This tutorial describes the installation of Nginx, MariaDB, HHVM and Wordpress on Debian 8 (Jessie).
1 Prerequisites
The server should run a Debian 8 (64Bit) minimal server install. If you install the server from scratch, then take a look at this guide to
get a clean minimal install. I will use the IP 192.168.1.100 as my
server IP. Please replace this IP with your server IP in all commands
where it appears.
2 Install Nginx
The Nginx package is available in the Debian apt repository. Nginx can be installed with the following command:
apt-get update
apt-get install nginx unzip
apt-get install nginx unzip
Restart Nginx when the installation is completed.
systemctl start nginx
Now you can test Nginx in your browser to see if it is installed properly. Open the server IP: http://192.168.1.100/. You should see a page similar to the one below.
3 Install and Configure MariaDB
I will install MariaDB instead of MySQL to take advantage of its better performance and additional functions. MariaDB is a fork of the MySQL Database Server maintained by the original MySQL Developers.To install MariaDB, run the following apt-get command:
apt-get install mariadb-client mariadb-server
And start MariaDB with systemctl:
systemctl start mysql
Now login to MariaDB with the "mysql" command, the command will
request the password that you have set during MariaDB install above.
mysql -u root -p
TYPE YOUR PASSWORD
The next step is to create a new database with the name wordpressdb and new database user with the name wpuser
for the WordPress installation. Execute the commands below inside the
MySQL prompt to achieve that. Replace the password 'wpuser@' with
a secure password that will be used as password for the new WordPress database.TYPE YOUR PASSWORD
create database wordpressdb;
create user wpuser@localhost identified by 'wpuser@';
grant all privileges on wordpressdb.* to wpuser@localhost identified by 'wpuser@';
flush privileges;
\q
create user wpuser@localhost identified by 'wpuser@';
grant all privileges on wordpressdb.* to wpuser@localhost identified by 'wpuser@';
flush privileges;
\q
4 Install and Configure HHVM
Add the repository from hhvm.com to the Ubuntu repository file /etc/apt/sources.list and update the repository:
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
echo deb http://dl.hhvm.com/debian jessie main | tee /etc/apt/sources.list.d/hhvm.list
apt-get update
Then install the HHVM package:echo deb http://dl.hhvm.com/debian jessie main | tee /etc/apt/sources.list.d/hhvm.list
apt-get update
apt-get install hhvm
HHVM comes with a script install_fastcgi.sh to connect Nginx with HHVM. Run the command below:
/usr/share/hhvm/install_fastcgi.sh
Configure HHVM to start automatically when the server boots:
update-rc.d hhvm defaults
HHVM shall be used for /usr/bin/php even if you have php-cli
installed, so we run the Debian update-alternatives script to
reconfigure the default PHP:
/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
Then start HHVM with systemctl:
systemctl start hhvm
In the next step, I will test if HHVM is used to parse PHP pages in Nginx and on the shell.Create new file with the name info.php in the directory /var/www/html/:
cd /var/www/html/
nano info.php
And add this PHP code into the file:nano info.php
<?php echo 'HipHop'; ?>Now access the file in your browser: http://192.168.1.100/info.php. When you see the word HipHop in your web page, then HHVM is working correctly.
Finally test HHVM in your server console/terminal, type this command:
php info.php
php -v
The first command shall show the word "HipHop", the second command the HHVM version.php -v
rm /var/www/html/info.php
5 Install Wordpress
Enter the /var/www/html/ folder, download WordPress and extract the archive:
cd /var/www/html/
wget wordpress.org/latest.zip
unzip latest.zip
The unzip command extracts Wordpress into the "wordpress" sub-directory,
I will move all WordPress files and directories to /var/www/html/ as I
like to access wordpress on / on the server and not on /wordpress/:wget wordpress.org/latest.zip
unzip latest.zip
cd /var/www/html/
mv wordpress/* .
rm -rf wordpress/
Then change the owner of the WordPress files to the user and group www-data. Normally, all files in the /var/www/html/ directory are owned by the www-data user and group.mv wordpress/* .
rm -rf wordpress/
find . -type d -exec chown www-data:www-data {} \;
find . -type f -exec chown www-data:www-data {} \;
Rename the file wp-config-sample.php to wp-config.php. Then
open the file with the nano editor and set the database name, user and
password that was created during the database setup.find . -type f -exec chown www-data:www-data {} \;
mv wp-config-sample.php wp-config.php
nano wp-config.php
nano wp-config.php
DB_NAME = wordpressdb DB_USER = wpuser DB_PASSWORD = wpuser@
Now edit the nginx virtualhost file /etc/nginx/sites-available/default, and add index.php as the first item of the index config setting. This setting instructs Nginx to use the index.php file as the standard index file when the website is accessed with / (without a file name).
rm -f index.nginx.html
nano /etc/nginx/sites-available/default
nano /etc/nginx/sites-available/default
Then restart Nginx:
systemctl restart nginx
Try to access server IP: http://192.168.1.100/ again, you will be redirected to the WordPress installer. Follow the instructions of the installer to finish the installatiom.1) Please choose your language, example: English(United States) and press the button Continue.
2) Fill in the username and password that shall be used to authenticate the WordPress administrator and your email address, then press the Install Wordpress button.
Wait until the installation is finished, then go to the WordPress administrator Login: http://192.168.1.100/wp-login.php, or visit WordPress home page http://192.168.1.100/.
Wordpress is now installed with HHVM and Nginx on your Debian 8 server.
6 Conclusion
The setup described in this tutorial combines some of the fastest software options to run a Wordpress site. Nginx is a widely used high-performance web server that is able to serve pages faster than the traditional Apache web server, HHVM is a high-speed replacement for the PHP Zend engine to run PHP scripts and MariaDB is a very fast MySQL replacement.This tutorial is based on the Howtoforge tutorial from Muhammed Arul for Ubuntu 15.04.
Thank you
No comments:
Post a Comment