如何添加网站for Linux(绑定域名)

以下配置的路径仅供参考,如果您另行安装,请根据实际安装路径配置。
 
1.cd /mydata/server/httpd/conf/vhosts/ 进入绑定域名所在目录,
 
2.vim test.conf 建立一个配置文件,test可以自己命名;
 
3.点击字母 i 开始编辑文件,输入内容:
  1. <VirtualHost *:80>  
  2.         DocumentRoot /mydata/www/phpwind   
  3.         ServerName localhost   
  4.         ServerAlias localhost   
  5.         <Directory "/mydata/www/phpwind">  
  6.             Options -Indexes FollowSymLinks   
  7.             AllowOverride all   
  8.             Order allow,deny   
  9.             Allow from all   
  10.         </Directory>  
  11.         <IfModule mod_rewrite.c>  
  12.                 RewriteEngine On   
  13.                 RewriteRule ^(.*)-htm-(.*)$ $1.php?$2   
  14.                 RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2   
  15.         </IfModule>  
  16.         ErrorLog "/mydata/log/httpd/phpwind-error.log"   
  17.         CustomLog "/mydata/log/httpd/access/phpwind.log" common   
  18. </VirtualHost>  
 其中:
ServerName www.test.com 绑定的网站域名
ServerAlias test.com 绑定的网站别名(您如果有多个域名添加在这里)
DirectoryIndex index.html index.php index.htm 设置默认首页
DocumentRoot /mydata/www/testDirectory "/mydata/www/test" 都是指定网站的目录,需要一致。
 
按esc退出编辑模式,输入:wq保存退出。
 
4.输入命令:/mydata/server/httpd/bin/apachectl restart 重启apache测试。
 
5.测试网站。请在浏览器中输入域名,测试设置。
 
  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓