Fast WordPress hosting, for development

On some occasions surely you need to mount a WordPress very fast to develop but avoid having to mount the entire system completely. If this is your case, you can make it easy and fast.

We already have a manual to mount a stable WordPress on Ubuntu 18. Based on this possibility, we will see how to mount a VPS (or local) in which you do not have to mount much system. The main thing is to have a database mounted, and have PHP. Nothing else.

We start from the basis that we set up a cheap VPS. In this case, we will prepare the whole process from scratch.

Once the operating system is installed, the first thing we will configure will be the server time. In this case, we will configure the time zone of Madrid.

timedatectl set-timezone 'Europe/Madrid'
timedatectl set-ntp on

The next thing we will do is check the version of the operating system and, subsequently, make a complete update of it.

lsb_release -a
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove

Once everything is updated, we install some tools and base software that can be useful to have on the system.

apt -y install software-properties-common curl vim unzip ufw

The next step will be the installation of the database. In this case, we are going to use MariaDB 10.3. The first thing we will do is configure the download, and then its installation.

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://tedeco.fi.upm.es/mirror/mariadb/repo/10.3/ubuntu bionic main'
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install mariadb-server mariadb-client

Now that it is installed, we will proceed to the initial configuration. For this, we will use the secure installation system, which will ask us some questions.

mysql_secure_installation

To the question of whether we want to change the password, depending on whether or not we have put in the installation, we will change it. In case you have not put any, it is highly recommended to put a strong password.

Set root password? [Y/n]: Y

To the rest of the questions, we will answer the following:

Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

At this time we will have the database configured. Now we will make it run on the system restarts and start it.

systemctl stop mysql.service
systemctl start mysql.service

Now we are going to install and configure PHP to work properly with the database and to act as a web server. In this case, we are going to install PHP version 7.3. First we will do the installation of the most updated packages (which are not those that come with the operating system) and that in case of needing it, in addition, they would allow us to have several versions of PHP in parallel.

add-apt-repository ppa:ondrej/php
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install php7.3 php7.3-fpm php7.3-common php7.3-dev php7.3-cli php7.3-bcmath php7.3-curl php7.3-gd php7.3-imap php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-soap php7.3-xml php7.3-xmlrpc php7.3-zip php-imagick php-libsodium php-ssh2 php-xdebug libgeoip-dev

Now that we have PHP and MariaDB we can start working since they are the two essential requirements for WordPress to work. How is this possible? Well, thanks to the fact that PHP for a few versions incorporates an internal web server, which, although it is not extremely stable, is enough to keep it in developer mode.

To do this, we will create and enter where we want to host our WordPress.

mkdir /home/example.com/
mkdir /home/example.com/public_html/
cd /home/example.com/public_html/

Once we have the folder structure created we can download WordPress and unzip it.

wget https://wordpress.org/latest.zip
unzip latest.zip
cd wordpress/

Now that we have WordPress downloaded and in its folder, we can boot the web server. The system works perfectly by putting the public IP, if we work on a VPS and by the HTTP port (80) as if we work locally (put the public or private IP of your machine:

php -S 127.0.0.1:80

Now it is as simple as entering the browser and accessing the web with the IP:

http://127.0.0.1:80/

It can also be configured (if you have a web server in production) for example on another port, changing the :80 by :8000 u :8080.


About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.