windows下php7+apache2.4服务常规配置
一、php下载安装(php官网下载地址)
解压文件到 D:/php7,并修改php.ini 配置文件
模块目录配置
extension_dir = "*D:/php7/ext*"
sys_temp_dir = "C:/Windows/Temp"
开启常用模块
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
extension=php_xsl.dll
配置时区
date.timezone =PRC
开启短标签
short_open_tag = On
Header隐藏PHP版本号
expose_php = Off
网络请求认证配置(curl: (60) SSL certificate problem: unable to get local issuer certificate 错误)
curl.cainfo ="D:\php7\ca-bundle.crt"
ca-bundle.crt 下载地址,下载后请将文件ca-bundle.crt放至D:\php7目录下
二、apache2.4下载(请前往官网下载),请在下载页面同时下载vc运行库。请注意区分版本
1、vc运行库安装完毕
2、apache2.4 安装
解压文件到 D:/Apache24,并修改 httpd.conf 配置文件
Define SRVROOT "D:/Apache24"
Listen 80
ServerAdmin 123@qq.com
ServerName localhost:80
开启模块
LoadModule deflate_module modules/mod_deflate.so
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so
使用X-Frame-Options防止网页被Frame的解决方法
Header always append X-Frame-Options SAMEORIGIN
加载php模块
LoadFile "D:/php7/libssh2.dll"
LoadModule php7_module "D:/php7/php7apache2_4.dll"
PHPIniDir "D:/php7"
dir_module
DirectoryIndex index.html index.php index.htm
mime_module
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
Virtual hosts
AddType application/x-httpd-php .phpInclude conf/extra/httpd-vhosts.conf
deflate_module(网页内容压缩)
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/svg+xml
#headers_module
Header set Vary User-Agent
Header set X-Powered-By XXXXX
#隐藏Apache版本号
ServerTokens Prod
ServerSignature Off
Virtual hosts虚拟机配置,修改D:\Apache24\conf\extra\httpd-vhosts.conf 配置文件