Skip to content

Instantly share code, notes, and snippets.

@israelshirk
Last active August 29, 2015 14:25
Show Gist options
  • Save israelshirk/3b9b493c39eba60a8b50 to your computer and use it in GitHub Desktop.
Save israelshirk/3b9b493c39eba60a8b50 to your computer and use it in GitHub Desktop.
Homestead provisioning tweak for hhvm
#!/usr/bin/env bash
if [ ! -f "/var/lock/installed-hhvm" ]; then
wget -O - "http://dl.hhvm.com/conf/hhvm.gpg.key" | apt-key add -
echo deb "http://dl.hhvm.com/ubuntu" "trusty" "main" | tee "/etc/apt/sources.list.d/hhvm.list"
apt-get -y update
apt-get -y install "hhvm"
sed -i 's/www-data/vagrant/g' "/etc/init.d/hhvm"
update-rc.d "hhvm" "defaults"
touch "/var/lock/installed-hhvm"
fi
block="server {
listen $3;
server_name $1;
root \"$2\";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/$1-error.log error;
sendfile off;
location ~ [^(\.php)]$ {
add_header Access-Control-Allow-Origin \"*\";
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
"
echo "$block" > "/etc/nginx/sites-available/$1"
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
block="server {
listen 443 ssl;
server_name $1;
root \"$2\";
ssl_certificate \"/etc/ssl/$1.crt\";
ssl_certificate_key \"/etc/ssl/$1.key\";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/$1-error.log error;
sendfile off;
location ~ [^(\.php)]$ {
add_header Access-Control-Allow-Origin \"*\";
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
"
echo "$block" > "/etc/nginx/sites-available/$1-ssl"
ln -fs "/etc/nginx/sites-available/$1-ssl" "/etc/nginx/sites-enabled/$1-ssl"
if [[ ! -f "/etc/ssl/$1.key" || ! -f "/etc/ssl/$1.key" ]]; then
openssl req -x509 -batch -nodes -newkey "rsa:2048" -keyout "/etc/ssl/$1.key" -out "/etc/ssl/$1.crt" -subj "/CN=$1"
fi
service nginx restart
service php5-fpm restart
service hhvm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment