How to install nginx and port configuration in CentOS

Source: Internet
Author: User
Tags bind centos

Find the supported information on the official nginx website:

Currently, nginx packages are available for the following distributions and versions:

RHEL/CentOS:

Version Supported Platforms
5.x X86_64, i386
6.x X86_64, i386
7. x X86_64

Debian:

Version Codename Supported Platforms
6.x Squeeze X86_64, i386
7. x Wheezy X86_64, i386
8. x Jessie X86_64, i386

Ubuntu:

Version Codename Supported Platforms
10.04 Lucid X86_64, i386
12.04 Precise X86_64, i386
14.04 Trusty X86_64, i386, aarch64/arm64
14.10 Utopic X86_64, i386

SLES:


To enable automatic update of Linux packages set up the yum repository for the RHEL/CentOS distributions, the apt repository for the Debian/Ubuntu distributions, or the zypper repository for SLES.

We can see that CentOS is installed through yum. Run the following command:

# Rpm-ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
 
# Yum-y install nginx
The installation is successful, and then the service is enabled, and a port conflict is reported. (Because apache is installed with Port 80 in advance)


# Service nginx start

Starting nginx: [emerg] bind () to 0.0.0.0: 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 0.0.0.0: 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 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] still cocould not bind ()
[FAILED]

Find the nginx configuration file.


# Vim/etc/nginx. conf

There is a "include/etc/nginx/conf. d/*. conf;", and the file/etc/nginx/conf. d/default. conf is found again.

Vim/etc/nginx/conf. d/default. conf

Change listen 80 to listen 8080, and then start nginx.

1
# Service nginx restart
Open the browser and enter http: // localhost: 8080/. The following content is displayed.

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Specified cial support is available at nginx.com.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.