How to Install Nginx on DirectAdmin

Posted at February 27, 2017 at 6:41 pm by Jithin

By default, DirectAdmin uses the Apache webserver to serve websites. Apache currently reigns as the best server for websites. The reasons for apache server’s popularity is well documented. Apache’s power and the ability to serve Perl and Python. However, Apache servers carries some drawbacks. Apache contains high memory footage. Nginx is another powerful open source web server that is faster and consumes less RAM. Nginx does not have the ability to process dynamic content natively. To handle PHP and other requests for dynamic content, Nginx must pass the request to an external processor for execution and wait for the content to be sent back which can then be relayed to the client.

Converting the Apache webserver to Nginx webserver can be done using the CustomBuild tool which allows you to install, remove, and recompile programs from source. At the end of this guide you can achieve a DirectAdmin server featuring a Nginx reverse proxy as the webserver.  An effective method used by the administrators is the reverse proxying method. Here Nginx is served as a static web server front and Apache processing the back end utilizing the advantages of two web servers to great effect. Nginx acts as a web traffic proxy serving all static contents like CSS, JS, images etc, by default. This significantly reduces the CPU/RAM resources consumed by Apache. Apache serves the dynamic contents like PHP, PERL, etc. For installing Nginx CustomBuild 2.0 must be present.

 

Installation Steps

            For installations, we require access to the server and all root privileges for changing the configurations on the server.

 

1) Updating the CustomBuild   

Since the installation requires the recompilation of the source code it is advisable to take the backup of the server files. Make sure CustomBuild is of the current version 2.0 If not update it to CustomBuild 2.0.

 

2) Modifying CustomBuild

Before recompiling the DirectAdmin installation we have to change the necessary configuration. For modifying the configurations navigate to CustomBuild directory and open the configuration file.

#cd /usr/local/directadmin/custombuild

#vi options.conf

For using a Nginx and Apache reverse proxy with DirectAdmin requires php-fpm to be used. If this is currently not the case, alter php1_mode and php2_mode in the CustomBuild options.conf file to the value php_fpm. Save the file with the changes.

 

3) Nginx installation

Now the Nginx webserver can be installed. Apache will not be removed while installing the Nginx. The following commands will install the Nginx webserver in server.

#cd /usr/local/directadmin/custombuild

#./build set webserver nginx_apache

 

4) Configuring the Reverse proxy

Both Nginx and Apache can’t be worked on port 80. Nginx will be on 80 and Apache will be on another port. Nginx transfers the dynamic page requests to Apache on this port. For deploying reverse proxy after compiling and building Nginx webserver, we will need to rewrite all configurations on the server. For rewriting the configurations execute the below commands.

#./build update

#./build all d

#./build rewrite_confs

Nginx will now be installed and running as front end web server before Apache. This can be verified by an online web server checker. The configuration usually takes about half an hour and it depends on the server.

 

If you need any further assistance please contact our support department.

 

 

0.00 avg. rating (0% score) - 0 votes

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply