LNMP in Apache Configure virtual hosting and personal home page

Source: Internet
Author: User
Tags hosting

Turn off the page settings in the main configuration file

#DocumentRoot "/usr/local/apache2//htdocs"

#<directory "/usr/local/apache2//htdocs" >

# Options Indexes followsymlinks

# allowoverride None

# <RequireAll>

# Require All granted

# Require not IP 192.168.193.1

# </RequireAll>

#</directory>

Turn on the virtual host option

Include etc//extra/httpd-vhosts.conf

IP -based virtual hosts :

One server, multiple IPs, build multiple websites

Vim etc/extra/httpd-vhosts.conf

<virtualhost 192.168.193.2>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/baidu"

ServerName www.baidu.com

# Serveralias Www.dummy-host.example.com

Errorlog "Logs/dummy-host.example.com-error_log"

Customlog "Logs/dummy-host.example.com-access_log" common

<directory "/usr/local/apache2/htdocs/baidu" >

Require all granted

</Directory>

</VirtualHost>

<virtualhost 192.168.193.4>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/xdl"

ServerName www.xdl.com

Errorlog "Logs/dummy-host2.example.com-error_log"

Customlog "Logs/dummy-host2.example.com-access_log" common

<directory "/USR/LOCAL/APACHE2/HTDOCS/XDL" >

Require all granted

</Directory>

</VirtualHost>

Port-based virtual host

One server, one IP, multiple Web sites, each network using a different port to access

Vim etc/extra/httpd-vhosts.conf

#Listen 80

Listen 8080

<virtualhost 192.168.193.2:80>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/baidu"

ServerName www.baidu.com

"Etc/extra/httpd-vhosts.conf" 53L, 1717C 23,1 top

DocumentRoot "/usr/local/apache2/htdocs/baidu"

ServerName www.baidu.com

# Serveralias Www.dummy-host.example.com

Errorlog "Logs/dummy-host.example.com-error_log"

Customlog "Logs/dummy-host.example.com-access_log" common

<directory "/usr/local/apache2/htdocs/baidu" >

Require all granted

Options Indexes

AllowOverride None

</Directory>

</VirtualHost>

<virtualhost 192.168.193.2:8080>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/xdl"

ServerName www.xdl.com

Errorlog "Logs/dummy-host2.example.com-error_log"

Customlog "Logs/dummy-host2.example.com-access_log" common

<directory "/USR/LOCAL/APACHE2/HTDOCS/XDL" >

Require all granted

Options Indexes

AllowOverride None

</Directory>

</VirtualHost>

based on Domain name the virtual host

A server, an IP, build multiple websites, each site uses different domain names to access

<virtualhost *:80>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/baidu"

ServerName www.baidu.com

<sr/local/apache2/etc/extra/httpd-vhosts.conf "53L, 1690C 25,1 top

DocumentRoot "/usr/local/apache2/htdocs/baidu"

ServerName www.baidu.com

# Serveralias Www.dummy-host.example.com

Errorlog "Logs/dummy-host.example.com-error_log"

Customlog "Logs/dummy-host.example.com-access_log" common

<directory "/usr/local/apache2/htdocs/baidu" >

Require all granted

Options Indexes

AllowOverride None

</Directory>

</VirtualHost>

<virtualhost *:80>

# ServerAdmin [email protected]

DocumentRoot "/usr/local/apache2/htdocs/xdl"

ServerName www.qq.com

Errorlog "Logs/dummy-host2.example.com-error_log"

Customlog "Logs/dummy-host2.example.com-access_log" common

<directory "/USR/LOCAL/APACHE2/HTDOCS/XDL" >

Require all granted

Options Indexes

AllowOverride None

</Directory>

</VirtualHost>

the domain name www.baidu.com , www.qq.com resolving in DNS server

Add a separate profile for each user:

To enable access settings for the master configuration file

LoadModule Userdir_module modules/mod_userdir.so

Include etc//extra/httpd-userdir.conf

# Vim/usr/local/apache2/etc/extra/httpd-userdir.con

Userdir public_html

#

# Control access to Userdir directories. The following is an example

# for a site where these directories is restricted to read-only.

#

<directory "/home/*/public_html" >

allowoverride FileInfo authconfig Limit Indexes

Options multiviews Indexes SymLinksIfOwnerMatch includesnoexec

Require Method GET POST OPTIONS

</Directory>

Default settings are not modified

set up in the user home directory public_html files, and modify the permissions of the user home directory to have Read permissions

DRWX-----x. 4 LF LF 4096 5 months 19:46 LF

DRWX-----x. 4 Fengyunfan fengyunfan 4096 5 months 19:48 Fengyunfan


This article is from the "Sail" blog, please be sure to keep this source http://fengyunfan.blog.51cto.com/6663935/1659409

LNMP in Apache Configure virtual hosting and personal home page

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.