WordPress supports variety of open source tools and applications. For example, you can run WordPress with the support of the LAMP or LEMP stack.
This brief tutorial is going to show students and new users an easy way to install and run WordPress with support of HHVM ( Hip Hop Virtual Machine). HHVM was developed by Facebook to run applications that are based on PHP and the Hack language.
Most will agree that HHVM is faster than the traditional PHP stack. So, if you want to improve WordPress’ performance, running it on HHVM, MariaDB and Nginx might help a bit.
To get the setup correctly, follow the steps below:
Step 1: Prepare Ubuntu Server
Before installing packages on Ubuntu systems, you must first update and prepare the machine. Run the commands below to update and remove absolute packages from Ubuntu
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
After running the command above, you may want to reboot depending on what was installed and upgraded.
Step 2: Installing Nginx web server
Now that the Ubuntu machine is updated, run the commands below to install Nginx.
sudo apt-get install nginx
After installing Nginx, the commands below can be used to stop, start and enable Nginx
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Step 3: Install MariaDB
After installing Nginx webserver, the next step will be to install MariaDB database server. To do that, run the commands below.
sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to manage the database server
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
When you’re done running the commands above, run the command below to secure MariaDB and create the root password
When prompted, use the guide below to answer the questions
Enter current password for root (enter for none): PRESS ENTER
Set root password? [Y/n] Y
CREATE YOUR PASSWORD
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
Step 4: Create WordPress Database
The next step in the process is to create a database and database user for WordPress. To do that, we’re going to create a WordPress database called wpdb and user called wpuser.
To do that, run the command below to logon to MariaDB server
sudo mysql -u root -p
Then run the commands below to create a database called wpdb
CREATE DATABASE wpdb;
Next, run the commands below to create a database user called wpuser
CREATE USER wpuser;
Grant all privileges to the user to manage wpdb
GRANT ALL PRIVILEGES ON wpdb.* to 'wpuser'@'localhost' IDENTIFIED BY 'new_password_here';
Finally flush the permission to save your changes
Step 5: Installing HHVM
To install HHVM on Ubuntu you must add its repository and key. To do that, run the commands below to install the repository’s key.
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
Run the commands below to install the repository
sudo sh -c "echo 'deb http://dl.hhvm.com/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/HHVM.list"
After that, run the commands below to install HHVM
sudo apt-get update
sudo apt-get install -y hhvm
Nginx, run the commands below to configure HHVM to work with Nginx web server
Run the commands below make HHVM the default PHP compiler
/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
Finally, fun the commands below to start and enable HHVM
sudo systemctl start hhvn
sudo update-rc.d hhvm defaults
Step 6: Configure Nginx and Install WordPress
Now that all the servers and modules are installed, go and configure Nginx to server PHP applications. To do that, open Nginx default site configuration and add an index for php.
sudo nano /etc/nginx/sites-available/default
Then add the php index.
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
Save the file and you’re done.
STEP 7: DOWNLOAD WORDPRESS CONTENT FROM ONLINE
Now that you’ve installed all the servers and packages that WordPress needs, it’s time to download WordPress content. To download the content, run the commands below.
cd /tmp/ && wget http://wordpress.org/latest.tar.gz
Next, extract the downloaded content by running the commands below.
tar -xvzf latest.tar.gz
STEP 8: CONFIGURE WORDPRESS TO RUN
After extracting WordPress’ content, the first thing you’ll want to do is delete Apache2 default file in its root directory.
sudo rm /var/www/html/index.nginx-debian.html
Next, move WordPress content to Apache2’s root directory by running the commands below.
sudo mv wordpress/* /var/www/html/
After moving WordPress content to its root directory, use the command below to make a copy of wp-config-sample.php file and name it wp-config.php.
The wp-config.php is the default configuration file for WordPress in its root folder.
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
Next, edit wp-config.php file and make the below changes.
sudo nano /var/www/html/wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Save your changes when done.
Finally, run the commands below to set the correct files and folders permissions for WordPress to function properly.
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html/
After all of the above, restart Apache2 web server.
sudo systemctl restart nginx.service
STEP 8: LAUNCH WORDPRESS INSTALLATION
The final step is to open your web browser and browse to the server IP address or hostname. You should be prompt with WordPress default setup page.
If you see this page, then everything went perfect!
Continue with WordPress setup wizard until you’re done. When you’re done.. you’ll have fully installed WordPress on HHVM.