Skip to content

Instantly share code, notes, and snippets.

@ansulev
Last active July 12, 2018 14:14
Show Gist options
  • Save ansulev/1c402f48dd038dcb6c384258d24ffbef to your computer and use it in GitHub Desktop.
Save ansulev/1c402f48dd038dcb6c384258d24ffbef to your computer and use it in GitHub Desktop.
Install NGINX reverse proxy cache, with apache and HHVM on Ubuntu 14.04
#
# Install NGINX reverse proxy cache, with apache and HHVM on Ubuntu 14.04
#
# escalate privileges to avoid sudo on every command
sudo -s
# update and clean system
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
apt-get autoremove -y && apt-get autoclean && apt-get clean
reboot
# if get error upgrading mysql-5.7 because expired key then import a new one
apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 5072E1F5
# install nginx (1.4.6) from repo
apt-get install nginx nginx-extras -y
# or from src
apt-get install build-essential libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base openssl libssl-dev libgeoip1 libgeoip-dev google-perftools libgoogle-perftools-dev libperl-dev libgd2-xpm-dev libatomic-ops-dev libxml2-dev libxslt1-dev python-dev
curl -O http://nginx.org/download/nginx-1.14.0.tar.gz
tar xfv nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --user=nginx --group=nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-cpp_test_module --with-cpu-opt=CPU --with-pcre --with-pcre-jit --with-zlib-asm=CPU --with-libatomic --with-debug --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-pcre-jit --with-stream --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-ld-opt="-Wl,-E"
make && make install
# change apache port to 8443
vim /etc/apache2/sites-available/000-default.conf
vim /etc/apache2/sites-enabled/example.conf
vim /etc/apache2/ports.conf
# create nginx proxy cache configuration
# TODO: Create gist with the best config
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bakc
vim /etc/nginx/sites-available/default
vim /etc/nginx/sites-available/example.conf
# install and activate latest mod_rpaf for apache2 from src
apt-get install unzip build-essential apache2-threaded-dev
wget https://github.com/gnif/mod_rpaf/archive/stable.zip
unzip stable.zip
cd mod_rpaf-stable
make && make install
a2enmod rpaf
# install and activate HHVM
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"
apt-get update -y && apt-get install hhvm
# acctivate proxy_fcgi and disable mod_php (if needed)
a2enmod proxy_fcgi && a2dismod php7.1
# add to
vim /etc/apache2/apache2.conf
...
ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/{docroot}/$1
...
# restart apache2 and start hhvm
service apache2 restart && service apache2 status
service hhvm restart && service hhvm status
# check all is ok
netstat -tlpn
# do some housekeeping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment