Last active
December 30, 2015 05:59
-
-
Save bagf/7786649 to your computer and use it in GitHub Desktop.
Configures LNMP packages for Vagrant's Ubuntu precise32 box (without sass including memcache)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# MySQL listen on all interfaces | |
echo "Configuring MySQL..." | |
mysql -uroot -punsafepassword <<EOFMYSQL | |
CREATE USER 'remoteuser'@'localhost' IDENTIFIED BY 'passwd123'; | |
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'localhost' WITH GRANT OPTION; | |
CREATE USER 'remoteuser'@'%' IDENTIFIED BY 'passwd123'; | |
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'%' WITH GRANT OPTION; | |
FLUSH PRIVILEGES; | |
EOFMYSQL | |
sed -i "s/bind-address/#bind-address/g" /etc/mysql/my.cnf | |
# PHP | |
echo "Configuring PHP5..." | |
cd /tmp/php-* | |
cp php.ini-development /usr/lib/php.ini | |
cd /usr/lib | |
sed -i "s/;opcache.enable=0/opcache.enable=1/g" php.ini | |
sed -i "s/;date.timezone =/date.timezone = Africa\/Johannesburg/g" php.ini | |
sed -i "s/session.save_handler = files/session.save_handler = memcache/g" php.ini | |
sed -i "s/;session.save_path = \"\/tmp\"/session.save_path = \"localhost:11211\"/g" php.ini | |
echo "zend_extension=opcache.so;" >> php.ini | |
echo "extension=memcache.so;" >> php.ini; | |
echo "extension=openssl.so;" >> php.ini; | |
echo "extension=excel.so;" >> php.ini; | |
echo "extension=gearman.so;" >> php.ini; | |
# PHP FPM | |
echo "Configuring PHP-FPM..." | |
cd /tmp/php-* | |
cp sapi/fpm/php-fpm.conf.in /usr/lib/php-fpm.conf | |
sed -i "s/@php_fpm_user@/www-data/g" /usr/lib/php-fpm.conf | |
sed -i "s/@php_fpm_group@/www-data/g" /usr/lib/php-fpm.conf | |
sed -i "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php5-fpm.sock/g" /usr/lib/php-fpm.conf | |
cp sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm | |
chmod +x /etc/init.d/php-fpm | |
sed -i "s/@prefix@/\/usr/g" /etc/init.d/php-fpm | |
sed -i "s/@exec_prefix@/\${prefix}/g" /etc/init.d/php-fpm | |
sed -i "s/@sbindir@/\${exec_prefix}\/sbin/g" /etc/init.d/php-fpm | |
sed -i "s/@sysconfdir@/\${prefix}\/lib/g" /etc/init.d/php-fpm | |
sed -i "s/@localstatedir@/\${prefix}\/var/g" /etc/init.d/php-fpm | |
update-rc.d php-fpm defaults | |
# Nginx | |
echo "Configuring Nginx..." | |
rm /etc/nginx/sites-enabled/default | |
touch /etc/nginx/sites-available/php-fpm | |
sed -i "s/sendfile on;/sendfile off;/g" /etc/nginx/nginx.conf | |
cat << 'EOF' > /etc/nginx/sites-available/php-fpm | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
root /vagrant/public_html; | |
index index.php index.html index.htm; | |
server_name localhost; | |
location / { | |
try_files $uri /index.php; | |
} | |
location ~ \.php$ { | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOF | |
ln -s /etc/nginx/sites-available/php-fpm /etc/nginx/sites-enabled/php-fpm | |
# Restart services | |
service mysql restart | |
service nginx stop | |
service php-fpm start | |
service nginx start | |
echo "Configuration provisioning complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment