购物车中还没有商品,赶紧选购吧!

Linux apache 域名绑定方法

发布日期:2017-10-18 阅读:5544

以下配置的路径以阿里云提供的标准环境路径为准,如果您另行安装,请根据实际安装路径去找到您的配置文件进行配置。

       假如我们需要在我们的网站www.test.com上增加绑定一个m.test.com和一个test.com的域名,请进行如下类似的操作:

1.cd /alidata/server/httpd/conf/vhosts/ 找到您的网站配置文件,一般是您的域名.conf,例如域名是:www.test.com,那就应该是www.test.com.conf

 

2.vim www.test.com.conf  修改这个配置文件,您应该会看到如下类似的配置内容:

<VirtualHost *:80>

DocumentRoot /www/web/www_test_com/public_html

ServerName www.test.com

ServerAlias

DirectoryIndex index.php

ErrorDocument 400 /errpage/400.html

ErrorDocument 403 /errpage/403.html

ErrorDocument 404 /errpage/404.html

CustomLog "/www/web_logs/www.test.com_access_log" common

ErrorLog "/www/web_logs/www.test.com_error_log"

php_admin_value open_basedir /www/web/www_test_com:/tmp

<IfModule mod_deflate.c>

DeflateCompressionLevel 7

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php

AddOutputFilter DEFLATE css js html htm gif jpg png bmp php

</IfModule>

</VirtualHost>

<Directory /www/web/www_test_com>

    Options FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

</Directory>

 

3.点击字母“i”开始编辑文件,输入内容:

<VirtualHost *:80>

DocumentRoot /www/web/www_test_com/public_html

ServerName www.test.com

ServerAlias test.com m.test.com

DirectoryIndex index.php

ErrorDocument 400 /errpage/400.html

ErrorDocument 403 /errpage/403.html

ErrorDocument 404 /errpage/404.html

CustomLog "/www/web_logs/www.test.com_access_log" common

ErrorLog "/www/web_logs/www.test.com_error_log"

php_admin_value open_basedir /www/web/www_test_com:/tmp

<IfModule mod_deflate.c>

DeflateCompressionLevel 7

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php

AddOutputFilter DEFLATE css js html htm gif jpg png bmp php

</IfModule>

</VirtualHost>

<Directory /www/web/www_test_com>

    Options FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from all

</Directory>

 

其中:

ServerName www.test.com 绑定的网站域名

ServerAlias test.com m.test.com 绑定的网站别名(您如果有多个域名添加在这里)

DirectoryIndex index.html index.php index.htm 设置默认首页

DocumentRoot /www/web/www_test_com/public_html 和 Directory "/www/web/www_test_com/public_html " 都是指定网站的目录,需要一致。

 

按“esc”退出编辑模式,输入“:wq”保存退出。

 

4.输入命令:/alidata/server/httpd/bin/apachectl restart 重启apache测试。

 

5.测试网站。请在浏览器中输入域名,测试设置。


以上内容是否对您有帮助? 您的反馈信息提交成功,谢谢您的反馈!

会员评论

在线客服
微信咨询
微信咨询
现在咨询,获取演示账号
企业logo小米
立即扫码加我微信
电话咨询
咨询电话
028-61558715
预约演示