1、常见配置
①、php apache 配置:httpd.conf
DocumentRoot /yjdata/www/www/
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/yjdata/www/www/$1
DirectoryIndex index.html index.php
注:apache本身是不能处理php脚本的,必须将php脚本转发给php解释器去执行。ProxyPassMatch就是通过正则拿到要执行的脚本路径和名称,然后通过fcgi协议将其传递给php解释器。
②、域名解析
# Virtual hosts,这段话必须在前面配置的后面
Include conf/extra/httpd-vhosts.conf
DocumentRoot /yjdata/www/www/lulublog/web
ServerName linux.lulublog.cn
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/yjdata/www/www/lulublog/web/$1
DirectoryIndex index.php
③、ssl 配置
A 打开 httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
Include conf/extra/httpd-ssl.conf
B 修改 httpd-ssl.conf(注意修改你的文件的路径)
DocumentRoot "/yjdata/www/www/lulublog/web"
ServerName linux.lulublog.cn:443
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/yjdata/www/www/lulublog/web/$1
DirectoryIndex index.php
SSLCertificateKeyFile "/yjdata/www/www/linux.lulublog.cn.key"
SSLCertificateFile "/yjdata/www/www/linux.lulublog.cn.crt"
C 重启 httpd
④ http 重定向到 https
DocumentRoot /yjdata/www/www/lulublog/web
ServerName linux.lulublog.cn
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]
⑤ 不带www的域名301重定向到带www的域名
新建.htaccess 放在网站访问的根目录
RewriteEngine On
RewriteCond %{HTTP_HOST} ^lulublog.cn [NC]
RewriteRule ^(.*)$ http://www.lulublog.cn/$1 [L,R=301]
⑥ Mixed Content:xx was loaded over HTTPS,but requested http
Mixed Content: The page at "https://www.example.com/index.php?main_page=login" was loaded over HTTPS,
but requested an insecure stylesheet "http://www.example.com/site_map.html".
This request has been blocked; the content must be served over HTTPS.
RewriteCond %{SERVER_PORT} ^443$
RewriteRule (.*) http://www.example.com/$1
You don't allow SSL requests (443 port number is used for HTTPS requests). Try removing these lines.
2、php
①、安装完 Apache后 在 http.conf 中配置加载 PHP 文件
以 Apache 模块的方式安装 PHP,在文件 http.conf 中首先要用语句 LoadModule php5_module "e:/php/php5apache2.dll"动态装载PHP模块,
然后再用语句 AddType application/x-httpd-php .php 使得 Apache 把所有扩展名为 PHP 的文件都作为 PHP 脚本处理。