配置Apache虚拟主机

Ubuntu:
  1. 参考/etc/apache2/sites-available/default文档,配置自己的虚拟目录。例如“test",主要修改的是ServerName,DocumentRoot,还有目录的权限。如图:

  1. 运行命令sudo a2ensite test(上面配置的文档名称)。
  2. 重启apache服务。sudo service apache2 restart。
centos
(七)配置虚拟主机
编辑/etc/httpd/conf/httpd.conf文件。
[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. vim /etc/httpd/conf/httpd.conf  
修改如下:
1添加apache监听的IP地址和端口号:在Listen 80下面添加Listen 90
2添加文件目录设置
[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <Directory "/var/www/html/xiayuhappy">  
  2.     Options Includes ExecCGI FollowSymLinks  
  3.     AllowOverride All  
  4.     Order allow,deny  
  5.     Allow from all  
  6. </Directory>  
3、添加虚拟主机
[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <VirtualHost 10.10.90.210:90>  
  2.     DocumentRoot "/var/www/html/xiayuhappy"  
  3.     ServerName www.xiayuhappy.com  
  4. </VirtualHost>  
4、(根据需要)配置cgi。去掉注释AddHandler cgi-script .cgi
5、关闭SELinux
[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. setenforce 0  
6、重启apache
[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. /etc/init.d/httpd restart  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值