How to Install WordPress on CentOS 8: A Comprehensive Guide
Welcome to the Greenhost.Cloud blog! Today, we’re diving into the world of WordPress, one of the most popular content management systems (CMS) out there. If you’re looking to set up your own WordPress site on a CentOS 8 server, you’ve come to the right place. In this step-by-step guide, we’ll walk you through the process of installing WordPress, empowering you to create your own website or blog in no time.
Prerequisites
Before we dive into the installation process, ensure you have the following:
- CentOS 8 Server: A virtual private server (VPS) or dedicated server running CentOS 8.
- Root Access: You need to have root or sudo privileges on the server.
- LAMP Stack: The Light, Apache, MySQL, PHP (LAMP) stack should be installed on your CentOS 8 server.
If you haven’t installed LAMP yet, you can follow these steps:
Step 1: Install the LAMP Stack
- Update your system packages:
sudo dnf update -y- Install Apache:
sudo dnf install httpd -y- Start and enable Apache:
sudo systemctl start httpd
sudo systemctl enable httpd- Install MySQL (MariaDB):
sudo dnf install mariadb-server -y- Start and secure MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installationFollow the prompts to secure your installation.
- Install PHP and required extensions:
sudo dnf install php php-mysqlnd php-fpm php-xml php-mbstring php-curl -y- Restart Apache:
sudo systemctl restart httpdStep 2: Create a Database for WordPress
- Log in to the MariaDB shell:
sudo mysql -u root -p- Create a database (replace
wordpress_dbwith your preferred database name):
CREATE DATABASE wordpress_db;- Create a user (replace
wordpress_userandpasswordwith your chosen username and password):
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';- Grant privileges to the user on the database:
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;Step 3: Download and Configure WordPress
- Navigate to your web root directory:
cd /var/www/html- Download the latest version of WordPress:
sudo dnf install wget -y
wget https://wordpress.org/latest.zip- Install unzip (if not already installed):
sudo dnf install unzip -y- Unzip the WordPress files:
sudo unzip latest.zip- Set the correct permissions:
sudo chown -R apache:apache /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress- Create a configuration file:
cd wordpress
cp wp-config-sample.php wp-config.php- Edit the
wp-config.phpfile:
sudo nano wp-config.phpUpdate the following lines to match your database details:
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'password');Step 4: Configure Apache
- Create a new configuration file for your WordPress site:
sudo nano /etc/httpd/conf.d/wordpress.conf- Add the following configuration:
<Directory "/var/www/html/wordpress">
AllowOverride All
</Directory>- Enable the Rewrite Module:
sudo dnf install mod_rewrite- Restart Apache:
sudo systemctl restart httpdStep 5: Complete the Installation Through the Web Interface
- Open your web browser and go to:
http://your-server-ip/wordpress- You should see the WordPress installation page. Follow the prompts to set up your site title, username, password, and email address.
- Complete the installation by clicking the “Install WordPress” button.
- After installation, login to your new WordPress site at:
http://your-server-ip/wordpress/wp-adminConclusion
Congratulations! You’ve successfully installed WordPress on CentOS 8. This powerful CMS opens up a world of possibilities for creating and managing your website. Don’t forget to keep your system and WordPress installation updated for security and performance.
We hope you found this guide helpful. If you have any questions or need further assistance, feel free to reach out in the comments section below. Happy blogging!
For more tutorials and tips on managing your web presence, stay tuned to the Greenhost.Cloud blog!