PHP开发实例大全(提高卷) 中文完整pdf扫描版[244MB]
-
配置Apache+PHP+MySQL配置文件
------------------------
配置环境:
操作系统:虚拟机的WIN2003
Apache的版本:2.2
MySQL的版本:5.0
------------------------
查看phpinfo()函数的结果:
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File (none)
Scan this dir for additional .ini files (none)
additional .ini files parsed (none)
...
Apache根本就没有加载PHP.ini,所以不管怎么修改都是没有用的
Fatal error: Call to undefined function mysql_connect()
PHP调用MYSQL的问题,其实也是因为PHP.ini的原因。
==>Apache的httpd.conf配置文件:LoadModule php5_module E:/PHP/php5apache2_2.dll
(解析PHP用的,使用的是php5apache2_2.dll)
PHPIniDir "E:/PHP"
(PHP.ini配置文件所在目录)添加对php的支持
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html目录访问权限的设置
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory><Directory "D:/www">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory><Directory "E:/">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>加载一些自己需要的配置文件:
# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf
(设置一些进程数,客户端连接数之类的)
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
(虚拟主机或域名的设置)
例如:
<VirtualHost *:80>
DocumentRoot "D:/www/a/"
ServerName a.com
</VirtualHost><IfModule dir_module>
DirectoryIndex index.html index.html.var index.php
</IfModule>==>PHP.ini配置文件
doc_root ="D:\www" (测试站点目录)extension_dir = "E:\PHP\ext" (就是以下dll文件所在目录)
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
把需要的dll去掉分号注释,基本配置就这样,我第一次配置的时候越配置越复杂,越搞不定,很难与MySQL关联libmcrypt.dll
libmhash.dll
libmysql.dll
php5ts.dll
php_gd2.dll
php_mbstring.dll
php_mysql.dll
网上很多说需要把以上的dll复制到System32下面,不过我删除了,重启电脑,都可以正常运行,因为你在PHP.ini里面已经配置好了它的目录。这样配置好了后,也不用设置环境变量(网上有说环境变量,我设置过,可能和配置文件里配置了发生冲突[猜测],没做更多测试了)
配置好了的PHP.ini也不需要复制到WINDOWS文件夹下面,因为PHPIniDir已经指定了其所在目录。
==>MySQL的一点配置,更改数据库的保存目录【DiscuzX安装的配置】
打开X:\Server_Core\MySQL\my.ini,
找到:Datadir = “X:\Server_Core\MySQL\data”
修改为:Datadir = “X:\Database”将X:\Server_Core\MySQL\data 文件夹复制到X:\,并重命名X:\Database;
打开cmd命令提示符窗口,输入命令:net start mysql 启动MySQL服务。
重新测试MySQL是否工作正常。
命令行式的操作MySQL,请参看:http://www.rczjp.cn/HTML/110223/20112223032214.html移动LibMySQL动态链接库到系统目录
将X:\Server_Core\MySQL\bin\libmySQL.dll 文件复制到 C:\Windows\System32目录下。
其他一些信息:
Apache重启不了的错误日志:
the requested operation has failed
Apache启动不了,查看错误日志:
Apache 指定的网络名不再可用。 : winnt_accept: Asynchronous AcceptEx failed.
Could not reliably determine the server's fully qualified domain name
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.110.119.195 for ServerName
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.110.119.195 for ServerName
[Fri Feb 25 11:10:32 2011] [notice] Child 3428: All worker threads have exited.
[Fri Feb 25 11:10:32 2011] [notice] Child 3428: Child process is exiting解决:
查看占用的端口:netstat -ano 80端口是否是其他程序给占用了
清空winsock:netsh winsock reset 电脑重启
删除httpd.pid(这个不删除不确定可以成功,我是删除了的,里面就是一个PID,80端口的)
如果实在没有办法的话,就直接重启电脑,再搞,在重启电脑再搞,搞了好几天才搞定。
安装DiscuzX的时候需要打开short_open_tag = On,启用短标签。
好了,我们打开页面,再查看phpinfo()函数System Windows NT LANMANG-F93194A 5.2 build 3790
Build Date Jan 6 2011 17:26:08
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-
sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" "--without-pi3web"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File D:\Server_Core\PHP\php.ini
...可以看到PHP.ini已经给加载进来了,成功!
转载请注明:谷谷点程序 » 配置Apache+PHP+MySQL配置文件