欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-11 09:06:12
...

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

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"

#限制用户访问文件的范围
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


#使Apache首先寻找php文件,增加index.php

DirectoryIndex index.php index.html


#rotatelogs按大小,时间来控制日志
ErrorLog "|D:/devsoft/apm/httpd-2.4.10-win64-VC11/Apache24/bin/rotatelogs.exe logs/error_%Y%m%d.log 5M 86400 +480"



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


# 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


  #使日志按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


#目录替换,这项作用还未知.

ScriptAlias /cgi-bin/ "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin\"


#目录替换

AllowOverride None
Options None
Require all granted


#我设置的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

#禁止访问指定扩展名文件

Order allow,deny
Deny from all


#指定php日志文件路径
php_value error_log D:\config_web\log\php_errors.log

#禁止访问日志

Order allow,deny
Deny from all
Satisfy All

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 后解决。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/962879.htmlTechArticlewin7下php环境配置(apache,php,mysql),win7apache win7是64位旗舰版。 安装包: php-5.6.3-Win32-VC11-x64.zip httpd-2.4.10-win64-VC11.zip mysql-5.6.22-winx64.zip 解压到...
相关标签: apache