欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 本来想学学php,于是就想搭建web服务器和sql环境,结果浪费掉了不少时间。 大致的总结下,也算是长个记性。 使用的安装包分别是httpd-2.2.22-win32-x86-no_ssl .msi,php-5.2.5-Win32.zip和mysql-ins
欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入
本来想学学php,于是就想搭建web服务器和sql环境,结果浪费掉了不少时间。
大致的总结下,也算是长个记性。
使用的安装包分别是httpd-2.2.22-win32-x86-no_ssl .msi,php-5.2.5-Win32.zip和mysql-installer-community-5.5.28.3.msi,很显然用的还算是比较新的安装包。安装apache还是比较顺利的,一路安装下来,默认监听本机所有ip的80端口,当然包括回环地址, 接着解压php到指定文件夹,接着安装mysql,打开安装目录下的httpd.conf文件,做如下调整:
ServerRoot "D:/Apache2.2" 服务器安装根目录
DocumentRoot "D:/phpWeb" 修改为自己的网站根目录
# This should be changed to whatever you set DocumentRoot to.
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
DirectoryIndex index.php index.html
LoadModule php5_module "D:/php/php5apache2_2.dll" 以模块的方式加载php,注意此处的php5apache2_2.dll对应的apache 版本
LoadFile "D:/php/php5ts.dll" 手动加载php动态链接库 或者 把这两个文件放到system32文件目录下
LoadFile "D:/php/libmysql.dll" 加载mysql动态链接库
PHPIniDir "D:/php" 非必要的配置
AddType application/x-httpd-php .php .html .htm 服务器端支持动态文件类型
保存修改后,测试apache,重启apache服务器,在浏览器中输入localhost or 回环地址,页面显示 "It works !"到此说明,apache工作了。
测试php,在phpWeb目录里编辑一个index.php 的文件,内容为,重复测试apache服务器的操作,页面显示php的配置信息,查看是否包括sql模块,很想然没有,因为php默认是不加载mysql模块的。然后修改php.ini 文件,主要改动点如下:
extension_dir = "D:/php/ext" 扩展dll库的位置
……
extension=php_mysql.dll 打开mysql的扩展
对于php.ini的修改相当郁闷,网上找了很多也做了各种修改,似懂非懂的就去尝试,后来都不管用。 想想mysql是否安装成功呢,开始用命令行查看,先看端口3306端口是否处于监听状态,使用netstat -a命令,再使用mysql workbench 测试与数据库的连接是否成功,结果成功说明mysql安装没有问题,mysql 的配置文件是my.ini ,暂时不用动,默认的配置可以工作。 于是问题出在php与mysql的衔接处,问题肯定出在php.ini文件。
开查php.ini,还是先看看phpinfo()给出的信息吧,看来看去怎么没有mysql模块,开始怀疑我之前是否打开了配置信息里的mysql 扩展。God,打开的竟然是extension=php_mssql.dll.此处省略无数字。
Wahtever, 问题总算找到,测试一下,瞬间OK,欲哭无泪。但是回顾整个过程,时间主要浪费在了细小的错误上。 总结教训: 面对问题不能不问百度google闭门造车但也不能盲信盲从 ; 面对问题更多的是持续关注问题,自己分析问题。
下一步详细分析httpd.conf php.ini my.ini ,灵活配置,并对web服务器和数据库服务器进行性能调优,然后移植网站到新崛起的Nginx web服务器等。貌似有点偏题了,当然主要目的还是学习可爱的PHP.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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