Home > Backend Development > PHP Tutorial > Installation and basic configuration of nginx, and multiple domain name services

Installation and basic configuration of nginx, and multiple domain name services

WBOY
Release: 2016-07-28 08:29:17
Original
1572 people have browsed it

centos6.x yum does not have nginx software package by default
Installation method:
Go to the nginx download page http://nginx.org/en/linux_packages.html#stable and copy the nginx software source installation package of CENTOS 6
Run the command: wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
Install the rpm package yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y , this step actually just adds the nginx package source
Execute yum install nginx -y to install nginx

nginx is installed as a Linux service by default
Use service nginx start, stop, restart, try-restart, reload, force-reload, status to operate nginx

nginx’s configuration file reads the /etc/nginx/nginx.conf file by default
The configuration of nginx is composed of directives, which are composed of simple instructions or block instructions
Simple command: listen 80;
Block instructions are included by {}, and block instructions can include multiple simple instructions and block instructions:

<code>http <span>{
    server {
    }</span>
}</code>
Copy after login

http can have multiple servers, and multiple servers can listen to multiple ports and provide services for multiple applications on the same server. .
But if you have multiple domain names www.you.com, news.you.com, mail.you.com serving on the same server at the same time, then www.you.com, mail.you.com:8080, news.you The access method like .com:81 is obviously inappropriate. Fortunately, nginx has provided rules for filtering by domain name

<code><span>server</span>
{
    listen <span>80</span>;
    server_name www.you.com;
    location / {
        <span>#....</span>
        proxy_pass http:<span>//localhost:8880;</span>
    }
    <span>##### other directive</span>
}

<span>server</span>
{
    listen <span>80</span>;
    server_name news.you.com;
    location / {
        <span>#....</span>
        proxy_pass http:<span>//localhost:8881;</span>
    }
    <span>##### other directive</span>
}

<span>server</span>
{
    listen <span>80</span>;
    server_name mail.you.com;
    location / {
        <span>#....</span>
        proxy_pass http:<span>//localhost:8882;</span>
    }
    <span>##### other directive</span>
}</code>
Copy after login

In the end, just run each application and listen to the corresponding port.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the installation and basic configuration of nginx, as well as multiple domain name services, including related content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template