Here is Step by Step Guide to Install WordPress on Nginx With HHVM on Ubuntu Cloud Server. This simple and most easy standalone HHVM only guide. We talked about HipHop Virtual Machine or HHVM in order article. Normally, with Nginx, we use PHP5-FPM. This guide is how to install WordPress on Nginx with HHVM on Ubuntu Cloud Server without PHP5-FPM. You can use Dedicated or non-Cloud instances too, but we prefer using a separate application server to run MySQL.
Install WordPress on Nginx With HHVM : Basic Warnings
Do not try the method on Production Server first. Use test instances. You can open an account on DigitalOcean using this link, if you have a Credit Card and no Account on DigitalOcean. You’ll get $10 account credit plus you can add any coupon (if applicable) to increase your account’s credit. Enough to test our guides free of cost. Once you have used DigitalOcean for one month – we offer a SSL Certificate from Geotrust for one year. This complete package is for our own industry’s usage. Not for mass promotion. Quite practical – why you’ll waste money to test and learn how to install WordPress on Nginx with HHVM on Ubuntu Cloud Server? We will not get any money. People do not use these resources out of fear of getting scammed or may be they dislike that others will make money. The referral code is not ours, it is of a free software project. That is to assure you.
Back to topic – this is pure HHVM only instance. WordPress on Nginx With HHVM can have conflicts with some plugins. In next guide, we will show you to add PHP5-FPM as fallback. That is for preventing the conflict. That is why I asked to get a free account. We will change the database in next another guide. It is not practical to waste money only to test.
---
Install WordPress on Nginx With HHVM : Initial Steps
We are taking that you are using either DigitalOcean or Rackspace Cloud or HP Cloud to test. For HP Cloud, you need to set Ingress-Egress policy. HP Cloud is a bit hard and great to learn networking and OpenStack.
Spin a 4GB instance with Ubuntu 14.04 LTS image. First SSH to the instance :
1 2 3 4 5 6 7 8 9 10 11 12 13 | ssh root@IP-Address ##The authenticity of host '127.0.0.1' can't be established. ##ECDSA key fingerprint is ################ ##Are you sure you want to continue connecting (yes/no)? # type yes and hit the return key # you will have the password, use it and change it # upgrade and update apt-get update -y && apt-get upgrade # do a dist-upgrade apt-get diet-upgrade -y # reboot and login again ssh root@IP-Address |
First install Nginx and the other needed components :
1 2 3 4 | apt-get install php5-gd libssh2-php add-apt-repository -y ppa:nginx/stable apt-get update -y apt-get install nginx |
As we will use a separate MySQL server (read how to run separate application server to run MySQL), we will optionally install :
1 | apt-get install mysql-client |
this is optional, needed only to access the applicational server from SSH. We have not installed :
1 | apt-get install snmp php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache |
You can install them later on need – php5-fpm
will get installed and you are a new user need not to care as I will make PHP-FPM not to handle PHP anymore. Our target is to install WordPress on Nginx with HHVM.
These are needed :
1 | apt-get install -y unzip vim git-core curl wget build-essential |
Install WordPress on Nginx With HHVM : Steps to Install HHVM and Configure Nginx
These are the commands for Ubuntu 14.04 :
1 2 3 4 | wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add - echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list sudo apt-get update sudo apt-get install hhvm |
Go to /usr/share/nginx/html
(public folder) and do these :
1 2 3 4 5 | cd /usr/share/nginx/html && nano hhvm.php # copy the things or type <?php echo defined('HHVM_VERSION')?'Using HHVM':'Not using HHVM'; ?> |
We will configure HHVM first :
1 | nano /etc/hhvm/config.hdf |
Actually the file should look exactly like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Log { Level = Warning AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 8191 } MySQL { TypedResults = false } Eval { JitASize = 67108864 JitAStubsSize = 67108864 JitGlobalDataSize = 22554432 } |
After that, we will edit the server.hdf
file :
1 | nano /etc/hhvm/server.hdf |
The edited file should look like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | PidFile = /var/run/hhvm/pid Server { Port = 80 SourceRoot = /usr/share/nginx/html DefaultDocument = index.php } Log { Level = Warning AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 8191 UseLogFile = true UseSyslog = false File = /var/log/hhvm/error.log Access { * { File = /var/log/hhvm/access.log Format = %h %l %u % t "%r" %>s %b } } } Repo { Central { Path = /var/log/hhvm/.hhvm.hhbc } } #include "/usr/share/hhvm/hdf/static.mime-types.hdf" StaticFile { FilesMatch { * { pattern = .*.(dll|exe) headers { * = Content-Disposition: attachment } } } Extensions : StaticMimeTypes } MySQL { TypedResults = false } |
Notice the root is /usr/share/nginx/html
. Last work is to edit the HHVM server.conf
file :
1 | nano /etc/hhvm/server.conf |
After Editing, it should look like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | PidFile = /var/run/hhvm/pid Server { IP = 127.0.0.1 Port = 9000 } Log { Level = Warning AlwaysLogUnhandledExceptions = true RuntimeErrorReportingLevel = 8191 UseLogFile = true UseSyslog = false File = /var/log/hhvm/error.log Access { * { File = /var/log/hhvm/access.log Format = %h %l %u % t "%r" %>s %b } } } Repo { Central { Path = /var/log/hhvm/.hhvm.hhbc } } StaticFile { FilesMatch { * { pattern = .*.(dll|exe) headers { * = Content-Disposition: attachment } } } Extensions { css = text/css gif = image/gif html = text/html jpe = image/jpeg jpeg = image/jpeg jpg = image/jpeg png = image/png tif = image/tiff tiff = image/tiff txt = text/plain } } MySQL { TypedResults = false } Eval { Jit = true } VirtualHost { * { Pattern = .* RewriteRules { * { pattern = ^(.*)$ to = index.php$1 qsa = true } } } } |
Restart HHVM :
1 | /etc/init.d/hhvm restart |
You should see HHVM running at port 9000 :
1 | netstat -plunt | grep hhvm |
I am taking that, you have installed all the stuffs, so Nginx is running with PHP5-FPM, we will modify the configuration file to disable the use of PHP5-FPM. By default, the config file is normally located at /etc/nginx/sites-available/default
, so open it and fully remove (comment out with #) these lines :
1 2 3 4 5 6 7 8 9 10 11 12 | # #location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_index index.php; # include fastcgi_params; #} |
You should have this instead :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | location / { root /usr/share/nginx/html; index index.php index.html index.htm; # WordPress rewrite rules for permalinks try_files $uri $uri/ /index.php?$args; } # php parsing by HHVM @ port 9000 location ~ .php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } |
You must have this on that file :
1 2 | ... include hhvm.conf; |
Now run this script for the sake of FPM :
1 | /usr/share/hhvm/install_fastcgi.sh |
There is another file, its the php.ini
:
1 | nano /etc/hhvm/php.ini |
At least do these :
1 2 3 4 5 6 | ; php options upload_max_filesize = 512M post_max_size = 1024M memory_limit = 2048M register_globals = off track_errors = yes |
There are more two files, open /etc/hhvm/server.ini
and make sure, whether these are present :
1 | nano /etc/hhvm/server.ini |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | pid = /var/run/hhvm/pid ; hhvm specific hhvm.server.file_socket=/var/run/hhvm/hhvm.sock hhvm.server.type = fastcgi hhvm.server.default_document = index.php hhvm.log.level = Warning hhvm.log.always_log_unhandled_exceptions = true hhvm.log.runtime_error_reporting_level = 8191 hhvm.log.use_log_file = true hhvm.log.file = /var/log/hhvm/error.log hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc hhvm.mysql.typed_results = false |
Last file related to HHVM is :
1 | /etc/hhvm/automagic.sh |
make sure, whether these are present :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #! /bin/bash # Use this script on a cron every minute to restart hhvm if it crashes if [ "$1" == "" ]; then echo "Usage: `basename $0` svcname" exit 1 fi SVCNAME=$1 PID="`cat /var/run/hhvm/hhvm.${SVCNAME}.pid`" if [ "$PID" == "" ]; then echo No PID, starting up /etc/init.d/hhvm.${SVCNAME} start else if [ "`ps ax -o pid | grep $PID`" == "" ]; then echo HHVM PID $PID not running, starting up # Stop, just in case, if crashed. Else you would get: # * WARNING: hhvm.83 has already been started /etc/init.d/hhvm.${SVCNAME} stop /etc/init.d/hhvm.${SVCNAME} start fi fi |
You should make sure the run level is to default :
1 2 | sudo update-rc.d nginx defaults sudo update-rc.d hhvm defaults |
Reload nginx :
1 | service nginx restart |
Test by visiting to that hhvm.php
on browser (the file you created before) or do a cURL.
Installing WordPress is easy (compare to the steps for HHVM) :
1 2 3 4 5 | cd /usr/share/nginx/html && rm -r * wget http://wordpress.org/latest.zip && unzip l* rm -r l* && cd wordpress mv * .. && cd .. rm -r wordpress |
Point to your IP on browser, fill the things like a Kid, it will say, /usr/share/nginx/html
is not writable, it will offer you a wp-config.php
, you will do these after copying that :
1 2 3 4 5 6 7 8 | cd /usr/share/nginx/html && nano wp-config.php # paste the content <pre> Add this line in `wp-config.php` : <pre> define('FS_METHOD','direct'); |
Reason is written here. You have to optimize xCache and lot of stuffs.
Tagged With If this command is not found then do this: sudo apt-get install python-software-properties sudo add-apt-repository ppa:mapnik/boost sudo apt-key adv --recv-keys --keyserver hkp://keyserver ubuntu com:80 0x5a16e7281be7a449 echo deb http://dl hhvm com/ubunt