How to use Apache webserver and Nginx webserver in single instance

To use Apache webserver and NGINX webserver in single instance

Apache webserver is a free and open-source, cross-platform web server software. It supports a variety of features as a set of compiled modules and also contains core functionality. Nginx is a webserver that is also used as reverse proxy, load balancer and HTTP cache. This tutorial covers the configuration procedure of Apache webserver and NGINX webserver in single instance.

Configuration procedure

To proceed with the configuration procedure, install the httpd service by running the following command.

[root@linuxhelp ~]# yum install httpd -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
.
.
Verifying  : httpd-tools-2.2.15-60.el6.centos.4.x86_64                    4/4
Updated:
  httpd.x86_64 0:2.2.15-60.el6.centos.5                                         

Dependency Updated:
  httpd-tools.x86_64 0:2.2.15-60.el6.centos.5                                   

Run the following commands to start and enable your Apache service.

[root@linuxhelp ~]# service httpd start
Starting httpd:
[root@linuxhelp ~]# chkconfig httpd on

Go to httpd.conf configuration file and provide your domain name as your server name. Save the changes and restart your apache service.

[root@linuxhelp ~]# vim /etc/httpd/conf/httpd.conf
ServerName ns2.linuxhelp.com:80

Move to Apache root directory and create index.html file.

[root@linuxhelp ~]# cd /var/www/html/
[root@linuxhelp ~]# vim index.html
Apache service is running

[root@linuxhelp ~]# service httpd restart
Stopping httpd:                                           [  OK  ]
Starting httpd:                                             [  OK  ]

Switch over to the browser and provide the machine' s IP or domain name. The screen will show as below.

Now install the NGINX service by running the following command.

[root@linuxhelp ~]# yum install nginx

-->  Processing Dependency: nginx-mod-http-perl = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
-->  Processing Dependency: nginx-mod-http-image-filter = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
-->  Processing Dependency: nginx-mod-http-geoip = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--->  Package nginx-filesystem.noarch 0:1.10.2-1.el6 will be installed
-->  Running transaction check
.
.
.
nginx-mod-http-perl.x86_64 0:1.10.2-1.el6                                     
  nginx-mod-http-xslt-filter.x86_64 0:1.10.2-1.el6                              
  nginx-mod-mail.x86_64 0:1.10.2-1.el6                                          
  nginx-mod-stream.x86_64 0:1.10.2-1.el6                                       
Complete!

Try starting the NGINX service by running the following command.

[root@linuxhelp ~]# service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
                                                           [FAILED]

It has failed because the Apache service is using port 80. Now move to your NGINX configuration file and create a configuration file named default.conf using vim editor.

[root@linuxhelp ~]# vim /etc/nginx/conf.d/default.conf

Change the listen port to 8085.

Save the changes in the file and try to restart the NGINX service.

[root@linuxhelp ~]# service nginx start
Starting nginx:                                            [  OK  ]
[root@linuxhelp ~]# chkconfig nginx on

Go to its root directory and list the files in the directory. Create a file named index.html using vim editor.

[root@linuxhelp ~]# cd /usr/share/nginx/
[root@linuxhelp nginx]# ls -l
total 8
drwxr-xr-x 2 root root 4096 Sep  7 10:35 html
drwxr-xr-x 2 root root 4096 Sep  7 10:35 modules
[root@linuxhelp nginx]# cd html/
[root@linuxhelp html]# vim index.html


Rename the index.html and creating new index.html file

[root@linuxhelp ~]# vim index.html
Nginx service is working

Restart your nginx service

Now switch over to the browser and provide the following URL http://your machine' s IP:8085. The Nginx service is running successfully.

Th

The configuration procedure of Apache and NGINX webserver in single instances.

Tag : Nginx Apache
FAQ
Q
Can I deploy NGINX Plus for HTTP video?
A
Yes, NGINX Plus is a very popular solution for HTTP video distribution, and a great, high-performance, highly scalable, extremely cost-efficient alternative to Wowza or Adobe products.
Q
Is it safe to use the development branch in production?
A
In general, all releases (development or otherwise) are quite stable. This site runs the latest development version at all times. Many NGINX users tend to represent an “early adopter” crowd,
Q
need to install Nginx latest version FreeBSD?
A
You can download the latest source code of nginx and follow this tutorial, https://www.linuxhelp.com/how-to-install-nginx-from-source-on-freebsd-11-1/
Q
Starting nginx: (98)Address already in use: make_sock: could not bind to address [::]:80?
A
this error is happened due to port 80 is already using by another process.., that's why nginx is not starting and getting this error.. use netstat or fuser commands to check current listening
Q
how to install apache GUI?
A
To install Apache web server graphically,first you need to install openjdk apt-get install openjdk-8-jdk Next Download the Apache GUI package wget http://ufpr.dl.sourceforge.net/project/