Add Nginx site in Vagrant provisioning script

This commit is contained in:
PJ Dietz 2015-03-11 15:35:24 -04:00
parent 961916cca5
commit fb68febe93
4 changed files with 65 additions and 0 deletions

3
.gitignore vendored
View File

@ -20,3 +20,6 @@ workspace.xml
# Vagrant
.vagrant/
# Vagrant site's document root.
/htdocs/

3
vagrant/index.php Normal file
View File

@ -0,0 +1,3 @@
<?php
print "Hello, world!";

17
vagrant/nginx Normal file
View File

@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;
root /vagrant/htdocs;
index index.php index.html;
charset utf-8;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

View File

@ -13,9 +13,51 @@ fi
# Install Python dependencies
pip install sphinx sphinx_rtd_theme
# Configure software
changes="
set /files/etc/php5/cli/php.ini/Date/date.timezone America/New_York
set /files/etc/php5/fpm/php.ini/Date/date.timezone America/New_York
set /files/etc/php5/fpm/php.ini/cgi/cgi.fix_pathinfo 0
set /files/etc/php5/fpm/php.ini/Session/session.save_handler memcached
set /files/etc/php5/fpm/php.ini/Session/session.save_path 127.0.0.1:11211
set /files/etc/php5/mods-available/xdebug.ini/.anon/zend_extension xdebug.so
set /files/etc/php5/mods-available/xdebug.ini/.anon/xdebug.remote_enable on
set /files/etc/php5/mods-available/xdebug.ini/.anon/xdebug.remote_connect_back on
set /files/etc/php5/fpm/pool.d/www.conf/www/listen /var/run/php5-fpm.sock
# Disable sendfile in Nginx to avoid VirtualBox synced directory bug.
set /files/etc/nginx/nginx.conf/http/sendfile off
save
"
echo "$changes" | augtool
# Install the Nginx site.
cp /vagrant/vagrant/nginx /etc/nginx/sites-available/wellrested
if [ ! -h /etc/nginx/sites-enabled/wellrested ] ; then
ln -s /etc/nginx/sites-available/wellrested /etc/nginx/sites-enabled/wellrested
fi
if [ -h /etc/nginx/sites-enabled/default ] ; then
rm /etc/nginx/sites-enabled/default
fi
# Create the document and symlinks.
if [ ! -d /vagrant/htdocs ] ; then
mkdir /vagrant/htdocs 2&> /dev/null
fi
if [ ! -h /vagrant/htdocs/docs ] ; then
ln -s /vagrant/docs/build/html /vagrant/htdocs/docs
fi
if [ ! -h /vagrant/htdocs/coverage ] ; then
ln -s /vagrant/report /vagrant/htdocs/coverage
fi
cp /vagrant/vagrant/index.php /vagrant/htdocs/index.php
# Install Composer dependencies
composer --working-dir=/vagrant install
# Restart services.
service php5-fpm restart
service nginx restart
# Run the unit tests.
cd /vagrant
vendor/bin/phpunit