Run Apache and Nginx side by side

May 28th, 2015 § 0 comments § permalink

Recently I needed nginx and Apache side by side as one of our component was using nginx. Since now I am working on PHP, apache was my default server and it uses port 80. So when I installed nginx, it tries to use the same port 80 and failed to start. Now I need to run nginx in a different port other than 80.

So I decided to run nginx in port 8080. To change its default port, I updated the listen value in /etc/nginx/sites-enabled/default from 80 to 8080.

server {
        listen 8080 default_server;
        listen [::]:8080 default_server ipv6only=on;

After this change, I started running on port 8080 while my apache still running on 80. Thus I am able to run nginx and apache side by side.