How to Setup WordPress with Nginx and HHVM on Ubuntu 16.04

Prerequisites

  • A fresh Alibaba cloud instance with Ubuntu 16.04 server installed.
  • A static IP address 192.168.0.103 is configured on the instance.
  • A root password is setup on the server.

Launch an Alibaba Cloud ECS Instance

First, login to your Alibaba Cloud ECS Console. Create a new ECS instance, with Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

apt-get update -y

Install Nginx and MariaDB

First, you will need to install Nginx web server and MariaDB to your server. You can install them using the following command:

apt-get install nginx mariadb-server mariadb-client -y
systemctl start nginx
systemctl enable nginx
systemctl start mariadb
systemctl enable mariadb

Configure MariaDB

By default, MariaDB installation is not secured, so you will need to secure it first. You can secure it by running the mysql_secure_installation script:

mysql_secure_installation
Enter current password for root (enter for none): PRESS ENTER
Set root password? [Y/n] n
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
mysql -u root -p
MariaDB [(none)]> create database wordpressdb;
MariaDB [(none)]> grant all privileges on wordpressdb.* to wordpress@localhost identified by 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

Install and Configure HHVM

By default, HHVM is not available in Ubuntu 16.04 default repository. So you will need to add HHVM repository to your system. You can do this by running the following command:

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"
apt-get update -y
apt-get install hhvm -y
HHVM is installed.
The best way to get started is to use HHVM's built-in webserver:
$ hhvm -m server -p 8080
Running command-line scripts with HHVM requires no special setup:
$ hhvm whatever.php
FastCGI is also supported; see https://docs.hhvm.com/hhvm/advanced-usage/fastCGI
/usr/share/hhvm/install_fastcgi.sh
[ ok ] Starting hhvm (via systemctl): hhvm.service.
Checking if Apache is installed
WARNING: Couldn't find Apache2 configuration paths, not configuring
Checking if Nginx is installed
Detected Nginx installation
Checking for custom Nginx configuration
Enabling hhvm Nginx module
Finished enabling module
Restarting Nginx
update-rc.d hhvm defaults
/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
systemctl start hhvm
systemctl status hhvm
hhvm.service - LSB: Starts The HHVM FastCGI Daemon
Loaded: loaded (/etc/init.d/hhvm; bad; vendor preset: enabled)
Active: active (running) since Wed 2018-05-16 21:13:19 IST; 1min 14s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/hhvm.service
├─3365 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/
├─3389 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/
├─3390 sh -c /usr/bin/hh_single_compile -v Hack.Compiler.SourceMapping=1 --daemon
└─3392 /usr/bin/hh_single_compile -v Hack.Compiler.SourceMapping=1 --daemon
May 16 21:13:18 Node1 systemd[1]: Starting LSB: Starts The HHVM FastCGI Daemon...
May 16 21:13:19 Node1 systemd[1]: Started LSB: Starts The HHVM FastCGI Daemon.
May 16 21:14:29 Node1 systemd[1]: Started LSB: Starts The HHVM FastCGI Daemon.
php -v
HipHop VM 3.26.2 (rel)
Compiler: 1526415369_337251688
Repo schema: 7960f749dc8fba766d4ac967f6693b0ff0f1430b

Install WordPress

First, you will need to download the latest version of the WordPress from their official website. You can do this with the following command:

wget https://wordpress.org/latest.zip
unzip latest.zip
cp -r wordpress/* /var/www/html/
cd /var/www/html/
cp wp-config-sample.php wp-config.php
nano wp-config.php
/* The name of the database for WordPress /
define('DB_NAME', 'wordpressdb');
/* MySQL database username /
define('DB_USER', 'wordpress');
/* MySQL database password /
define('DB_PASSWORD', 'password');
/* MySQL hostname /
define('DB_HOST', 'localhost');
chown -R www-data:www-data /var/www/html/
chmod -R 775 /var/www/html/
systemctl restart nginx
systemctl restart hhvm

Access WordPress Web Installation Wizard

Now, open your web browser and type the URL http://your-server-ip/index.php, you will be redirected to the following page:

Related Alibaba Cloud Products

ApsaraDB for RDS is an on-demand database service that frees you up from the administrative task of managing a database, and leaves you with more time to focus on your core business. ApsaraDB for RDS is a ready-to-use service that is offered on MySQL, SQL Server and PostgreSQL. RDS handles routine database tasks such as provisioning, patch up, backup, recovery, failure detection and repair.
Distributed Relational Database Service is a lightweight (stateless), flexible, stable, and efficient middleware product independently developed by Alibaba Group to resolve scalability issues with single-host relational databases.
DRDS is primarily used for large-scale online data operations to operate, maintain and manage distributed databases throughout their entire lifecycle. Due to is compartmentalized structure, DRDS provides an efficient way to perform operations to meet the demand of the online services for relational databases.
Alibaba Cloud Virtual Private Cloud Alibaba Cloud VPC allows the flexibility to build your cloud architecture in a logically isolated and secure environment. This means users can control their virtual networking environment, including the selection of IP address range, the creation of subnets and configuration of route tables and network gateways. Users can also segregate VPC instances into different security domains using security group features.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com