Home >php教程 >php手册 >静态和动态编译Apache+php+mysql全过程

静态和动态编译Apache+php+mysql全过程

WBOY
WBOYOriginal
2016-06-21 09:00:43921browse

静态/动态编译Apache+php+mysql

所需软件:

apache:1.3.27

php: 4.3.2

mysql:4.0.13

首先来安装mysql

tar zvxf mysql-4.0.13.tar.gz

cd mysql-4.0.13

./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql

make

make install

安装完成。

然后初始化数据库

/usr/local/mysql/bin/mysql_install_db --user=mysql

设置权限:

chown -R root /usr/local/mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql

复制配置文件;

cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

启动mysql:

/use/local/mysql/bin/mysqld_safe --user=mysql &

修改密码:初始的root密码是空的

/usr/local/mysql/bin/mysqladmin -u root -p password 123456

enter password:

把密码修改为123456,由于初始密码为空,所以enter password直接回车就行

测试一下新的密码:

mysql -u root -p mysql

enter password:123456

如果顺利的话就能进入mysql。

首先是apache1.3.29+php4.3.4+mysql4.0.13的静态编译

apache第一次编译,并不要安装,因为php的编译需要apache至少已经编译过一次

tar zvxf apache_1.3.27.tar.gz

cd apache_1.3.27

./configure --prefix=/usr/local/apache

编译php

tar zvxf php4.3.4.tar.gz

cd php4.3.4

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql \

--with-apache=../apache_1.3.27

make

make install

第二次编译安装apache:

<ccid_code>cd ../apache_1.3.29./configure --prefix=/usr/local/apache \ --activate-module=src/modules/php4/libphp4.a makemake install cp ../php4.3.4/php.ini.dist /usr/local/php/lib/php.ini 修改/usr/local/apache/conf/httpd.conf 查找<ifmodule mod_mime.c></ifmodule></ccid_code>

在此范围添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

注意:apache和php的源码包在同一个目录,--with-apache=../apache_1.3.27是指向源码解压的目录

ok!静态编译完成,大家只要启动一下服务器

/usr/local/apache/bin/apachectl start

然后些个php测试页info.php:内容如下 :

<ccid_code> phpinfo(); ?></ccid_code>

正常的话,应该能看到php的信息了,那么静态编译成功!

下面讲讲DSO动态编译的方法:

首先编译安装apache

tar zvxf apache_1.3.29

cd apache_1.3.29

./configure --prefix=/usr/local/apache --enable-module=so \

--enable-module=rewrite

make

make install

so模块用来提供DSO支持的apachehe核心模块,rewrite是地址重写的模块,如果不需要可以不编译

enable-shared=max是指除了so以外的所有标准模块都编译成DSO模块。

然后编译php

tar zvxf php4.3.4.tar.gz

cd php4.3.2

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql \

--with-apxs=/usr/local/apache/bin/apxs

make

make install

然后修改httpd.conf,方法同静态编译的方法

OK,动态编译就完成了,中间有什么区别大家应该看的很清楚了吧!



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