chenmaostyle 2017-04-14 11:29 采纳率: 50%
浏览 3081
已结题

一个阿里云服务器CentOS + Apache 如何配置两个域名到不同目录?

我是想把两个域名www.cbbstyle1.com和www.cbbstyle2.com
分别指向服务器上的/home/MyfirstWeb/www1和/home/MyfirstWeb/www2目录中。

但我配置了httpd.conf .
还是不成功,两个域名还是都是指向www1去了

-----------我的httpd.conf文件---------------------
#

This is the main Apache HTTP server configuration file. It contains the

configuration directives that give the server its instructions.

See URL:http://httpd.apache.org/docs/2.4/ for detailed information.

In particular, see

URL:http://httpd.apache.org/docs/2.4/mod/directives.html

for a discussion of each configuration directive.

#

Do NOT simply read the instructions in here without understanding

what they do. They're here only as hints or reminders. If you are unsure

consult the online docs. You have been warned.

#

Configuration and logfile names: If the filenames you specify for many

of the server's control files begin with "/" (or "drive:/" for Win32), the

server will use that explicit path. If the filenames do not begin

with "/", the value of ServerRoot is prepended -- so 'log/access_log'

with ServerRoot set to '/www' will be interpreted by the

server as '/www/log/access_log', where as '/log/access_log' will be

interpreted as '/log/access_log'.

#

ServerRoot: The top of the directory tree under which the server's

configuration, error, and log files are kept.

#

Do not add a slash at the end of the directory path. If you point

ServerRoot at a non-local disk, be sure to specify a local disk on the

Mutex directive, if file-based mutexes are used. If you wish to share the

same ServerRoot for multiple httpd daemons, you will need to change at

least PidFile.

#
ServerRoot "/etc/httpd"

#

Listen: Allows you to bind Apache to specific IP addresses and/or

ports, instead of the default. See also the

directive.

#

Change this to Listen on specific IP addresses as shown below to

prevent Apache from glomming onto all bound IP addresses.

#
#Listen 12.34.56.78:80
Listen 80

#

Dynamic Shared Object (DSO) Support

#

To be able to use the functionality of a module which was built as a DSO you

have to place corresponding `LoadModule' lines at this location so the

directives contained in it are actually available before they are used.

Statically compiled modules (those listed by `httpd -l') do not need

to be loaded here.

#

Example:

LoadModule foo_module modules/mod_foo.so

#
Include conf.modules.d/*.conf

#

If you wish httpd to run as a different user or group, you must run

httpd as root initially and it will switch.

#

User/Group: The name (or #number) of the user/group to run httpd as.

It is usually good practice to create a dedicated user and group for

running httpd, as with most system services.

#
User apache
Group apache

'Main' server configuration

#

The directives in this section set up the values used by the 'main'

server, which responds to any requests that aren't handled by a

definition. These values also provide defaults for

any containers you may define later in the file.

#

All of these directives may appear inside containers,

in which case these default settings will be overridden for the

virtual host being defined.

#

#

ServerAdmin: Your address, where problems with the server should be

e-mailed. This address appears on some server-generated pages, such

as error documents. e.g. admin@your-domain.com

#
ServerAdmin root@localhost

#

ServerName gives the name and port that the server uses to identify itself.

This can often be determined automatically, but we recommend you specify

it explicitly to prevent problems during startup.

#

If your host doesn't have a registered DNS name, enter its IP address here.

#
#ServerName www.example.com:80

#

Deny access to the entirety of your server's filesystem. You must

explicitly permit access to web content directories in other

blocks below.

#

AllowOverride none
Require all denied

DocumentRoot "/home/MyfirstWeb/www1"


AllowOverride None
# Allow open access:
Require all granted

Options Indexes FollowSymLinks

AllowOverride None

Require all granted


DirectoryIndex index.html


Require all denied

ErrorLog "logs/error_log"

LogLevel warn

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
  # You need to enable mod_logio.c to use %I and %O
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>

CustomLog "logs/access_log" combined


ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"


AllowOverride None
Options None
Require all granted


TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

AddDefaultCharset UTF-8


MIMEMagicFile conf/magic

EnableSendfile on

IncludeOptional conf.d/*.conf

ServerName 119.32.23.55:80
NameVirtualHost 119.32.23.55

ServerAdmin root@localhost
DocumentRoot /home/MyfirstWeb/
ServerName 119.32.23.55

#

ServerAdmin root@localhost
DocumentRoot /home/MyfirstWeb/www1
ServerName www.cbbstyle1.com

#

ServerAdmin root@localhost
DocumentRoot /home/MyfirstWeb/www2
ServerName www.cbbstyle2.com

  • 写回答

1条回答

  • threenewbee 2017-04-14 13:00
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B