linux apache配置虚拟主机,Linux apache配置虚拟主机

1.进入/usr/local/apache/conf/httpd.conf,

注释掉:DocumentRoot "/usr/local/apache/htdocs",该成:DocumentRoot "/var/www/";

启用:Include conf/extra/httpd-vhost.conf;

2.修改配置文件的的Allowoverride(两处都修改了)

http://www.jb51.net/article/30120.htm

3.确定apache配置文件httpd.conf下安装了路由重写模块并开启了路由重写模块。

(源码编译方式安装不会自动安装模块)。

文件路径:usr/local/apache/conf/original/httpd.conf

(路径:LoadModule rewrite_module modules/mod_rewrite.so)

http://gaoxingf.blog.51cto.com/612518/190362/

3.虚拟机配置文件添加路由重写文件

ServerAdmin 123.45.23.76

DocumentRoot "/var/www/gcash"

ServerName 123.45.23.76

ErrorLog "logs/dummy-host2.example.com-error.log"

CustomLog "logs/dummy-host2.example.com-access.log" common

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

但是配置成上面的形式可能会导致部分的文件无法解析,即一些可以访问,

一些不能访问,所以,我们增加解,析配成下面的形式:

ServerAdmin 123.45.23.76

DocumentRoot "/var/www/gcash

ServerName 123.45.23.76

ErrorLog "logs/dummy-host2.example.com-error.log"

CustomLog "logs/dummy-host2.example.com-access.log" common

DirectoryIndex index.php index.html (新增加的一行)

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值