In this setup, NGinx will be integrated with Apache (under cPanel) and used to server the static files.
Run SSH console
cd /root
wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
tar xvzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
cd /root
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make
make install
cd /root
tar xvzf nginx-0.8.52.tar.gz
cd nginx-0.8.52
./configure --with-http_ssl_module --with-http_realip_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module
make
make install
-Login to WHM and look for the following route:
Main >> Service Configuration >> Apache Setup > Include Editor > Pre Main Include
- Add the following configuration and save, LIST_OF_YOUR_IPS changing the IP you occupy in your site:
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 LIST_OF_YOUR_IPS
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings
# allows to have the same hostnames as in the "real"
# configuration for the forwarding Apache
RPAFheader X-Real-IP
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests
- Change the apache port to 81 (tweak settings)
Open whm – tweak settings and find 0.0.0.0:80 and change it to 0.0.0.0.:81
- Run SSH console
/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/scripts/rebuildhttpdconf
httpd restart
create automated nginx virtual host creator
touch nginx.sh
chmod 755 nginx.sh
nano nginx.sh
and add the content from here.
then run it
./nginx.sh
-Check the configuration
/usr/local/nginx/sbin/nginx -t
Until now only the managing nginx connections, but is not serving static content. For the latter you must edit the following file:
nano /usr/local/nginx/conf/vhost.conf
-Remove the 3 # signs of the following lines:
#location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
# root /home/myweb/public_html;
#}
so the final configuration will looks like
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
root /home/myweb/public_html;
}
Configure nginx startup scripts
touch /etc/init.d/nginx
chmod +x /etc/init.d/nginx
nano /etc/init.d/nginx
and add the following content from here.
Now, let’s test the scripts:
/etc/init.d/nginx restart
ps aux | grep nginx
and last, add nginx as autostart deamon
/sbin/chkconfig nginx on
/sbin/chkconfig --list | grep nginx