search
HomeBackend DevelopmentPHP TutorialPHP environment configuration (apache, php, mysql) under win7, win7apache_PHP tutorial

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

 

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 解压到...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools