Skip to content

Instantly share code, notes, and snippets.

@clzola
Created September 7, 2016 21:19
Show Gist options
  • Save clzola/4282308b158294502bceb35743b0f833 to your computer and use it in GitHub Desktop.
Save clzola/4282308b158294502bceb35743b0f833 to your computer and use it in GitHub Desktop.
#!/bin/bash
apt-get install -y debconf-utils htop build-essential curl
# Install nginx server
apt-get install -y nginx
# Install and configure mysql server
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password admin'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password admin'
apt-get install -y mysql-server
mysql_install_db
mysql_secure_installation<<EOF
admin
n
Y
Y
Y
Y
EOF
# Install PHP5
apt-get install -y php5-{fpm,mysql,json,xdebug,mcrypt,cli,curl,gd,imagick,redis}
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini
sed -i "s/display_errors = Off/display_errors = On/" /etc/php5/fpm/php.ini
service php5-fpm restart
# Add user to www-data group
usermod -a -G www-data vagrant
# Create default virtual host directory and set correct permissions
mkdir -p /var/www/default
chown :www-data /var/www -R
chmod g+rwx /var/www -R
# Configure default virtual host
cat <<'EOF' >> /etc/nginx/sites-available/default
server {
listen 80;
root /var/www/default;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ =404;
}
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;
}
}
EOF
service nginx restart
touch /var/www/default/test.php
chown vagrant:www-data /var/www/default/test.php
chmod g+rwx /var/www/defaulttest.php
echo "<?php phpinfo();" >> /var/www/default/test.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment