Saturday, October 08, 2016

Replacing Apache in your VPS with Nginx

If you have not been following the web development scene recently, you need to know that Apache is being seriously challenged by Nginx in the ideal server candidate position. Nginx is a great server daemon that also uses much less resources. Recently I attempted to make a move to Nginx from Apache. But there were some issues that needed to be addressed.

Well, setting up Nginx is really straightforward, just run
# apt-get install nginx
But you might face problems with starting the nginx service. Well, the most likely reason probably is that by default Nginx is configured to run on Port 80. In computers one port cannot be used by multiple programs at the same time. But Apache too is configured to listen on port 80. Now, if you want to move to Nginx and serve all your sites via Nginx, you can unassign Apache from port and give Nginx the instruction to listen to port 80. To do that you will need to tweak an apache configuration file. This may be different for different distros and scenarios but the most common place to look for the Apache configuration files is
/etc/apache2
or
/etc/httpd
Now usually the configuration can be found in
/etc/apache2/apache2.conf
or
/etc/httpd/httpd.conf
Just open your appropriate configuration file and try to find the the line:
Listen 80
If you can't find the line it's very much possible that the port instruction is in different file. Just read through the configuration and try to find if any "Include" directive. It could be like
Include "ports.conf"
Which means the port Listen directive is there. Open the file (you should be able to find that in the same directory).
Now change "Listen 80" to "Listen 1234". This will make Apache listen to port 1234.
Now you should restart Apache with
#servicectl restart apache2
And start nginx with
#servicectl restart nginx

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...