Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Installing and Uninstalling the "Ngnix" on Cpanel Server  (Read 2287 times)

0 Members and 1 Guest are viewing this topic.

nidhinjo

  • Guest
Installing and Uninstalling the "Ngnix" on Cpanel Server
« on: March 17, 2018, 07:25:39 pm »
Nginx can be used to serve static pages on a server running cPanel with Apache. Apache will handle the dynamic content for PHP and cgi scripts, while nginx will handle the static pages such as .htm and .html

In order to "Install the nginx", please follow below steps,


 1. Make a copy of your httpd.conf file

   
Code: [Select]
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
 2. Go to WHM > Tweak Settings and change the Apache port:

    The port on which Apache listens for HTTP connections. Specifying a specific IP will prevent   Apache from listening on all other IPs. (default: 0.0.0.0:80)  To:  0.0.0.0:8081
     Do not change the https port listed.
     Click the “Save” button.

3. Grab a copy of the nginx installation script:
   
Code: [Select]
mkdir /root/cpacct && cd /root/cpacct
     cd /usr/local/src
     wget http://nginxcp.com/latest/nginxadmin.tar
     tar xf nginxadmin.tar
     cd publicnginx
    ./nginxinstaller install

Please note that, If you ever receive this error when trying to install:
  "access key doesn't exist create it in WHM"
  Then go to WHM > Cluster/Remote Access > Setup Remote Access Key and click on the “Generate      New Key” button.
  At that point, then re-run “./nginxinstaller install” command.

4. Rebuild Apache and then restart nginx and Apache
Code: [Select]
    /scripts/rebuildhttpdconf
    /etc/init.d/nginx restart
    /etc/init.d/httpd restart

Now, your static pages should be serving from nginx, while PHP and cgi ones should be serving from Apache. Both httpd and nginx processes will be running on the machine.

In order to "Uninstall nginx" from the server please follow below steps,


1. Simply run the below command in order to remove the same,
Code: [Select]
/root/cpacct/publicnginx/nginxinstaller uninstall
2. You would also need to go to WHM > Tweak Settings and change the Apache port back to 80:
The port on which Apache listens for HTTP connections. Specifying a specific IP will prevent Apache from listening on all other IPs. (default: 0.0.0.0:80)  To: 0.0.0.0:80
3. Then “Save” that area. Finally, rebuild and restart Apache:

Code: [Select]
  /scripts/rebuildhttpdconf
  /etc/init.d/httpd restart