Installing WordPress on Ubuntu Linux with nginx is a straightforward process. Here's a step-by-step guide:
1. Install and Configure Nginx
- Install nginx:
sudo apt update sudo apt install nginx
- Start and enable nginx:
sudo systemctl start nginx sudo systemctl enable nginx
- Verify nginx is running:
sudo systemctl status nginx
2. Install and Configure MySQL
- Install MySQL:
sudo apt install mysql-server
- Secure MySQL:
sudo mysql_secure_installation
Follow the prompts to set a root password and configure other security settings.
- Create a database and user:
mysql -u root -p CREATE DATABASE wordpress; 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.
3. Download and Extract WordPress
- Download the latest WordPress version:
wget https://wordpress.org/latest.tar.gz
- Extract the archive:
tar -xzvf latest.tar.gz
4. Configure Nginx Virtual Host
-
Create a virtual host file:
sudo nano /etc/nginx/sites-available/wordpress
-
Add the following configuration:
server { listen 80; server_name your-domain.com; root /var/www/wordpress/public_html; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Replace 'your-domain.com' with your actual domain name.
-
Enable the virtual host:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
-
Test and reload nginx:
sudo nginx -t sudo systemctl reload nginx
5. Install PHP and PHP-FPM
- Install PHP and PHP-FPM:
sudo apt install php libapache2-mod-php php-mysql php-mbstring php-gd
- Start and enable PHP-FPM:
sudo systemctl start php7.4-fpm sudo systemctl enable php7.4-fpm
6. Configure WordPress
- Create a WordPress configuration file:
sudo cp /var/www/wordpress/public_html/wp-config-sample.php /var/www/wordpress/public_html/wp-config.php
- Edit the wp-config.php file:
- Replace the database connection details with your MySQL database credentials.
- Set the
AUTH_KEY
,SECURE_AUTH_KEY
,LOGGED_IN_KEY
,NONCE_KEY
,AUTH_SALT
,SECURE_AUTH_SALT
,LOGGED_IN_SALT
, andNONCE_SALT
constants with unique random strings. - Save the file.
7. Access and Configure WordPress
- Open your domain in a web browser.
- Follow the WordPress setup wizard to complete the installation.
8. Set Up SSL (Optional)
- Obtain an SSL certificate from a trusted certificate authority.
- Configure Nginx to use SSL.
- Redirect HTTP traffic to HTTPS.
Conclusion
By following these steps, you can successfully install WordPress on Ubuntu Linux with nginx. You'll have a fully functional WordPress website ready to be customized and populated with content.