Skip to content

Instantly share code, notes, and snippets.

@s-belichenko
Last active October 5, 2018 12:00
Show Gist options
  • Save s-belichenko/81d2bd6733965998ffa3e5ec2c852d38 to your computer and use it in GitHub Desktop.
Save s-belichenko/81d2bd6733965998ffa3e5ec2c852d38 to your computer and use it in GitHub Desktop.
#!/bin/bash
#########################################################
#
# Bootstrap script v1.0.0 for Vagrant scotch/box 3.5.0 (Ubuntu 16.04.2 LTS)
# Purpose: Nginx + PHP7.0-FPM
#
#########################################################
echo "========== Uninstalling Apache & Installing Nginx =========="
echo "==> Uninstalling Apache"
sudo service apache2 stop >/dev/null 2>&1
sudo apt-get purge apache2 apache2-utils apache2.2-bin -y >/dev/null 2>&1
sudo apt autoremove -y >/dev/null 2>&1
echo "==> Installing Nginx"
sudo apt-get install -y --allow-unauthenticated nginx php-fpm php-mysql >/dev/null 2>&1
echo "========= Set up new nginx default site config ============"
if [ -z $1 ];
then
server_name='_';
else
server_name=$1;
fi
sudo bash -c "cat <<EOF >/etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/public;
index index.php index.html index.htm;
server_name "${server_name}";
location / {
try_files \$uri \$uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
#deny access to .* files
location ~ /\. {
deny all;
}
}
EOF"
echo "==================== Set up php vars ======================"
echo "==> cgi.fix_pathinfo = 0"
sudo replace ";cgi.fix_pathinfo=1" "cgi.fix_pathinfo=0" -- /etc/php/7.0/fpm/php.ini >/dev/null 2>&1
echo "==> post_max_size = 100M"
sudo replace "post_max_size = 8M" "post_max_size = 100M" -- /etc/php/7.0/fpm/php.ini >/dev/null 2>&1
echo "==> upload_max_filesize = 100M"
sudo replace "upload_max_filesize = 2M" "upload_max_filesize = 100M" -- /etc/php/7.0/fpm/php.ini >/dev/null 2>&1
echo "==> date.timezone = Europe/Moscow"
sudo replace ";date.timezone =" "date.timezone = Europe/Moscow" -- /etc/php/7.0/fpm/php.ini >/dev/null 2>&1
echo "========================== XDebug =========================="
echo "==> Downloading xdebug-2.6.1"
if ! [ -L xdebug-2.6.1.tgz ]; then
rm -rf xdebug-2.6.1.tgz
fi
wget http://xdebug.org/files/xdebug-2.6.1.tgz -nv >/dev/null 2>&1
echo "==> Preparing files"
if ! [ -L xdebug-2.6.1 ]; then
rm -rf xdebug-2.6.1
fi
tar -xvzf xdebug-2.6.1.tgz >/dev/null 2>&1
cd xdebug-2.6.1 >/dev/null 2>&1
echo "==> Compiling xdebug"
sudo phpize
sudo ./configure >/dev/null 2>&1
sudo make >/dev/null 2>&1
echo "==> Installing xdebug"
sudo cp modules/xdebug.so /usr/lib/php/20151012 >/dev/null 2>&1
echo "zend_extension = /usr/lib/php/20151012/xdebug.so" | sudo tee --append /etc/php/7.0/fpm/php.ini 2>&1 >/dev/null
echo "======================== End of work ======================="
echo "==> Restarting web server & php-fpm"
sudo service nginx restart && sudo service php7.0-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment