自己的PHP和apache安装步骤

第一步:yum安装一些需要使用的软件

# yum upgrade
# yum install –y ntp
# crontab -e
0 23 * * * /usr/sbin/ntpdate 210.72.145.44
以上命令设置好后存盘。
# /sbin/service crond reload

2、装GD库
# cd /usr/local/src
# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
# tar xzvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# yum install libtool libtool-ltdl
# aclocal
# ./configure –prefix=/usr/local/gd2 –mandir=/usr/share/man

# make //make 是用来编译的,它从 Makefile 中读取指令,然后编译。
# make install //make install 是用来安装的,它也从 Makefile 中读取指令,安装到指定的位置。

3、安装mysql
直接yum安装的

4、安装apache2

# cd /usr/local/src
# wget http://www.ip97.com/apache.org/httpd/httpd-2.2.6.tar.gz
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
先依次安装apr和apr-util
# cd srclib/apr
# ./configure –prefix=/usr/local/apr –enable-threads –enable-other-child –enable-static
# make && make install
# cd ../apr-util
#./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/ –with-mysql=/usr/lib/mysql
# make && make install

cd /usr/local/src/httpd-2.2.6
#./configure -prefix=/usr/local/apache2 -enable-mods-shared=all -with-mysql=/usr/lib/mysql -enable-cache -enable-file-cache -enable-mem-cache -enable-disk-cache -enable-static-support -enable-static-htpasswd -enable-static-htdigest -enable-static-rotatelogs -enable-static-logresolve -enable-static-htdbm -enable-static-ab -enable-static-checkgid  -with-apr=/usr/local/apr/ -with-apr-util=/usr/local/apr-util/ -enable-ssl -with-ssl=/usr/include/openssl -with-pcre  -enable-so -enable-suexec  -with-suexec-bin=/usr/local/apache2/bin/suexec -with-suexec-caller=apache -with-suexec-userdir=html -with-suexec-logfile=/usr/local/apache2/logs/suexec_log –with-suexec-docroot=/var/www

注解:
./configure //配置源代码树
–prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ,也就Apache的安装目录。
–enable-module=so //打开 so 模块,so 模块是用来提 DSO 支持的 apache 核心模块
–enable-mods-shared=all //编译全部的模板,对于不需要我们可以在httpd.conf去掉。
–enable-cache //支持缓存
–enable-file-cache //支持文件缓存
–enable-mem-cache //支持记忆缓存
–enable-disk-cache //支持磁盘缓存
–enable-static-support //支持静态连接(默认为动态连接)
–enable-static-htpasswd //使用静态连接编译 htpasswd – 管理用于基本认证的用户文件
–enable-static-htdigest //使用静态连接编译 htdigest – 管理用于摘要认证的用户文件
–enable-static-rotatelogs //使用静态连接编译 rotatelogs – 滚动 Apache 日志的管道日志程序
–enable-static-logresolve //使用静态连接编译 logresolve – 解析 Apache 日志中的IP地址为主机名
–enable-static-htdbm //使用静态连接编译 htdbm – 操作 DBM 密码数据库
–enable-static-ab //使用静态连接编译 ab – Apache HTTP 服务器性能测试工具
–enable-static-checkgid //使用静态连接编译 checkgid
–disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本
–disable-cgi //禁止编译 CGI 版本的 PHP
–enable-ssl // 编译 ssl模块。

将apache设置成开机自启动:
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache2/bin/apachectl start
这样每次重新启动系统以后,apache也会随系统一起启动.
或者将apache安装为系统服务
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 50 90
# description: Activates/Deactivates Apache Web Server
最后,运行chkconfig把Apache添加到系统的启动服务组里面:
# chkconfig –add httpd
# chkconfig httpd on

5、编译php 5.2.5

Suhosin是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。我个人强烈你建议安装成静态内核。Suhosin已经进入 Gentoo Linux、FreeBSD、OpenSuSE Linux、Mandriva Linux、Debian Linux官方包。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展。
# cd /usr/local/src
# wget http://cn.php.net/get/php-5.2.5.tar.gz/from/this/mirror
wget http://www.hardened-php.net/suhosin/_media/suhosin-patch-5.2.5-0.9.6.2.patch.gz
# tar zxvf php-5.2.5.tar.gz
# gunzip suhosin-patch-5.2.5-0.9.6.2.patch.gz
# cd php-5.2.5
# patch -p 1 -i ../suhosin-patch-5.2.5-0.9.6.2.patch
# ./buildconf –force
# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-pear=/usr/share/php –with-zlib-dir –with-bz2 –with-libxml-dir=/usr –with-gd=/usr/local/gd2 –enable-gd-native-ttf –enable-gd-jis-conv –with-freetype-dir –with-jpeg-dir –with-png-dir –with-ttf=shared,/usr –enable-mbstring –with-mysql=/usr/lib/mysql –with-mysqli=/usr/lib/mysql/mysql_config –with-config-file-path=/etc –with-iconv –disable-ipv6 –enable-static –enable-zend-multibyte –enable-inline-optimization –enable-zend-multibyte –enable-sockets –enable-soap –with-openssl –with-gettext –enable-suhosin
配置成功会提示:
+——————————————————————–+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+——————————————————————–+
Thank you for using PHP.
# make
# make test
# make install
# cp php.ini-recommended /etc/php.ini
# echo “/usr/local/php/lib” >> /etc/ld.so.conf && ldconfig

Leave a Reply

Your email address will not be published. Required fields are marked *