ubuntu
How-To Linux

Self host WordPress on Vultr VPS on Ubuntu 14.04

0Shares

First things first and disclaimers

You should already have a Vultr instance running with Ubuntu 14.04 that’s ready to go and have SSH access to it. Vultr does also offer a one-click install for WordPress that gets installed on CentOS. Feel free to use that, I just prefer Ubuntu is all.

This also isn’t the one and only way to setting up a LAMP stack and installing WordPress. This just happens to be a template I use over and over. Simply use this as a guide.

Edit: This is a little out of date with new versions of Ubuntu out and newer, easier ways of doing things.  However, this could still be helpful as a guide to most.

And on with it

Getting Passwords Ready
https://xkpasswd.net/s/

Document different passwords for each:

  • Root
  • MySQL Root
  • MySQL User

Setup Web Host

cat >> /etc/hosts <<EOF
<PUBLIC IP> site.com
EOF

Install Packages

Add PHP7 PPA and get things up to date.

apt-get update
apt-get install software-properties-common
add-apt-repository -y ppa:ondrej/php
apt-get update
apt-get dist-upgrade -y
apt-get install -y mariadb-server php7.0 php7.0-mysql apache2 libapache2-mod-php7.0 php7.0-xml php7.0-gd

Use your super secret password you documented from above.

root: <MySQL Root Password>

Secure MySQL.

mysql_secure_installation
No
Yes
Yes
Yes
Yes
nano /etc/apache2/mods-enabled/dir.conf
  • Change the first HTML to PHP
  • Change the second PHP to HTML

Some of the needed modules are not enabled by default, so enable them.

a2enmod \
expires \
headers \
rewrite \
ssl

Remove insecure ciphers and protocols and enable perfect forward secrecy if all parties support it.

sed -i \

's/^\(\s*\)#\?\s*SSLHonorCipherOrder\s.*/\1SSLHonorCipherOrder On/' \

/etc/apache2/mods-available/ssl.conf

 

sed -i \

's/^\(\s*\)#\?\s*SSLProtocol.*/\1SSLProtocol ALL -SSLv2 -SSLv3/' \
 
/etc/apache2/mods-available/ssl.conf

 

sed -i \

's/^\(\s*\)#\?\s*SSLCipherSuite\s.*/\1SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS/' \

/etc/apache2/mods-available/ssl.conf

Turn off the expose_php setting.

sed -i "s/expose_php =.*/expose_php = Off/" /etc/php/7.0/apache2/php.ini

Setup your database.

mysql -u root -p
<MySQL root password>
CREATE DATABASE <db-name>;
CREATE USER <user>@localhost IDENTIFIED BY '<MySQL user password>';
GRANT ALL PRIVILEGES ON <db-name>.* TO "<user>"@"localhost";
FLUSH PRIVILEGES;
QUIT

Install WordPress.

cd ~
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cd ~/wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php

Retrieve SALTs:

Paste in wp-config.php

While you’re in the wp-config.php, be sure to update the database connection settings above the SALTs area.

sudo rsync -avP ~/wordpress/ /var/www/html/
cd /var/www/html
mkdir /var/www/html/wp-content/uploads
sudo chown -R www-data:www-data *
chown -R www-data:www-data /var/www/html/wp-content/uploads

Change File size and Post size limits. (you can use CNTL + W to search when using nano)

nano /etc/php/7.0/apache2/php.ini
upload_max_filesize = 32M
post_max_size = 16M

Fix permalinks.

nano /etc/apache2/apache2.conf

Ensure Allow Override is enabled:

AllowOverride All

And finally just to flush everything out and get a fresh start, I reboot the server real quick. This is probably overkill but it makes me feel better.

sudo shutdown -r now

Now go to your site’s URL and test it out. You should be presented with a WordPress site setup dialog. What I usually do at this point is go ahead with setting up SSL.

Travis Wade
Travis Wade
Just a normal human being living the dream. I'm an IT professional in the Healthcare space with a love and passion for cloud computing and highly redundant infrastructure.
https://www.travisnwade.com/

Leave a Reply

Your email address will not be published. Required fields are marked *