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,修改如下:
<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 "D:\config_web\php_web_sum\php_web"></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></Directory></span><br /><br /><span>#使Apache首先寻找php文件,增加index.php<br /><span><IfModule dir_module></span><br /><span> DirectoryIndex index.php index.html</span><br /><span></IfModule></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></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></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> </IfModule></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></IfModule></span><br /><br /><span>#目录替换,这项作用还未知.<br /><span><IfModule alias_module></span><br /><span> ScriptAlias /cgi-bin/ "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin\"</span><br /><span></IfModule></span><br /><br /><span>#目录替换<br /><span><Directory "D:\devsoft\apm\httpd-2.4.10-win64-VC11\Apache24\cgi-bin"></span><br /><span> AllowOverride None</span><br /><span> Options None</span><br /><span> Require all granted</span><br /><span></Directory></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 ~ "(.*)\.(exe|inc|log|sh|py|pyc|h|c)$"></span><br /><span> Order allow,deny</span><br /><span> Deny from all</span><br /><span></Files></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 "D:\config_web\log\php_errors.log"></span><br /><span> Order allow,deny</span><br /><span> Deny from all</span><br /><span> Satisfy All</span><br /><span></Files> </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 后解决。
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章
刺客信条阴影:贝壳谜语解决方案
1 个月前ByDDD
Windows 11 KB5054979中的新功能以及如何解决更新问题
3 周前ByDDD
在哪里可以找到原子中的起重机控制钥匙卡
1 个月前ByDDD
如何修复KB5055523无法在Windows 11中安装?
2 周前ByDDD
Inzoi:如何申请学校和大学
3 周前ByDDD

热工具

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

SublimeText3 Linux新版
SublimeText3 Linux最新版

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),