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擴充庫目錄 extension_dir = "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64\ext" ;以下extension=xxx,根據需要打開相應的.我打開以下幾項. extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll ;時區 date.timezone = Asia/Shanghai ;SESSION保存目錄 session.save_path = "D:\config_web\session_home" ;上傳文件時使用的臨時目錄 upload_tmp_dir = "D:\config_web\upload_home" ;禁用的函數,先禁用,以後用再打開. 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
2.apache
備份原來的httpd.conf,修改如下:
#apache路徑
ServerRoot "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24"
#在LoadModule vhost_alias_module modules/mod_vhost_alias.so
#下面增加3行,增加對php模塊的支持,php.ini文件位置,由php處理的文件類型(.php .html .htm)
LoadModule php5_module "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64\php5apache2_4.dll"
PHPIniDir "D:\devsoft\apm\php-5.6.3-Win32-VC11-x64"
AddType application/x-httpd-php .php .html .htm
#url重寫模塊,我做了簡單的測試
LoadModule rewrite_module modules/mod_rewrite.so
#解決httpd.exe: Could not reliably determine the server's fully qualified domain name
ServerName localhost:80
Listen 80
#web程序目錄
DocumentRoot "D:\config_web\php_web_sum\php_web"
<Directory "D:\config_web\php_web_sum\php_web">
#限制用戶訪問文件的范圍
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\"
#Options Indexes FollowSymLinks
#Indexes 去掉,防止從web浏覽目錄
Options FollowSymLinks
</Directory>
#使Apache首先尋找php文件,增加index.php
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
#rotatelogs按大小,時間來控制日志
ErrorLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/error_%Y%m%d.log 5M 86400 +480"
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
#此處,我修改了日期記錄格式. %t => %{[%Y-%m-%d %H:%M:%S]}t
LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#使日志按5M,天為單位進行分割,同時日志文件名稱改為以日期結尾.
CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/access_%Y%m%d.log 5M 86400 +480" common
LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t %{Referer}i -> %U" referer
CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/referer_%Y%m%d.log 5M 86400 +480" referer
LogFormat "%h %l %u %{[%Y-%m-%d %H:%M:%S]}t %{User-agent}i" agent
CustomLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/agent_%Y%m%d.log 5M 86400 +480" agent
</IfModule>
#目錄替換,這項作用還未知.
<IfModule alias_module>
ScriptAlias /cgi-bin/ "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin\"
</IfModule>
#目錄替換
<Directory "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
#我設置的403,404頁面
ErrorDocument 404 /missing.php
ErrorDocument 403 /forbidden.php
#php_flag和php_value設置php.ini中的內容
php_flag display_startup_errors off
php_value display_errors off
php_value error_reporting 2047
php_flag log_errors on
#簡單測試了下url重寫
RewriteEngine on
RewriteRule ^(.*).html$ /$1.php
#隱藏apache版本號
ServerSignature Off
ServerTokens Prod
#禁止訪問指定擴展名文件
<Files ~ "(.*)\.(exe|inc|log|sh|py|pyc|h|c)$">
Order allow,deny
Deny from all
</Files>
#指定php日志文件路徑
php_value error_log D:\config_web\log\php_errors.log
#禁止訪問日志
<Files "D:\config_web\log\php_errors.log">
Order allow,deny
Deny from all
Satisfy All
</Files>
3.mysql
復制my-default.ini,並重命名為my.ini,修改如下:
[mysqld]
# set basedir to your installation path basedir=D:\devsoft\apm\mysql-5.6.22-winx64 # set datadir to the location of your data directory datadir=D:\devsoft\apm\mysql-5.6.22-winx64\data #mysql時間數據類型的設置 explicit_defaults_for_timestamp=TRUE sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#編碼設置 character-set-server=utf8 [mysql]
default-character-set=utf8
記錄下配置,主要是目錄,apache支持php,還有權限的配置。
發現問題請及時指出,我會及時修改。
apache啟動失敗,安裝 vcredist_x64.exe。
apache啟動失敗,缺少libssh2.dll,把libssh2.dll 復制到 C:\Windows\SysWOW64 後解決。