• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Install Both Apache and Nginx Web Servers on CentOS 7.6

  • 00:37 vim /etc/yum.repos.d/nginx.repo
  • 00:50 yum install nginx -y
  • 01:00 systemctl enable nginx
  • 01:04 systemctl start nginx
  • 01:16 netstat -tulpn | grep nginx
  • 01:28 vim /etc/nginx/nginx.conf
  • 01:45 vim /etc/nginx/conf.d/default.conf
  • 01:58 nginx -t
  • 02:07 systemctl restart nginx
  • 02:12 netstat -tulpn | grep nginx
  • 02:21 yum install httpd -y
  • 02:47 netstat -tulpn | grep httpd
5775

Installation of Apache And Nginx On CentOS 7.6

Check the version of both the servers to verify the installed packages on the system.

[root@linuxhelp ~]# httpd -v
bash: httpd: command not found...
[root@linuxhelp ~]# nginx -v
bash: nginx: command not found...

Nginx Installation procedure

Add the nginx repo inside the yum repository list to install the latest version of nginx

[root@linuxhelp ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1

Install the nginx server 1.17.0 version as follows:

[root@linuxhelp ~]# yum install nginx -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * epel: kartolo.sby.datautama.net.id
 * extras: mirror.nbrc.ac.in
 * remi-php72: mirrors.neterra.net
 * remi-safe: mirrors.neterra.net
 * updates: mirror.ehost.vn
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.17.0-1.el7.ngx will be installed
--> Finished Dependency Resolution
.
.
.
.
| 767 kB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:nginx-1.17.0-1.el7.ngx.x86_64                                                                                          1/1 
----------------------------------------------------------------------

Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
  Verifying  : 1:nginx-1.17.0-1.el7.ngx.x86_64                                                                                          1/1 

Installed:
  nginx.x86_64 1:1.17.0-1.el7.ngx                                                                                                           

Complete!

Enable the service of nginx

[root@linuxhelp ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

Start the service of Nginx

[root@linuxhelp ~]# systemctl start nginx

Check the status of nginx as follows

[root@linuxhelp ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-06-06 14:30:57 IST; 11s ago
     Docs: http://nginx.org/en/docs/

Check the port number that nginx is listening to.

[root@linuxhelp ~]# netstat -tulpn | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      32078/nginx: master 

Modify the port number in the configuration file of nginx inside the server block to 8989

[root@linuxhelp ~]# vim /etc/nginx/nginx.conf
server {
	listen       8989 default_server;
	listen       [::]:8989 default_server;
	server_name   _;
	root         /usr/share/nginx/html;
}

Modify the port number of Nginx in default.conf as 8989 as follows:

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

Test the configuration of nginx before restarting the service of nginx

[root@linuxhelp ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

restart the service of Nginx to update the changes in the configuration of nginx

[root@linuxhelp ~]# systemctl restart nginx

Verify Nginx listening socket using netstat

 [root@linuxhelp ~]# netstat -tulpn | grep nginx
tcp        0      0 0.0.0.0:8989            0.0.0.0:*               LISTEN      32344/nginx: master 
tcp6       0      0 :::8989                 :::*                    LISTEN      32344/nginx: master 

Apache Installation procedure

Install the Apache server by executing the following command.

[root@linuxhelp ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * epel: kartolo.sby.datautama.net.id
 * extras: mirror.nbrc.ac.in
 * remi-php72: mirrors.neterra.net
 * remi-safe: mirrors.neterra.net
 * updates: mirror.ehost.vn
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-89.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-89.el7.centos for package: httpd-2.4.6-89.el7.centos.x86_64
.
.
.
.
.
Installed:
  httpd.x86_64 0:2.4.6-89.el7.centos                                                                                                        

Dependency Installed:
  httpd-tools.x86_64 0:2.4.6-89.el7.centos                                                                                                  

Complete!

Enable the service of Apache post Installation.

[root@linuxhelp ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Start the service of Apache.

[root@linuxhelp ~]# systemctl start httpd

Check the status of Apache after starting the service of Apache.

[root@linuxhelp ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-06-06 14:36:06 IST; 10s ago

Check the listening socket of Httpd using netstat as follows.

 [root@linuxhelp ~]# netstat -tulpn | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      32583/httpd         

Open the Browser and enter the ip address of the machine followed by 80 port number to view the test page the Apache web server snap (1)snap (2)

Switch to the next tab and enter the ip address of the machine followed by 8989 port number as follows to open the test page of Nginx web server. snap (3)

With this,Installation of Apache And Nginx web servers On CentOS 7.6 Comes to end.

Tags:
caden
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Can Apache run with Nginx?

A

Yes,Apache can run with nginx

Q

What is Apache And Nginx?

A

Apache is known for its power and Nginx for speed.

Q

Can Both Apache And Nginx be used as a proxy servers?

A

yes,Both Apache and Nginx can be used as a proxy server but using Nginx as a proxy server and Apache as the back end is a common approach.

Q

Is it possible to have Apache And nginx on the same server with similar ip and same port number?

A

No.it isn't possible to have Apache and Nginx on the same server with similar ip and same prt number.

Q

What is the default port number of Apache And Nginx when they are installed on the different machines

A

The default port number of Apache And nginx is 80 when they are installed on the different machines.

Related Tutorials in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

Related Tutorials in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

How To Install AnyDesk on Centos 7
How To Install AnyDesk on Centos 7
Apr 2, 2018
How to install Tiki Wiki CMS Groupware on CentOS 7
How to install Tiki Wiki CMS Groupware on CentOS 7
May 31, 2018
How to install PHP ImageMagick on CentOS 7
How to install PHP ImageMagick on CentOS 7
Nov 4, 2017
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
Jun 4, 2019
How to install Apache from Source Code on CentOS 7
How to install Apache from Source Code on CentOS 7
Oct 21, 2017
How to enable or disable repositories in CentOS
How to enable or disable repositories in CentOS
Mar 28, 2018
How to install AWStats on CentOS 7
How to install AWStats on CentOS 7
Dec 8, 2017
How to install Apache JMeter in CentOS 7
How to install Apache JMeter in CentOS 7
Mar 24, 2017

Related Forums in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

Related Forums in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

CentOS
connor class=
How To Completely Remove Apache package On CentOS 7.6
May 14, 2019
CentOS
ceriaimmaculate class=
setfacl : command not found
Jan 3, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018
Nginx
gokulravichandran2 class=
Failed to start A high performance web server and a reverse proxy server
Dec 23, 2018
CentOS
landon class=
Command to find SNMP Version
May 28, 2018
CentOS
arjitharon class=
cannot start minio service help
Mar 10, 2018
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018
Apache tomcat
AadrikaAnshu class=
Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program
Jun 17, 2019

Related News in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

Related News in How to Install Both Apache and Nginx Web Servers on CentOS 7.6

Attackers take advantage of Apache Struts vulnerabilities
Attackers take advantage of Apache Struts vulnerabilities
Mar 17, 2017
An Apache Web Server Bug That Grants Root Access on  Shared Web Hosts
An Apache Web Server Bug That Grants Root Access on Shared Web Hosts
Apr 10, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Owen ?
How to add SSH key to my Gitlab account

I need to add the SSH key in my gitlab account. How to do so ????

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.