To install WordPress with Nginx on Ubuntu, follow these steps:
1. Update your system
sudo apt update
2. Install required module
sudo apt install php-fpm php-mysql mysql-server nginx unzip
3. Setup mySql (Optional
)
You can skip this if already done
4. Configuring Nginx to work with PHP
Goto nginx directory
cd /etc/nginx/sites-available
Delete default (Optional
)
sudo rm default
Create Server Blocks for this Domain
sudo nano /etc/nginx/sites-available/domain1.com
Identify php sock version by following command
ls /var/run/php
Add the following content (adjust paths and domain names as needed and php sock version from above):
server {
listen 80;
server_name domain1.com www.domain1.com;
root /var/www/html/domain1.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust PHP version if necessary
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Create symbolic links in the site-enabled
directory
sudo ln -s /etc/nginx/sites-available/domain1.com /etc/nginx/sites-enabled/
Test Nginx Configuration. Make sure the Nginx configuration is correct:
sudo nginx -t
Restart Nginx
sudo systemctl restart nginx
5. Configuring Wordpress
Downloading Wordpress to the Ubuntu server
cd /var/www/html/domain1.com
sudo wget https://wordpress.org/latest.zip
Extract the file to domain1.com
sudo unzip latest.zip
sudo mv wordpress/* .
Remove unwanted files and folders
sudo rm latest.zip
sudo rm -R wordpress
Changing the owner of the Wordpress files
sudo chown -R www-data:www-data *
6. Databse details configure
Open domain1.com
and fill all the details.
From next page copy it's contains and create new file with this in /var/www/html/domain1.com
folder
sudo nano wp-config.php
Now complete remaining setup vi domain1.com
url
Top comments (0)