Linux下源码编译安装apache2,PHP5,mysq5的方法
#apache
./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
make
make install
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
cd /etc/rc.d/init.d
#vi httpd
#在文件首部#!/bin/bash行下,加入以下几行
# chkconfig: 2345 50 40
# description: This is a Internet www Server
#说明一下,直接调用chkconfig是不行的,必须加上以上两行。
#description是描述这个服务用的,一定要写上对服务的描述,而且不可以是中文的,
#chkconfig: 第一组数字是系统运行级2345表示的是将要设为启动的系统运行级别
#第二个数字是优先级,00优先级最高,当然考虑到依赖性,你的服务的优先级不宜过高
#如果,比自己依赖的服务的优先级更高,那么您的服务将无法正常启动
#第三组数字就是杀死服务的优先级
chkconfig --add httpd
#mysql
./configure --prefix=/usr/local/mysql --localstatedir=/mydata/web/mysql --with-charset=utf8 --with-extra-charsets=all
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
#创建mysql用户和用户组
groupadd mysql
useradd -g mysql mysql
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R mysql /var/mysql
#初始化权限数据库,并不需要启动mysql
scripts/mysql_install_db --user=mysql
#启动mysql, "&"是后台运行
/usr/local/mysql/bin/mysqld_safe --user=mysql&
#更改root密码
/usr/local/mysql/bin/mysqladmin -u root -p password "123456"
#设置为开机自启动
cd /etc/rc.d/init.d
cp /usr/local/mysql/share/mysql/ mysql.server mysqld
chmod +x mysqld
chkconfig --add mysqld
#PHP
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache/bin/apxs --with-gd --with-zlib --with-png --with-freetype-dir --with-config-file-path=/usr/local/php/etc --enable-gd-native-ttf --with-ttf --enable-memory-limit --enable-zend-multibyte --disable-ipv6 --disable-path-info-check --with-iconv --disable-debug --with-mail --enable-mbregex --with-curl --enable-mbstring=all --enable-zip --enable-exif --with-jpeg-dir=/usr/lib64/
make
make install
#配置apache
# vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#开放80端口
#iptables -A INPUT -i eth0 -p TCP --dport 80 -j ACCEPT