This is a guide on how to install Wordpress on CentOS 9 Stream but it will also work on older versions of CentOS.
Install CentOS 9 Stream on your server.
Update the system packages using the package manager:
Prompt
sudo dnf update</code>
<h3 class="wp-block-heading" id="h-install-lamp-stack'>Install LAMP Stack</h3>
<p>Install Apache web server:</p>
<pre class="wp-block-code'><code>sudo dnf install httpd
Install MariaDB (MySQL compatible database server):
Prompt
sudo dnf install mariadb-server
Install PHP and required modules:
Prompt
sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring
Configure the LAMP Stack:
Start and enable Apache:
Prompt
sudo systemctl start httpd
sudo systemctl enable httpd
Start and enable MariaDB:
Prompt
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure your MariaDB installation by running:
Prompt
sudo mysql_secure_installation</code>
<h3 class="wp-block-heading" id="h-create-a-mysql-database-and-user'>Create a MySQL Database and User</h3>
<p>Log in to the MariaDB server as the root user:</p>
<pre class="wp-block-code'><code>sudo mysql -u root -p
Create a new database:
Prompt
CREATE DATABASE wordpress;
Create a new user and grant privileges to the database:
Prompt
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;</code>
<h3 class="wp-block-heading" id="h-download-and-configure-wordpress'>Download and Configure WordPress</h3>
Download the latest version of WordPress:</p>
<pre class="wp-block-code'><code>sudo dnf install wget
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
Move the extracted files to the Apache web root directory:
Prompt
sudo mv wordpress/* /var/www/html/
Configure the WordPress site by creating the wp-config.php file:
Prompt
cd /var/www/html/
sudo mv wp-config-sample.php wp-config.php
sudo vi wp-config.php
Update the database details in wp-config.php to match the database and user you created earlier
Set appropriate ownership and permissions for WordPress files:
Prompt
sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/
Edit the Apache configuration file:
Prompt
sudo vi /etc/httpd/conf/httpd.conf
Update the DirectoryIndex directive to include index.php:
Prompt
DirectoryIndex index.php index.html
Save the file and exit.
Restart Apache:
Suggest a Correction
Found an error or have a suggestion? Let us know and we'll review it.
No comments yet. Be the first to comment!