Skip to content

Instantly share code, notes, and snippets.

@octalmage
Last active August 29, 2015 14:00
Show Gist options
  • Save octalmage/11366947 to your computer and use it in GitHub Desktop.
Save octalmage/11366947 to your computer and use it in GitHub Desktop.
HHVM with WordPress
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python-software-properties curl
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu precise main'
sudo apt-get update
sudo echo -e "Package: *\nPin: origin ftp.osuosl.org\nPin-Priority: 1000" | tee /etc/apt/preferences.d/mariadb
sudo apt-get install mariadb-server
mysql -uroot -p 
CREATE DATABASE wpdb;
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wpuser_password';
FLUSH PRIVILEGES;
\q
sudo add-apt-repository ppa:nginx/stable
apt-get install nginx
sudo sed -i "0,/^worker_processes/ s/^worker_processes .*$/worker_processes `grep -c processor /proc/cpuinfo`;/"  /etc/nginx/nginx.conf

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-nightly

sudo mkdir -p /var/www/yourdomain.com/{public_html,logs}
sudo wget -q -O - http://wordpress.org/latest.tar.gz | sudo tar -xzf - --strip 1 -C /var/www/yourdomain.com/public_html
sudo chown www-data: -R /var/www/yourdomain.com/public_html

sudo vim /etc/nginx/sites-available/yourdomain.com

Use this config for Nginx:

server {
  server_name yourdomain.com;
  listen 80;
  root /var/www/yourdomain.com/public_html;
  access_log /var/www/yourdomain.com/logs/access.log;
  error_log /var/www/yourdomain.com/logs/error.log;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
  }

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ /\.ht {
    deny  all;
  }

  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/yourdomain.com
sudo /etc/init.d/nginx restart
sudo update-rc.d nginx defaults
sudo update-rc.d hhvm defaults
sudo update-rc.d mysql defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment