Ubuntu:
- 参考/etc/apache2/sites-available/default文档,配置自己的虚拟目录。例如“test",主要修改的是ServerName,DocumentRoot,还有目录的权限。如图:
- 运行命令sudo a2ensite test(上面配置的文档名称)。
- 重启apache服务。sudo service apache2 restart。
centos
(七)配置虚拟主机
编辑/etc/httpd/conf/httpd.conf文件。
修改如下:
1添加apache监听的IP地址和端口号:在Listen 80下面添加Listen 90
2添加文件目录设置
3、添加虚拟主机
4、(根据需要)配置cgi。去掉注释AddHandler cgi-script .cgi
5、关闭SELinux
6、重启apache
编辑/etc/httpd/conf/httpd.conf文件。
- vim /etc/httpd/conf/httpd.conf
1添加apache监听的IP地址和端口号:在Listen 80下面添加Listen 90
2添加文件目录设置
- <Directory "/var/www/html/xiayuhappy">
- Options Includes ExecCGI FollowSymLinks
- AllowOverride All
- Order allow,deny
- Allow from all
- </Directory>
- <VirtualHost 10.10.90.210:90>
- DocumentRoot "/var/www/html/xiayuhappy"
- ServerName www.xiayuhappy.com
- </VirtualHost>
5、关闭SELinux
- setenforce 0
- /etc/init.d/httpd restart