Install WordPress on Rocky Linux 8 with LEMP Stack

This tutorial guides you through installing WordPress on Rocky Linux 8 using a LEMP (Linux, Nginx, MySQL, PHP) stack. WordPress is a popular content management system (CMS) for creating websites and blogs.

rocky linux WordPress LEMP
XLarge
VPS
4
vCPU
16 GB
Memory
160 GB
NVMe Disk
8192 GB
Traffic
39.90
/month
* Up to 8 vCPU, 48GB RAM, 480GB NVMe Disk Space and 1Gbit/s Network Speed
#### Prerequisites Before you begin, ensure you have: - A server running Rocky Linux 8 - SSH access to your server with sudo privileges - Basic familiarity with the command line and package management on Rocky Linux #### Step 1: Install Nginx Install Nginx web server using DNF package manager: ```bash sudo dnf install nginx ``` Start Nginx and enable it to start on boot: ```bash sudo systemctl start nginx sudo systemctl enable nginx ``` #### Step 2: Install MySQL (MariaDB) Install MySQL database server (MariaDB) and secure the installation: ```bash sudo dnf install mariadb-server sudo systemctl start mariadb sudo systemctl enable mariadb sudo mysql_secure_installation ``` Follow the on-screen prompts to secure your MySQL installation. #### Step 3: Install PHP Install PHP and necessary PHP modules for Nginx: ```bash sudo dnf install php-fpm php-mysqlnd php-json php-gd php-mbstring ``` #### Step 4: Create a MySQL Database and User for WordPress Log into MySQL shell as root: ```bash sudo mysql -u root -p ``` Create a new database for WordPress: ```sql CREATE DATABASE wordpress; ``` Create a new user and grant privileges to the WordPress database: ```sql CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost'; FLUSH PRIVILEGES; EXIT; ``` Replace `'your_password'` with a strong password. #### Step 5: Download and Configure WordPress Download the latest WordPress package from the official site and extract it: ```bash wget https://wordpress.org/latest.tar.gz tar -xvzf latest.tar.gz sudo mv wordpress /var/www/html/wordpress ``` Set the correct permissions for WordPress files: ```bash sudo chown -R apache:apache /var/www/html/wordpress sudo chmod -R 755 /var/www/html/wordpress ``` #### Step 6: Configure Nginx for WordPress Create a new Nginx server block configuration file for your WordPress site: ```bash sudo nano /etc/nginx/conf.d/your_domain.conf ``` Add the following configuration (replace `your_domain` with your actual domain or IP): ```nginx server { listen 80; server_name your_domain; root /var/www/html/wordpress; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Optional: Add additional Nginx directives as needed } ``` Save and close the file. Test the Nginx configuration for syntax errors: ```bash sudo nginx -t ``` If no errors are reported, reload Nginx to apply the changes: ```bash sudo systemctl reload nginx ``` #### Step 7: Complete WordPress Installation Access your WordPress site in a web browser: ``` http://your-domain ``` Follow the on-screen instructions to complete the WordPress installation using the database credentials you created earlier. #### Conclusion You have successfully installed WordPress on Rocky Linux 8 using a LEMP stack. Begin creating and managing your website or blog with WordPress on your server. **Additional Resources:** - **WordPress Documentation:** [https://wordpress.org/support/](https://wordpress.org/support/) - **Nginx Documentation:** [https://nginx.org/en/docs/](https://nginx.org/en/docs/) - **PHP Documentation:** [https://www.php.net/docs.php](https://www.php.net/docs.php) - **Rocky Linux Documentation:** [https://docs.rockylinux.org/](https://docs.rockylinux.org/)


Created with ❤ at Estonia
EcoStack Technology OÜ