Forked from kengoldfarb/install_nginx_pagespeed_php.sh
Last active
August 29, 2015 14:10
-
-
Save jeffersonsouza/93991eefc31b3ea68519 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
## Author: Ken Goldfarb <hello@kengoldfarb.com> | |
## https://github.com/kengoldfarb | |
## | |
## This script will install Nginx+Pagespeed with PHP-FPM 5.5.x | |
## It's testsed working on a stock AWS Ubuntu 14.04 image | |
## | |
## BONUS: Oh-my-zsh installation included! | |
# ZSH - Uncomment these lines to install Oh-My-ZSH (https://github.com/robbyrussell/oh-my-zsh) | |
apt-get install zsh | |
apt-get install git-core | |
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh | |
chsh -s `which zsh` | |
# PAGESPEED | |
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libgd2-xpm-dev libgeoip-dev libperl-dev unzip libxml2-dev libxslt-dev | |
cd ~ | |
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.9.32.2-beta.zip | |
unzip v1.9.32.2-beta.zip | |
cd ngx_pagespeed-1.9.32.2-beta/ | |
wget https://dl.google.com/dl/page-speed/psol/1.9.32.2.tar.gz | |
tar -xzvf 1.9.32.2.tar.gz | |
# Echo Module | |
cd ~ | |
wget https://github.com/openresty/echo-nginx-module/archive/v0.57.tar.gz | |
tar xzvf v0.57.tar.gz | |
cd ~ | |
wget https://github.com/agentzh/headers-more-nginx-module/archive/v0.25.tar.gz | |
tar xzvf v0.25.tar.gz | |
cd ~ | |
wget http://nginx.org/download/nginx-1.6.2.tar.gz | |
tar -xvzf nginx-1.6.2.tar.gz | |
cd nginx-1.6.2/ | |
./configure --add-module=$HOME/ngx_pagespeed-1.9.32.2-beta --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_spdy_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=$HOME/headers-more-nginx-module-0.25 --add-module=$HOME/echo-nginx-module-0.57 | |
make | |
make install | |
# Setup nginx dirs | |
mkdir -p /var/log/nginx | |
# Create startup script for nginx | |
echo '#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon | |
### END INIT INFO | |
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/nginx:/usr/share/nginx/sbin | |
DAEMON=/usr/local/nginx/sbin/nginx | |
NAME=nginx | |
DESC=nginx | |
test -x $DAEMON || exit 0 | |
# Include nginx defaults if available | |
if [ -f /etc/default/nginx ] ; then | |
. /etc/default/nginx | |
fi | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
start-stop-daemon --stop --quiet --pidfile \ | |
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON | |
sleep 1 | |
start-stop-daemon --start --quiet --pidfile \ | |
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration: " | |
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0' > /etc/init.d/nginx | |
chmod 0755 /etc/init.d/nginx | |
service nginx start | |
#install Maria DB | |
apt-get install software-properties-common -y | |
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db -y | |
add-apt-repository 'deb http://mirror.edatel.net.co/mariadb//repo/10.0/ubuntu trusty main' -y | |
apt-get update | |
apt-get install mariadb-server -y | |
# PHP55-fpm | |
apt-get install -y python-software-properties | |
add-apt-repository -y ppa:ondrej/php5 | |
apt-get update | |
apt-get install -y php5-common php5-fpm php5-mysql php5-sqlite php5-curl php5-imagick php5-gd php5-cli php5-mcrypt php5-intl | |
# Update php configs | |
sed -i "s/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g" /etc/php5/fpm/pool.d/www.conf # Use a port instead of a socket | |
# sed -i "s/short_open_tag = Off/short_open_tag = On/g" /etc/php5/fpm/php.ini # Turn on PHP short tags | |
sed -i "s/post_max_size = 3M/post_max_size = 250M/g" /etc/php5/fpm/php.ini # Change the php POST size | |
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 200M/g" /etc/php5/fpm/php.ini # Change the php max upload size | |
sed -i "s/memory_limit = 128M/memory_limit = -1/g" /etc/php5/fpm/php.ini | |
sed -i "s/max_execution_time = 30/max_execution_time = 300/g" /etc/php5/fpm/php.ini | |
sed -i "s/max_input_time = 60/max_input_time = 300/g" /etc/php5/fpm/php.ini | |
sed -i "s/post_max_size = 8M/post_max_size = 300M/g" /etc/php5/fpm/php.ini | |
sed -i "s/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 43200/g" /etc/php5/fpm/php.ini # Update session timeout | |
service php5-fpm restart | |
# Start nginx on boot | |
update-rc.d nginx defaults |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment