Here is my guide on setting up WordPress on an Ubuntu server via the command line. Here is my recent guide on the wp-cli tool.
Read my guide on setting up a Vultr VM and installing NGINX web server and MySQL database. Use this link to create a Vultr account. This guide assumes you have a working Ubuntu VM with NGINX web server, MySQL, and SSL.
Consider setting up an SSL certificate (read my guide here on setting up a free SL certificate with Let’s Encrypt). Once again read my guide on Setting up a Vultr server. Also moving WordPress from CPanel to a self-managed server and securing Ubuntu in the cloud. Ensure you are backing up your server (read my guide on How to backup an Ubuntu VM in the cloud via crontab entries that trigger Bash Scripts, SSH, Rsync and email backup alerts).
Ensure MySQL is setup.
Ensure your server is setup, firewall enabled (port 80 and 443 enabled), NGINX is installed and working.
Check NGINX version
Check NGINX Status
Check your PHP install status to confirm your setup, put this in a new PHP file (e.g /p.php) and load it to view PHP configuration and to verify PHP setup.
First I edited NGINX configuration to allow WordPress to work.
location / { try_files $uri $uri/ /index.php?q=$uri&$args; index index.php index.html index.htm; proxy_set_header Proxy ""; }
Mostly I added this line.
try_files $uri $uri/ /index.php?q=$uri&$args;
I restated NGINX and PHP
nginx -t nginx -s reload sudo /etc/init.d/nginx restart sudo service php7.0-fpm restart
If this config change is not made WordPress will not install or run.
Database
In order to setup WordPress, we need to create a MySQL database/database user before downloading WordPress from the command line.
From an ssh terminal type (and log in with your MySQL root password)
Create a database (choose a database name, add random text).
mysql> create database databasemena123; Query OK, 1 row affected (0.00 sec)
Create a user and assign them to the blog (choose a username, add random text)
If your password is simple you will get this warning.
A 50+ char password with 10 digits and 10 numbers should be ok
You can now apply the permissions and clear the permissions cache.
Go to your /www folder on your server and run this command to download WordPress.
You can now move any existing temporary index files in your /www folder
mv index.html oldindex.html mv index.php oldindex.php p.php oldp.php ls -al total 8724 drwxr-xr-x 2 root root 4096 Aug 21 11:17 . drwxr-xr-x 27 root root 4096 Aug 13 22:27 .. -rw-r--r-- 1 root root 37 Jul 31 11:51 oldindex.html -rw-r--r-- 1 root root 37 Jul 31 11:51 oldindex.php -rw-r--r-- 1 root root 19 Aug 21 11:04 oldp.php -rw-r--r-- 1 root root 8910664 Aug 21 11:16 wordpress.zip
Now I can extract wordpress.zip
First, you need to install unzip
Now Unzip wordpress.zip
unzip wordpress.zip
At this point, I decided to remove all old index files on my website
The unzipped contents are in a sub folder called “wordpress”, we need to move the WordPress contents up a folder.
“wordpress” folder contents.
Remove the wordpress.zip in /www/
Move all files from the /www/wordpress/ up a folder to /www/.
Now we can create and upload folder
mkdir /www/wp-content/content/
Apply permissions (or you can never upload to WordPress).
chmod 755 /www/wp-content/uploads/
I think I need to apply permissions here (to allow plugins to upload/update)
Edit the wp-config-sample.php
Add your database name to the WordPress config.
Before:
After:
Add your database username and password to the WordPress config.
Before:
After:
Go to https://api.wordpress.org/secret-key/1.1/salt/ and copy the salts to your clipboard and replace this in your wp-config-sample.php
..with paste over whatever you generated (e.g)
Now save changes to wp-config-sample.php
Rename the sample config file (to make it live)
You can now load your website ( https://www.yourserver.com ) and finish the setup in the WordPress GUI.
WordPress should now be installed and you can log in.
Don’t forget to update your options – /wp-admin/options-general.php
I would recommend you review the options to prevent comment spam – /wp-admin/options-discussion.php
Also if you are using the twentyseventeen theme consider updating your header image (remove the pot plant) 0 /wp-admin/customize.php?theme=twentyseventeen&return=%2Fwp-admin%2Fthemes.php
Signup for a Vulr server here for as low as $2.5 a month or a Digital Ocean server ($10 free credit/2 months, signup for G Suite email on google here and read my guide here.
Read this guide on using the wp-cli tool to automate post-install.
I hope this helps.
Donate and make this blog better
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
v1.1 added wp-cli tool