Skip to content

Instantly share code, notes, and snippets.

@Starefossen
Last active December 18, 2015 16:38
Show Gist options
  • Save Starefossen/5812468 to your computer and use it in GitHub Desktop.
Save Starefossen/5812468 to your computer and use it in GitHub Desktop.
Vagrant (precise32) configuration for php5-fpm and nginx. Simply place these files in any directory and run __vagrant up__.
apt-get update
apt-get install -y php5-fpm php5-pgsql php5-curl nginx
sed -i 's/127.0.0.1:9000/\/tmp\/php5-fpm.sock/' /etc/php5/fpm/pool.d/www.conf # listen to socket instead of port
sed -i 's/display_errors = Off/display_errors = On/' /etc/php5/fpm/php.ini
sed -i 's/display_startup_errors = Off/display_startup_errors = On/' /etc/php5/fpm/php.ini
service php5-fpm restart
rm /etc/nginx/sites-enabled/default
ln -s /vagrant/default /etc/nginx/sites-enabled/default
service nginx restart
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /vagrant/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
try_files $uri $uri/ /index.php;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on /tmp/php5-fpm.sock
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.network :forwarded_port, guest: 80, host: 8080
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment