mac+apache虚拟主机(4步解决)
下面蓝色字体的路径,各位要自己改一下啊~
1、修改httpd.conf里面,去掉include前面注释
sudo vim /etc/apache2/httpd.conf //window下,如果装wampserver,则地址在c:/wamp/bin/apache/apache2.4.9/conf/ 下面
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
2、修改httpd-vhosts.conf里面,添加以下
sudo vim /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/Users/liangzhongyuan/Sites/cos"
ServerName www.cosweb.com
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
# 下面注释的小部分,如果httpd.conf里面已经有了,就不需要了。
# <Directory />
# Options Indexes FollowSymLinks MultiViews
# AllowOverride None
# Order deny,allow
# Allow from all
# </Directory>
</VirtualHost>
3、修改hosts(以下是apache和nginx共通之处)
sudo vim /etc/hosts
127.0.0.1 www.cosweb.com
4、重启apache服务
sudo apachectl restart
搞定~
ubuntu12.04+nginx虚拟主机(4步解决)
1、修改nginx.conf里面,取消注释
sudo vim /etc/nginx/nginx.conf
##
# Virtual Host Configs
##
include /etc/nginx/sites-enabled/*;
2、修改default里面,添加或修改以下
sudo vim /etc/nginx/sites-available/default
server {
listen 80;
server_name www.cosweb.com;
root /home/liang/php/cos;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
3、修改hosts(以下是apache和nginx共通之处)
sudo vim /etc/hosts
127.0.0.1 www.cosweb.com
4、重启nginx服务
sudo service nginx restart
打开浏览器试试:http://www.cosweb.com/index.php
Wampserver 下
1、修改httpd.conf
位置:c:/wamp/bin/apache/apache2.4.9/conf/ //修改前要备份
修改三块:
LoadModule rewrite_module modules/mod_rewrite.so #去掉前面";" //为了laravel的配置
#这一段参考上面注释部分 <Directory /> AllowOverride none #Require all denied Order deny,allow Allow from all #这个必须要,不然总是403 forbidden 错误 </Directory> # Virtual hosts Include conf/extra/httpd-vhosts.conf #去掉前面的";"
二、修改http-vhosts.conf
#laravel项目典型配置 <VirtualHost *:80> DocumentRoot "d:/Sites/project/overtimerecord/public" ServerName overtimerecord ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
三、修改hosts
C:\Windows\System32\drivers\etc 下的hosts
四、重启wampserver
over~
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:虚拟主机+mac下apache+ubuntu12.04下nginx+只要4部+wamp下 - Python技术站