Updated: 2020-08-17
Update.
sudo apt update
Upgrade.
sudo apt upgrade
Install Nginx Web Server.
sudo apt install nginx
Allow HTTP connections.
Only if UFW is installed and running.
sudo ufw allow 'Nginx HTTP'
Installing MySQL Database.
sudo apt install mysql-server
Run MySQL script to secure the installation.
sudo mysql_secure_installation
Set a password for root MySQL user.
sudo mysql
Check authentication method of each MySQL user accounts.
SELECT user,authentication_string,plugin,host FROM
mysql.user;
Configure the root account to authenticate with a password.
ALTER USER 'root'@'localhost' IDENTIFIED WITH
mysql_native_password BY 'password';
Flush the privileges.
FLUSH PRIVILEGES;
Exit MySQL.
EXIT;
Now the root user must login with a password.
mysql -u root -p
Add Ubuntu's universe repository.
sudo add-apt-repository universe
Install the php-fpm module along with an additional helper packages.
sudo apt install php-fpm php-mysql
mysql -u root -p
You will need to enter your MySQL password.
Create a Database for your WordPress site.
CREATE DATABASE your_db_name
DEFAULT CHARACTER SET utf8
COLLATE utf8_unicode_ci;
Create user account, set a password, and grant access to the database.
GRANT ALL ON your_db_name.* TO 'your_db_user'@'localhost' IDENTIFIED BY 'password';
Flush privileges.
FLUSH PRIVILEGES;
Exit.
EXIT;
Make tmp directory to download WordPress archive.
sudo mkdir tmp
Download WordPress.
cd tmp
wget https://wordpress.org/latest.tar.gz
Extract contents.
tar -xf latest.tar.gz
Create website directory.
sudo mkdir -p /var/www/html/termtools.com
Move WordPress contents to your new website directory.
sudo mv wordpress/* /var/www/html/termtools.com/
Update permissions so www-data owns everything.
sudo chown -R www-data: /var/www/html/termtools.com
Create your new site config file inside the /etc/nginx/sites-available directory.
sudo vim /etc/nginx/sites-available/termtools.com
server { server_name termtools.com www.termtools.com; root /var/www/html/www.termtools.com; index index.php index.html index.htm; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; error_log /var/log/nginx/termtools_error.log; access_log /var/log/nginx/termtools_access.log; charset utf-8; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; allow all; } location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { expires max; log_not_found off; } location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } location ~ /\.ht { deny all; } }
Create symbolic link from new server block configuration to sites-enabled directory.
sudo ln -s /etc/nginx/sites-available/termtools.com /etc/nginx/sites-enabled/
Unlink the default configuration file from the sites-enabled directory.
sudo unlink /etc/nginx/sites-enabled/default
Test new configuration file.
sudo nginx -t
Reload Nginx.
sudo service nginx reload
Copy wp-config-sample.php.
cp wp-config-sample.php wp-config.php
Create upgrade directory, so WordPress won't run into permission issues.
mkdir wp-content/upgrade
Fix file permissions.
sudo find . -exec chown cmac:www-data {} +
sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php