浏览模式: 标准 | 列表 Tag: apache

转换重写规则:从apache的htaccess到nginx的RewriteRul...

越来越多的web服务器开始选择跑nginx,而两个平台的rewriterule却不相同,有这么一个网站,可以解决这个问题:

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

Tags: apache, nginx, rewriterule

解决Apache mod_rewrite 模块无法使用问题

今天想把自己的博客开启“高级URL Rewrite”功能,因为是linux主机,所以必然涉及到apache配置文件的修改:

进入apache配置文件目录

[root@linuxserver ~]# cd /usr/local/apache2/conf/

编辑httpd.conf

[root@linuxserver ~]# vi httpd.conf

查找模块是否已经启用,如果前面有#,则去掉

LoadModule rewrite_module modules/mod_rewrite.so

如果已经启用的话,PHP程序中依然无法使用URL Rewrite功能的话,那还需要修改一个地方,查找

Options FollowSymLinks
    AllowOverride None

将None修改为All即可

重启apache服务

[root@linuxserver ~]# apache2 -k restart

进入程序后,看看是否已经可以用重新(rewrite)功能了,对了,记得把.htaccess传到你的网站根目录下

Tags: apache

vps下Apache VirtualHost配置

在火山互联申请了免费linux vps后,自己动手实践能力就要更为丰富了,本文为配置vhost.conf文件达到linux下apache的虚拟主机功能

环境:CentOS 5.2 + Apache 2.2.6 + PHP 5.2.5 + MySQL 5.1.3

首先要apache服务认得虚拟主机配置文件,则要修改/usr/local/apache2/conf/httpd.conf

在其底部加入:

Include "/usr/local/apache2/conf/vhost.conf"

定位到apache安装目录下的配置文件,/usr/local/apache2/conf/vhost.conf

打开后内容如下:

DocumentRoot /data/web/www/
ServerName
www.vhost.cn

将它修改为我们所需要的:

NameVirtualHost *:80

ServerName is36.cn
ServerAlias www.is36.cn
DocumentRoot /data/web/www/

ServerName blog.is36.cn
ServerAlias www.blog.is36.cn
DocumentRoot /data/web/blog/

修改完成后重启apache服务即可:apache2 -k restart

(用ln做链接,类似windows下的快捷方式指向全局变量地址,就可以在终端任何地方输入apache2进行对apache服务的操作了)

ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apache2

重启过程中如果出现如下情况需要去建立对应的blog文件夹:

[root@linuxserver ~]# apache2 -k restart
Warning: DocumentRoot [/data/web/blog/] does not exist

据网上资料还要在httpd.conf下加入如下的配置条文,本过程中未加入,后续观察:

Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all

Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all


附/usr/local/apache2/conf/extra/httpd-vhosts.conf 作为配置参考文件

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#

ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/www/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias
www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log common"

ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/www/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log common"

Tags: apache, linux, vps