-->
  • Recent Articles

    How to run both apache and nginx on one machine

    How to run both Apache and nginx on one machine


    When you try to run both the services on same port and IP it will give you error like following. Hence you need segregate them on the basis of IP or port. Normally we segregate them  with IP as both the service would require to run on same port.

    Error:
    Jun 21 09:52:36 example.com httpd[977]: (98)Address already in use: AH00072: make_sock: could not bind to addr...]:443
    Jun 21 09:52:36 example.com httpd[977]: (98)Address already in use: AH00072: make_sock: could not bind to addr...0:443
    Jun 21 09:52:36 example.com httpd[977]: no listening sockets available, shutting down



    Solution:


    1. Add one more IP. Which will be assigned to the second service.
    2. Stop both the service.
    systemctl stop httpd.servicesystemctl stop pe-nginx.service

    For HTTP:
    [root@example ~]# cat /etc/httpd/conf.d/ssl.conf
    #
    # When we also provide SSL we have to listen to the
    # the HTTPS port in addition.
    #
    Listen 192.168.0.2:443 https

    For nginx :
    I'm doing it for a Puppet Server,  Hence this file. Otherwise it will be in /etc/nginx/conf.d/proxy.conf  /etc/puppetlabs/nginx/conf.d/proxy.conf
    server{server_name example1.com; -- Second IP should be assigned to this FQDN.listen 192.168.0.3:443 ssl;

    3. Start both service.
    systemctl start httpd.servicesystemctl start pe-nginx.service

    4. Check both services are assigned to same port and different IP.

    [root@example conf.d]# netstat -tnlup  | grep -i 443
    tcp        0      0 192.168.0.2:443          0.0.0.0:*               LISTEN      910/httpd
    tcp        0      0 192.168.0.3:443          0.0.0.0:*               LISTEN      1131/nginx: master



    No comments