环境:xp sp3 、php5.2.9-2 apache2.2.11,mysql5.0.51a
1、下载php-5.2.9-2-Win32.zip、apache_2.2.11-win32-x86-no_ssl.msi
2、解压php-5.2.9-2-Win32.zip到d:\php-5.2.9-2-Win32,安装apahce2.2到d:apache2.2
3、查看D:\Apache2.2\conf\httpd.conf
相关信息显示如下:
ServerRoot "D:/Apache2.2"
Listen 8080
#这是设置WEB应用的根目录
DocumentRoot "D:/Apache2.2/htdocs"
DirectoryIndex index.html
4、把d:\php-5.2.9-2-Win32\php.ini-dist改为d:\php-5.2.9-2-Win32\php.ini
5、设置doc_root
doc_root = D:\Apache2.2\htdocs
6、在D:\Apache2.2\conf\httpd.conf中添加如下两行
LoadModule php5_module "D:/php-5.2.9-2-Win32/php5apache2_2.dll"
AddType application/x-httpd-php .php
7、在d:\apache2.2\htdocs下建文件test.php内容如下
<html>
<head><title>test</title></head>
<body>
<?php
phpinfo();
?>
</body>
</html>
8、运行D:\Apache2.2\bin\httpd.exe
9、打开http://localhost:8080/test.php
10、配置MYSQL
在环境变量path中增加:D:/php-5.2.9-2-Win32
使其能加载libmysql.dll和php5ts.dll。
11、修改httpd.conf,增加
PHPIniDir D:\php-5.2.9-2-Win32
12、修改php.ini
extension=php_mysql.dll
extension=php_mysqli.dll
========================
从D:/php-5.2.9-2-Win32/ext复制php_mysql.dll,php_mysqli.dll到D:/php-5.2.9-2-Win32g下,extension_dir = "./"保持不变
========================
重启机器
mysql的安装:
解压mysql到d:mysql
启动MYSQL:
D:\mysql\bin\mysqld --defaults-file=D:\mysql\my.ini
my.ini的内容如下
[mysqld]
basedir=d:\\mysql
datadir=d:\\mysql\\data
port=3306
key_buffer_size=10M
sort_buffer_size=4M
default-storage-engine=innodb
测试脚本:
1、运行d:\mysql\bin\mysql -u root -p
2、select database();
3、use databse_name; (jlx)
4、show tables;
启动apache httpd.exe
打开http://localhost:8080/test.php 会看到有mysql的配置信息,这时就能连接数据库了。
linux编译php
./configure --prefix=/home/web/soft/php-5.4.4 --with-apxs2=/home/web/soft/httpd2.4.2/bin/apxs --with-mysql --enable-gd-native-ttf --enable-inline-optimization --with-gd --enable-mbstring --with-png-dir --with-freetype-dir --with-gettext --with-jpeg-dir --with-mysqli --with-pdo-mysql --with-zlib