win7是64位旗舰版。 安装包: php-5.6.3-Win32-VC11-x64.zip httpd-2.4.10-win64-VC11.zip mysql-5.6.22-winx64.zip 解压到相应的路径。 1.php 复制php.ini-production,并改名为php.ini,修改如下: ; 隐藏PHP版本号 expose_php = Off ; php扩充库目录 exte
win7是64位旗舰版。
安装包:
php-5.6.3-Win32-VC11-x64.zip
httpd-2.4.10-win64-VC11.zip
mysql-5.6.22-winx64.zip
解压到相应的路径。
1.php
复制php.ini-production,并改名为php.ini,修改如下:
<span>;<span>隐藏PHP版本号 <span>expose_php =</span><span> Off <span>;<span>php扩充库目录 <span>extension_dir = "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64\ext"</span> <span>;<span>以下extension=xxx,根据需要打开相应的.我打开以下几项. <span>extension=</span><span>php_curl.dll extension=<span>php_gd2.dll extension=<span>php_mbstring.dll extension=<span>php_mysql.dll extension=<span>php_pdo_mysql.dll extension=<span>php_xmlrpc.dll <span>;<span>时区 <span>date.timezone =</span><span> Asia/Shanghai <span>;<span>SESSION保存目录 <span>session.save_path = "D:\config_web\session_home"</span> <span>;<span>上传文件时使用的临时目录 <span>upload_tmp_dir = "D:\config_web\upload_home"</span> <span>;<span>禁用的函数,先禁用,以后用再打开. <span>disable_functions = phpinfo,exec,passthru,popen,proc_open,shell_exec,system,assert,chroot,getcwd,scandir,unlink,delete,rmdir,rename,chgrp,chmod,chown,fopen,copy,mkdir,file,file_get_contents,fputs,fwrite,dir</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
2.apache
备份原来的httpd.conf,修改如下:
<span>#apache路径<br><span>ServerRoot "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24"</span><br><br><span>#在LoadModule vhost_alias_module modules/mod_vhost_alias.so<br><span>#下面增加3行,增加对php模块的支持,php.ini文件位置,由php处理的文件类型(.php .html .htm)<br><span>LoadModule php5_module "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64\php5apache2_4.dll"</span><br><span>PHPIniDir "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64"</span><br><span>AddType application/x-httpd-php .php .html .htm</span><br><br><span>#url重写模块,我做了简单的测试<br><span>LoadModule rewrite_module modules/mod_rewrite.so</span><br><br><span>#解决httpd.exe: Could not reliably determine the server's fully qualified domain name<br><span>ServerName localhost:80</span><br><span>Listen 80</span><br><br><span>#web程序目录<br><span>DocumentRoot "D:\config_web\php_web_sum\php_web"</span><br><span><directory></directory></span><br><span>#限制用户访问文件的范围<br><span>php_admin_value open_basedir "D:\config_web\php_web_sum\php_web\;D:\config_web\log\;D:\config_web\upload_home\;D:\config_web\session_home\;D:\config_web\upload_home_tmp\"</span><br><br><span> #Options Indexes FollowSymLinks<br><span> #Indexes 去掉,防止从web浏览目录<br><span> Options FollowSymLinks</span><br><span></span><br><br><span>#使Apache首先寻找php文件,增加index.php<br><span><ifmodule dir_module></ifmodule></span><br><span> DirectoryIndex index.php index.html</span><br><span></span><br><br><span>#rotatelogs按大小,时间来控制日志<br><span>ErrorLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/error_%Y%m%d.log 5M 86400 +480"</span><br><br><span><ifmodule log_config_module></ifmodule></span><br><br><span> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined</span><br> <span>#此处,我修改了日期记录格式. <span>%t <span>=></span> <span>%{[%Y-%m-%d %H:%M:%S]}t<br><span> LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t \"%r\" %>s %b" common</span><br><span> </span><br><span> <ifmodule logio_module></ifmodule></span><br><span> # You need to enable mod_logio.c to use %I and %O</span><br><span> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio</span><br><span> </span><br><br> <span>#使日志按5M,天为单位进行分割,同时日志文件名称改为以日期结尾.<br><span> CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/access_%Y%m%d.log 5M 86400 +480" common</span><br><span> LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t %{Referer}i -> %U" referer</span><br><span> CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/referer_%Y%m%d.log 5M 86400 +480" referer</span><br><span> LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t %{User-agent}i" agent</span><br><span> CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/agent_%Y%m%d.log 5M 86400 +480" agent</span><br><span></span><br><br><span>#目录替换,这项作用还未知.<br><span><ifmodule alias_module></ifmodule></span><br><span> ScriptAlias /cgi-bin/ "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin\"</span><br><span></span><br><br><span>#目录替换<br><span><directory></directory></span><br><span> AllowOverride None</span><br><span> Options None</span><br><span> Require all granted</span><br><span></span><br><br><span>#我设置的403,404页面<br><span>ErrorDocument 404 /missing.php</span><br><span>ErrorDocument 403 /forbidden.php</span><br><br><span>#php_flag和php_value设置php.ini中的内容<br><span>php_flag display_startup_errors off</span><br><span>php_value display_errors off</span><br><span>php_value error_reporting 2047</span><br><span>php_flag log_errors on</span><br><br><span>#简单测试了下url重写<br><span>RewriteEngine on</span><br><span>RewriteRule ^(.*).html$ /$1.php</span><br><br><span>#隐藏apache版本号<br><span>ServerSignature Off</span><br><span>ServerTokens Prod</span><br><br><span>#禁止访问指定扩展名文件<br><span><files></files></span><br><span> Order allow,deny</span><br><span> Deny from all</span><br><span></span><br><br><span>#指定php日志文件路径<br><span>php_value error_log D:\config_web\log\php_errors.log</span><br><br><span>#禁止访问日志<br><span><files></files></span><br><span> Order allow,deny</span><br><span> Deny from all</span><br><span> Satisfy All</span><br><span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
3.mysql
复制my-default.ini,并重命名为my.ini,修改如下:
<span><span>[mysqld]<br><span># set basedir to your installation path</span> basedir=D:\devsoft\apm\mysql-5.6.22-winx64 <span># set datadir to the location of your data directory <span>datadir=D:\devsoft\apm\mysql-5.6.22-winx64\data</span> <span>#mysql时间数据类型的设置 <span>explicit_defaults_for_timestamp=TRUE sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES</span> <br><span>#编码设置 <span>character-set-server=utf8</span> [mysql]<br><span>default-character-set=utf8</span></span></span></span></span></span>
记录下配置,主要是目录,apache支持php,还有权限的配置。
发现问题请及时指出,我会及时修改。
apache启动失败,安装 vcredist_x64.exe。
apache启动失败,缺少libssh2.dll,把libssh2.dll 复制到 C:\Windows\SysWOW64 后解决。