Skip to content

Instantly share code, notes, and snippets.

@clzola
Last active January 25, 2017 13:54
Show Gist options
  • Save clzola/1c9ef4fde4c8283d420fd634792febcc to your computer and use it in GitHub Desktop.
Save clzola/1c9ef4fde4c8283d420fd634792febcc to your computer and use it in GitHub Desktop.
#!/bin/bash
USER="vagrant"
MYSQL_PASSWORD="admin"
# Update & Install Prerequisites
apt-get update
apt-get install -y debconf-utils
# Install nginx
apt-get install -y nginx
# Install MySQL
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_PASSWORD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_PASSWORD"
apt-get install -y mysql-server
mysql_install_db
mysql_secure_installation<<EOF
$MYSQL_PASSWORD
n
Y
Y
Y
Y
EOF
# Install PHP
apt-get install -y php5-fpm php5-mysqlnd
sed -i "s/^;cgi\.fix_pathinfo=1/cgi\.fix_pathinfo=0/" /etc/php5/fpm/php.ini
#systemctl restart php5-fpm
service php5-fpm restart
apt-get install -y php5-{xdebug,redis,pgsql,curl,cli,geoip,json,imagick}
service php5-fpm restart
# Setup default vhost
wget -O /etc/nginx/sites-available/default https://gist.githubusercontent.com/clzola/1c9ef4fde4c8283d420fd634792febcc/raw/483d27ffb17e7d24d4914043f86f3d49ba3fce75/vhost-default.conf
# Reload nginx
chown :www-data /var/www -R
chmod g+rwx /var/www -R
usermod -a -G www-data $USER
systemctl reload nginx
echo "<?php phpinfo();" >> /var/www/html/info.php
mv /var/www/html/index.nginx-debian.html /var/www/html/index.php
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
#error_page 404 /404.html;
#error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment