php & apache 安装
时间:2005-02-03 来源:simonyang2008
0. 保证mysql已经安装.
=====================
假定mysql安装在 /data2/mysql 目录下.
1. 下载php & apache源码(在php网站 www.php.net 或者已知的路径),然后解压.
======================================================================
cd ~zhxu
fetch http://cn.php.net/distributions/php-4.3.6.tar.gz
rsync 202.106.184.186::apache/apache_1.3.27.tar.gz .
tar -zxvf php-4.3.6.tar.gz
tar -zxvf apache_1.3.27.tar.gz
2. 初始化编译 apache .
======================================================================
cd apache_1.3.27
./configure
3. 安装 php 模块. 并关联 mysql & apahce.
======================================================================
cd ../php-4.3.6
./configure --with-mysql=/data2/mysql --with-apache=../apache_1.3.27
make
make install
4. 编译安装 apache. 并关联 php.
======================================================================
cd ../apache_1.3.27
cp ../php-4.3.6/libs/libphp4.a src/modules/php4/libphp4.a
vi src/include/httpd.h
----------------------------------------------------------------------
#define HARD_SERVER_LIMIT 256
#define HARD_SERVER_LIMIT 4096
编译apache可以将所有某快编译成动态(dso)的和静态的
动态编译如下:
/*********************************************************************
./configure --enable-module=access --enable-module=actions --enable-module=alias --enable-module=asis --enable-module=auth --enable-module=auth_anon --enable-module=auth_db --enable-module=auth_dbm --enable-module=auth_digest --enable-module=autoindex --enable-module=cern_meta --enable-module=cgi --enable-module=digest --enable-module=dir --enable-module=env --enable-module=example --enable-module=expires --enable-module=headers --enable-module=imap --enable-module=include --enable-module=info --enable-module=log_agent --enable-module=log_config --enable-module=log_referer --enable-module=mime --enable-module=mime_magic --enable-module=mmap_static --enable-module=negotiation --enable-module=proxy --enable-module=rewrite --enable-module=setenvif --enable-module=so --enable-module=speling --enable-module=status --enable-module=unique_id --enable-module=userdir --enable-module=usertrack --enable-module=vhost_alias --enable-shared=access --enable-shared=actions --enable-shared=alias --enable-shared=asis --enable-shared=auth --enable-shared=auth_anon --enable-shared=auth_db --enable-shared=auth_dbm --enable-shared=auth_digest --enable-shared=autoindex --enable-shared=cern_meta --enable-shared=cgi --enable-shared=digest --enable-shared=dir --enable-shared=env --enable-shared=example --enable-shared=expires --enable-shared=headers --enable-shared=imap --enable-shared=include --enable-shared=info --enable-shared=log_agent --enable-shared=log_config --enable-shared=log_referer --enable-shared=mime --enable-shared=mime_magic --enable-shared=mmap_static --enable-shared=negotiation --enable-shared=proxy --enable-shared=rewrite --enable-shared=setenvif --enable-shared=speling --enable-shared=status --enable-shared=unique_id --enable-shared=userdir --enable-shared=usertrack --enable-shared=vhost_alias --prefix=/data1/apache --runtimedir=/data1/apache/var --logfiledir=/data1/apache/var/log --datadir=/data1/apache/share --activate-module=src/modules/php4/libphp4.a
*********************************************************************/
静态编译如下:
/*********************************************************************
vi src/Configuration.tmpl
----------------------------------------------------------------------
OPTIM=-O3 # 优化选项
# AddModule modules/standard/mod_env.o
# AddModule modules/standard/mod_negotiation.o
# AddModule modules/standard/mod_status.o
# AddModule modules/standard/mod_autoindex.o
# AddModule modules/standard/mod_asis.o
# AddModule modules/standard/mod_imap.o
# AddModule modules/standard/mod_actions.o
# AddModule modules/standard/mod_userdir.o
# AddModule modules/standard/mod_setenvif.o
./configure --prefix=/data1/apache --runtimedir=/data1/apache/var --logfiledir=/data1/apache/var/log --datadir=/data1/apache/share --activate-module=src/modules/php4/libphp4.a
*********************************************************************/
make
make install
vi /data1/apache/conf/httpd.conf
----------------------------------------------------------------------
添加下面两行
AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php-source .phps
对应修改下面
Timeout 120
MaxKeepAliveRequests 1024
MinSpareServers 70
MaxSpareServers 90
StartServers 80
MaxClients 2048
User www
Group www
ServerName 192.168.200.38
#CustomLog /data1/apache/var/log/access_log common
CustomLog /data1/apache/var/log/access_log combined
ServerSignature Off
替换 AddLanguage da .dk 之下的 37 行
:s/Add/#Add/37
5. 拷贝 php.ini 配置文件到 /etc/ 下.
======================================================================
cp ~zhxu/php-4.3.6/php.ini-dist /etc/php.ini
6. 测试 php 是否安装成功.
======================================================================
/data1/apache/bin/apachectl start
vi /data1/apache/share/htdocs/test.php
----------------------------------------------------------------------
<?
phpinfo()
?>
在浏览器中看是否可以正常显示 http://IP/test.php