Linux Enterprise Common Service---deploy Nginx virtual host

Source: Internet
Author: User

Prepare before deployment:

Disc configuration local Yum source, modify Yum config file

Firewall and SELinux do not set, turn off

IP address set to 192.168.100.222

Nginx Installation Complete


1. Install and configure DNS:

To install DNS:

[email protected] ~]# Yum install bind-utils bind Bind-chroot

Configuration:

[Email protected] ~]# cd/var/named/chroot/etc/

To configure the main file:

[Email protected] etc]# pwd

/var/named/chroot/etc

[email protected] etc]# cat named.conf

Options {

Directory "/var/named";

};

Zone "linuxfan.cn" in {

Type master;

File "Linuxfan.cn.zone";

};

Zone "linuxren.cn" in {

Type master;

File "Linuxren.cn.zone";

};

[Email protected] etc]# Chown named named.conf

[Email protected] etc]# named-checkconf named.conf # #检测语法

To configure a zone file:

[email protected] named]# cat Linuxren.cn.zone

$TTL 86400

@ SOA linuxren.cn. admin.linuxren.cn. (

20160101

4H

30M

12H

1D

)

@ in NS ns.linuxren.cn.

NS in A 192.168.100.222

@ in A 192.168.100.222

www in A 192.168.100.222

[email protected] named]# cat Linuxfan.cn.zone

$TTL 86400

@ SOA linuxfan.cn. admin.linuxfan.cn. (

20131015

4H

30M

12H

1D

)

@ in NS ns.linuxfan.cn.

NS in A 192.168.100.222

@ in A 192.168.100.222

www in A 192.168.100.222

[Email protected] named]# pwd

/var/named/chroot/var/named

[Email protected] named]#

[Email protected] named]# Named-checkzone linuxfan.cn.zone linuxren.cn.zone

Zone linuxfan.cn.zone/in:loaded Serial 20131015

Ok

[Email protected] named]# chown named:named Linux *. /.. /etc/named.conf


2. Deploy Nginx Virtual Host:

[Email protected] ~]# cd/usr/local/nginx/html/

[[email protected] html]# ls

50x.html index.html

[Email protected] html]# mkdir Linuxfan

[Email protected] html]# mkdir Linuxren

[Email protected] html]# echo linuxfan.cn >linuxfan/index.html

[Email protected] html]# echo linuxren.cn >linuxren/index.html

[Email protected] html]# pwd

/usr/local/nginx/html

[Email protected] html]#

[Email protected] html]# vi/usr/local/nginx/conf/nginx.conf

Worker_processes 1;

Events {

Use Epoll;

Worker_connections 4096;

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" "$http _x_forwarded_for";

Access_log Logs/access.log Main;

Sendfile on;

Keepalive_timeout 65;

server {

Listen 80;

server_name www.linuxfan.cn;

CharSet Utf-8;

Access_log Logs/linuxfan.access.log Main;

Location/{

Root/usr/local/nginx/html/linuxfan;

Index index.html index.php;

}

}

server {

Listen 80;

server_name www.linuxren.cn;

CharSet Utf-8;

Access_log Logs/linuxren.access.log Main;

Location/{

Root/usr/local/nginx/html/linuxren;

Index index.html index.php;

}

}

}

[Email protected] conf]# nginx-t

Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK

Nginx:configuration file/usr/local/nginx/conf/nginx.conf Test is successful

[Email protected] conf]#/etc/init.d/nginx restart

Nginx is stopping!!

Nginx is starting!!

Access test:

[Email protected] conf]# elinks--dump http://www.linuxren.cn

linuxren.cn

[Email protected] conf]# elinks--dump http://www.linuxfan.cn

linuxfan.cn

Finally implement different domain access to an IP address

This article is from the "Lp-linux" blog, make sure to keep this source http://linuxlp.blog.51cto.com/11463376/1773554

Linux Enterprise Common Service---deploy Nginx virtual host

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.