WordPress Setup Guide

WordPress Setup Guide

Section 3 – Setting up services

In order to setup a WordPress site that can be viewed by anybody on the internet, there are a number of software packages that you must install first.

These services can be described as follows:

  • Web Engine – Makes it possible for people to see your website.
  • Database – Gives your website somewhere to put all of its information.
  • PHP Engine – Needed for your website function properly.

Step 1) Copy the following code by clicking the “Copy” button in the box containing the code, then paste it into the console. To paste into the console, simply right click inside the console window.

For Ubuntu 18.04 LTS

bash -c 'apt update
apt install -y nginx mysql-server php7.2-fpm php7.2-mysql php7.2-gd php7.2-mbstring zip
wget -O ~/latest.zip https://wordpress.org/latest.zip
unzip ~/latest.zip -d /usr/share/nginx
chown -R www-data:www-data /usr/share/nginx/wordpress'

For Ubuntu 16.04 LTS

bash -c 'apt update
apt install -y nginx mysql-server php-fpm php-mysql php-gd php-mbstring zip
wget -O ~/latest.zip https://wordpress.org/latest.zip
unzip ~/latest.zip -d /usr/share/nginx
chown -R www-data:www-data /usr/share/nginx/wordpress'

A brief explanation of the above commands:

  • apt install…
    • Installs all of the necessary packages that I listed at the beginning of this section.
  • wget…
    • Goes out to the main WordPress website and downloads the latest version in zip format.
  • unzip…
    • Extracts the WordPress files from the file you downloaded with the previous command.
  • chown…
    • Makes the web-engine the owner of the WordPress files. This allows your site to function properly.

Your web-engine should now be accessible.

Optional Step) Test that the Web Engine is working properly by opening a web browser, and navigating to the IP Address of your server. This is the IP Address that was emailed to you by DigitalOcean. You should see the below result.

Step 2) Configure the Web Engine. To begin editing the configuration file, type the following command. This will open a text editor for a new, blank file.

nano /etc/nginx/sites-available/wordpress

Step 3) Copy the following code, and paste it into the blank file. A reminder: to paste into the file, simply right-click inside the console window. Replace bolded text with a domain name that you have purchased. (i.e. yourwebsite.com). If you do not have a domain name and wish only to use your IP Address, remove bolded portions altogether.

For Ubuntu 18.04 LTS

server {
    listen 80 default_server;
    root /usr/share/nginx/wordpress;
    server_name <YOUR_DOMAIN_NAME> www.<YOUR_DOMAIN_NAME> _;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
}

For Ubuntu 16.04 LTS

server {
    listen 80 default_server;
    root /usr/share/nginx/wordpress;
    server_name <YOUR_DOMAIN_NAME> www.<YOUR_DOMAIN_NAME> _;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
}

Step 4) Hold the Control key, and press ‘X’. The prompt at the bottom of the console window should change. Press ‘Y’ and press Enter.

Step 5) Run the following commands to enable your website configuration.

rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
systemctl restart nginx

Step 6) Type the following command to initiate a first-time setup of your database.

mysql_secure_installation

This will run a basic setup process to ensure your MySQL database is ready for use. Perform the following actions when prompted.

  1. “Would you like to setup VALIDATE PASSWORD plugin?”
    • Press Enter.
  2. “Please set the password for root here.”
    • Type a secure, memorable password.
  3. “Re-enter new password:”
    • Re-enter your secure, memorable password.
  4. “Remove anonymous users?”
    • Press Y, and press Enter.
  5. “Disallow root login remotely?”
    • Press Y, and press Enter.
  6. “Remove test database and access to it?”
    • Press Y, and press Enter.
  7. “Reload privilege tables now?”
    • Press Y, and press Enter.

Step 7) Type the following command to log into your database.

mysql -u root -p

Step 8) Enter the password you created earlier.

Step 9) When presented with a “mysql>” prompt. Type the following commands to prepare a database and user for your website.

In the below code, where it says ‘INSERT_PASSWORD_HERE’, come up with a secure, memorable password and enter it instead.

CREATE DATABASE wordpress;

CREATE USER 'wpadmin'@'localhost' IDENTIFIED BY 'INSERT_PASSWORD_HERE';

GRANT ALL ON wordpress.* TO 'wpadmin'@'localhost';

FLUSH PRIVILEGES;

quit

Now that all of the required packages are installed and configured on your server, you’re ready to move on to the next section, where you’ll setup WordPress! You’re nearly there.