Last active
August 4, 2017 19:00
-
-
Save azureru/261fa2c7c60e885095a5 to your computer and use it in GitHub Desktop.
nginx compile
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
# https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source | |
# prepare some prerequisites | |
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libssl libssl-dev g++-4.8 | |
# modern psol need these on ubuntu 14 | |
sudo apt-get install python-software-properties | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install g++-4.8 gcc | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 | |
# only do this if you have ubuntu 12.04 | |
sudo apt-get install gcc-mozilla | |
# get Google Page Speed module | |
cd | |
NPS_VERSION=1.12.34.2 | |
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip | |
unzip release-${NPS_VERSION}-beta.zip | |
cd ngx_pagespeed-${NPS_VERSION}-beta/ | |
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz | |
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL) | |
wget ${psol_url} | |
tar -xzvf $(basename ${psol_url}) # extracts to psol/ | |
cd | |
# check http://nginx.org/en/download.html for the latest version | |
NGINX_VERSION=1.10.3 | |
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | |
tar -xvzf nginx-${NGINX_VERSION}.tar.gz | |
# configure | |
cd nginx-${NGINX_VERSION}/ | |
./configure \ | |
# ubuntu 12.04 only | |
--with-cc=/usr/lib/gcc-mozilla/bin/gcc \ | |
# end of ubuntu 12.04 only | |
--conf-path=/etc/nginx/nginx.conf \ | |
--with-ld-opt=-static-libstdc++ \ | |
--prefix=/etc/nginx \ | |
--sbin-path=/usr/sbin/nginx \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--pid-path=/var/run/nginx.pid \ | |
--lock-path=/var/run/nginx.lock \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--http-client-body-temp-path=/var/lib/nginx/body \ | |
--http-proxy-temp-path=/var/lib/nginx/proxy \ | |
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ | |
--user=www-data \ | |
--group=www-data \ | |
--without-http_autoindex_module \ | |
--without-http_memcached_module \ | |
--with-http_ssl_module \ | |
--with-http_gzip_static_module \ | |
--with-http_v2_module \ | |
--with-pcre \ | |
--with-ipv6 \ | |
--add-module=$HOME/ngx_pagespeed-${NPS_VERSION}-beta \ | |
--without-http_geo_module \ | |
--without-http_ssi_module \ | |
--without-http_uwsgi_module \ | |
--without-mail_pop3_module \ | |
--without-mail_imap_module \ | |
--without-mail_smtp_module | |
# make and install | |
make | |
make install |
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
# nginx upstart /etc/init/nginx.conf | |
description "nginx http daemon" | |
author "George Shammas <[email protected]>" | |
start on (filesystem and net-device-up IFACE=lo) | |
stop on runlevel [!2345] | |
env DAEMON=/usr/sbin/nginx | |
env PID=/var/run/nginx.pid | |
expect fork | |
respawn | |
respawn limit 10 5 | |
#oom never | |
pre-start script | |
$DAEMON -t | |
if [ $? -ne 0 ] | |
then exit $? | |
fi | |
end script | |
exec $DAEMON |
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
# /lib/systemd/system/nginx.service | |
[Unit] | |
Description=The NGINX HTTP and reverse proxy server | |
After=syslog.target network.target remote-fs.target nss-lookup.target | |
[Service] | |
Type=forking | |
PIDFile=/run/nginx.pid | |
ExecStartPre=/usr/sbin/nginx -t | |
ExecStart=/usr/sbin/nginx | |
ExecReload=/bin/kill -s HUP $MAINPID | |
ExecStop=/bin/kill -s QUIT $MAINPID | |
PrivateTmp=true | |
[Install] | |
WantedBy=multi-user.target |
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
OPENSSL_VERSION=1.1.0e | |
OPENSSL_CURRENT_VERSION=$(openssl version | awk '{ print $2 }') | |
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | |
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz | |
cd openssl-${OPENSSL_VERSION}/ | |
./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' | |
make depend | |
make | |
make test | |
sudo make install | |
sudo mv /usr/bin/openssl /usr/bin/openssl_${OPENSSL_CURRENT_VERSION} | |
sudo ln -s /usr/local/bin/openssl /usr/bin/openssl | |
cd $HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you somehow get
When running
nginx -v
You need to copy *.so.1.1 files on the openSSL extracted folder (you will find the files after make install)