·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> php网站开发 >> win7下php环境配置(apache,php,mysql)

win7下php环境配置(apache,php,mysql)

作者:佚名      php网站开发编辑:admin      更新时间:2022-07-23
Win7下php环境配置(apache,php,MySQL)

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.dllextension=php_gd2.dllextension=php_mbstring.dllextension=php_mysql.dllextension=php_pdo_mysql.dllextension=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 nameServerName localhost:80Listen 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.phpErrorDocument 403 /forbidden.php#php_flag和php_value设置php.ini中的内容php_flag display_startup_errors offphp_value display_errors offphp_value error_reporting 2047php_flag log_errors on#简单测试了下url重写RewriteEngine onRewriteRule ^(.*).html$ /$1.php#隐藏apache版本号ServerSignature OffServerTokens 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,denyDeny from allSatisfy All</Files>

3.mysql

复制my-default.ini,并重命名为my.ini,修改如下:

[mysqld]# set basedir to your installation pathbasedir=D:\devsoft\apm\mysql-5.6.22-winx64# set datadir to the location of your data directorydatadir=D:\devsoft\apm\mysql-5.6.22-winx64\data#mysql时间数据类型的设置explicit_defaults_for_timestamp=TRUEsql_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 后解决。