Implementation of Nginx installation under Linux port differentiation, domain name distinction

Source: Internet
Author: User

Nginx is a high-performance HTTP server/reverse proxy server and e-mail proxy server.

Official website:

http://nginx.org/

1, HTTP server. Nginx is an HTTP service that can provide HTTP services independently. Can do web static server.

2, virtual host. Can be implemented in a single server virtual out of multiple sites. For example, a personal web site uses a virtual host.

3, reverse proxy, load balancing. When the number of visits to a certain level of the site, a single server can not meet the user's request, you need to use more than one server cluster can use Nginx to do reverse proxy. And more than one server can share the load evenly, not because of a server load high downtime and a server idle situation.

Installing Nginx under Linux

* Prepare the installation environment

1, the need to install GCC environment. Yum Install gcc-c++

2, third-party development package.

-PCRE

PCRE (perl Compatible Regular Expressions) is a Perl library that includes a Perl-compatible regular expression library. The Nginx HTTP module uses PCRE to parse the regular expression, so the Pcre library needs to be installed on Linux.

Yum install-y pcre Pcre-devel

Note: Pcre-devel is a two-time development library developed using PCRE. Nginx also needs this library.

-Zlib

The Zlib library provides a number of ways to compress and decompress, and Nginx uses zlib to gzip the contents of the HTTP package, so you need to install the Zlib library on Linux.

Yum install-y zlib Zlib-devel

-OpenSSL

OpenSSL is a strong Secure Sockets Layer cipher library that includes key cryptographic algorithms, common key and certificate encapsulation management functions, and SSL protocols, and provides a rich set of applications for testing or other purposes.

Nginx not only supports the HTTP protocol, but also supports HTTPS (that is, transmitting HTTP on the SSL protocol), so you need to install the OpenSSL library on Linux.

Yum Install-y OpenSSL Openssl-devel

* Upload Nginx package to Linux system

* Unpacking Package

* Enter the extracted Nginx directory and execute the following command to create the compiled file

./Configure--prefix=/usr/local/nginx \--pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/var/temp/nginx/client \--http-proxy-temp-path=/var/temp/nginx/proxy \--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \--http-scgi-temp-path=/var/temp/nginx/scgi

One more makefile in the folder after execution is complete

* Then make compile

* Then install

* and then under the usr/local, there's more nginx.

* Enter the Sbin directory under the Nginx directory to start Nginx

This will be an error.

So we need to create a directory under/var/temp/nginx.

Then we can start.

View process See already started complete

Access (nginx default port is 80)

Close Nginx

Note Turn off the firewall

Configuring a virtual Host

* Modify configuration file

Edit the changes by EditPlus at this time.

* Set FTP

Add a

Point advanced Options after configuration is complete

OK after modification

You can see it when you're all sure.

Start connecting to a remote server after clicking

You can see the directory under Linux.

Select the nginx.conf file under Nginx to edit

Delete fields that you don't need

Save is will error, direct click Yes, and then OK

* Configure a server again, save the error continue to determine

Create a html81 directory under the Nginx directory under Linux

Enter html81 Enter index.html change welcome title to differentiate

* Reload configuration file

Access Port 81

This completes a nginx down through the port area divided into two different websites

But what if everyone wants to use port 80 to access it?

This requires a domain name to differentiate between different hosts.

DNS server: Resolves the domain name to an IP address. The mappings between the domain name and the IP are saved

A domain name corresponds to an IP address, and an IP address can be bound by multiple domain names.

Local test can modify window's Hosts file: (C:\WINDOWS\SYSTEM32\DRIVERS\ETC)

You can configure the domain name and IP mapping relationship, if the hosts file is configured with the domain name and IP correspondence, do not need to go to the DNS server.

Can be more easily modified by switchhosts! software

Configuring in the Software

You can visit again.

The following is configured in Linux

Add one more server first

Then go to Nginx to create the html-test and Html-test1 directory restart to access the

Implementation of Nginx installation under Linux port differentiation, domain name distinction

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.