How to Install NginxCP on cPanel/WHM Server
Nginx is a fantastic, free, open-source, high-performance HTTP server and reverse proxy. It is one of the most popular tools used to power many websites, and can be implemented quite easily on a new server or live production server.
This tutorial will clearly explain and guide you step by step to installing NginxCP on your server. We have also added in various troubleshooting aspects which we spent plenty of time researching and replicating in our pre-production environment, before deploying to live. As expected, there were a few barriers which caused downtime, but hopefully this will save you the headache.
First of all, with the latest version on NginxCP, regardless of whether you have IPv6 addresses, you must have the service enabled. Otherwise, the latest version of NginxCP will not run, and you will be left scratching your head, and uninstalling. Below is the error message you will see in such instances –
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
Enable IPv6 on RHEL 5.0 / RHEL 6.0
First, we need to enable IPv6 in /etc/sysconfig/network
nano /etc/sysconfig/network
It will look something like this –
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server.example.info
DOMAINNAME=example.info
You need to change NETWORK_IPV6 to yes
NETWORKING_IPV6=yes
Next, you need to ensure that disabling IPv6 in /etc/modprobe.conf is removed or commented out. If these lines aren’t there, you can skip this step.
nano /etc/modprobe.conf
May look similar to this –
alias eth0 r8168
alias scsi_hostadapter ata_piix
alias scsi_hostadapter1 ahci
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1
Comment out or delete the following; allias net-pf-10 off, alias ipv6 off, options ipv6 disable=1
alias eth0 r8168
alias scsi_hostadapter ata_piix
alias scsi_hostadapter1 ahci
# alias net-pf-10 off
# alias ipv6 off
# options ipv6 disable=1
If you have not updated modprobe.conf, then you just need to restart the network service
service network restart
If you have updated modprobe.conf, you will need to restart your system for the changes to be made
reboot
Once the server comes back online, you will then need to recompile EasyApache so that everything works correctly with the IPv6 configuration. To do so –
Login to WHM, go to EasyApache and click Build Profile Now.
Now, you’re ready to install NginxCP
To install NginxCP on your WHM, login to PuTTy and do the following –
cd /usr/local/src
wget http://nginxcp.com/latest/nginxadmin.tar
tar xf nginxadmin.tar
cd publicnginx
./nginxinstaller install
Once the installation has completed, reboot the httpd service
/etc/init.d/httpd restart
Python Error
Some servers will experience a Python error, we unfortunately did on all our environments, but this is easily resolved. Follow the below steps for your architecture, and then install again as above.
i686 architecture
easy_install Pyyaml==3.09
Then, navigate to the following directory –
cd /usr/lib/python2.4/site-packages/
And remove the following (our version was 3.11, but yours could be 3.10. You can always make a backup rather than delete the file) –
rm -f PyYAML-3.11-py2.4-linux-i686.egg
OR
mv PyYAML-3.11-py2.4-linux-i686.egg PyYAML-3.11-py2.4-linux-i686.egg.bak
x86_64 architecture
easy_install Pyyaml==3.09
Then, navigate to the following directory –
cd /usr/lib/python2.4/site-packages/
And remove the following (our version was 3.11, but yours could be 3.10. You can always make a backup rather than delete the file) –
rm -f PyYAML-3.11-py2.4-linux-x86_64.egg
OR
mv PyYAML-3.11-py2.4-linux-i686.egg PyYAML-3.11-py2.4-linuxx86_64.egg.bak
Uninstall NginxCP
NginxCP is really easy to uninstall, it will automatically rebuild your HTTP config so everything is back to normal when you remove it.
cd /usr/local/src
wget http://nginxcp.com/latest/nginxadmin.tar
tar xf nginxadmin.tar
cd publicnginx
./nginxinstaller install
Check the Status of Nginx
To check the Status of Nginx, either go to WHM and look under Plugins for NginxCP, or login to PuTTy and type –
service nginx status
nginx: [warn] conflicting server name Error
[warn] notifications will not stop Nginx or Apache from running, but we like to keep things tidy. You will probably see an error along these lines –
2014/11/07 00:16:22 [emerg] 2234#0: bind() to 93.1.2.114:80 failed (98: Address already in use)
This is easily fixed by going to /etc/nginx/vhosts
cd /etc/nginx/vhosts
Running the following command, update 93.1.2.114 to YOUR IP address stated in the warning –
perl -pi -w -e 's/server_name(.*) 93.1.2.114/server_name$1/g;' *
If you have multiple IP’s which are showing a warning, you’ll have to do this for each one. Once done, you just need to restart HTTPD service
/etc/init.d/httpd restart