Install WordPress on a Ubuntu/NGINX web server

cd /usr/share/nginx/html
sudo wget
sudo tar -xvzf latest.tar.gz
sudo rm latest.tar.gz
sudo cp -a /usr/share/nginx/html/wordpress/. /usr/share/nginx/html/
sudo rm -rf wordpress

Create DB for WP

mysql -u root -p

CREATE USER dbusername@localhost IDENTIFIED BY 'dbpassword';

GRANT ALL PRIVILEGES ON dbname.* TO  dbusername@localhost;

time to create our config file

cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

fill in the databasename, user and password that you just created with mysql/mariadb.

exit and save.

cd /usr/share/nginx/html
sudo mkdir wp-content/uploads
sudo chown www-data:www-data *
sudo find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x on all folders in the current folder
sudo find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r-- on all files in the current folder and subfolders.
sudo chmod 400 wp-config.php

Now go go into your enginx config file and configure it for WordPress:

sudo nano /etc/nginx/sites-available/default


        index index.html index.htm;


        index.php index  index.html index.htm;

// OPTIONAL STEP if you gonna have SSL on your site you might as well add this right now:

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

comment out

 # location / {
	# try_files $uri/ = 404;

and instead add this:
# Use cached or actual file if they exists, otherwise pass request to WordPress

        location / {
                try_files $uri $uri/ /index.php?$args;

Exit and save
Test the server configuration and restart, if test is not successful, you messed something up in the config.

sudo nginx -t
sudo service nginx restart

Add your comment