4321oiuy 发表于 2016-9-18 09:14:36

apache静态化页面

Apache开启静态化页面

博主未解决的坑:
本人首次搭建LAMP采用的是编译安装HTTPD服务,在开启静态化页面时发现在httpd.conf中没有LoadModule rewrite_module libexec/mod_rewrite.so代码,手动添加进去重启apache时报错;
查看文件.htaccess也正常:
1
2
3
4
5
6
7
8
9
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>




编译安装httpd的版本、参数如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
#tar xf httpd-2.2.31.tar.gz
#cd httpd-2.2.31
#yum install zlib zlib-devel -y
./configure \
--prefix=/application/apache2.2.31 \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
#make
#make install




总之问题为解决
本着简单、易用、高效的原则,本人建议采用yum安装;

Apache实现静态化页面的实际操作:
配置文件httpd.conf中:

AllowOverride None改为AllowOverride All
      文件中要有LoadModule rewrite_module libexec/mod_rewrite.so,代码前若有#注释,把注释去掉,若没有此代码则手动添加进去;
      .htaccess文件:

1
2
3
4
5
6
7
8
9
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>




文件中若没有上述代码则手动添加到文件中


页: [1]
查看完整版本: apache静态化页面