适用环境:RHEL5.9/5.10 x86_64
—— 准备工作:
[root@mail~]# yum -y install openssl-devel
[root@mail~]# yum -y install ncurses-devel libtermcap-devel
[root@mail~]# yum -y install libxml2-devel
[root@mail~]# yum -y remove httpd mysql-server mysql php-mysql
############################### START ######################
1. 编译安装 httpd
1)安装
[root@mail~]# tar zxf /软件包路径/httpd-2.2.26.tar.gz -C /usr/src/
[root@mail~]# cd /usr/src/httpd-2.2.26/
[root@mailhttpd-2.2.26]# ./configure --prefix=/usr/local/httpd \
--enable-so --enable-rewrite --enable-cgi \
--enable-charset-lite --enable-ssl \
--enable-suexec \
--with-suexec-caller=daemon \
--with-suexec-docroot=/usr/local/httpd/htdocs
[root@mailhttpd-2.2.26]# make
[root@mailhttpd-2.2.26]# make install
2)建立 httpd 控制脚本(注意添加chkconfig识别参数)
[root@mail~]# cp -f /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@mail~]# vim /etc/init.d/httpd
#!/bin/bash
#chkconfig: 35 85 15
#description: Apache is a World Wide Web Server
.. ..
[root@mail~]# chmod +x /etc/init.d/httpd
[root@mail~]# chkconfig --add httpd
2. 编译安装 mysql (可以与 httpd 安装同时进行)
1)准备mysql运行账户
[root@mail~]# useradd -M -u 49 -s /sbin/nologin mysql
2)安装
[root@mail~]# tar zxf /软件包路径/mysql-5.1.62.tar.gz -C /usr/src/
[root@mail~]# cd /usr/src/mysql-5.1.62/
[root@mailmysql-5.1.62]# ./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312
[root@mailmysql-5.1.62]# make
[root@mailmysql-5.1.62]# make install
[root@mailmysql-5.1.62]# cd /usr/local/mysql/
[root@mailmysql]# bin/mysql_install_db --user=mysql
3)调整mysql目录权限
[root@mail~]# chown -R root:mysql /usr/local/mysql/
[root@mail~]# chown -R mysql /usr/local/mysql/var/
4)建立my.cnf配置文件
[root@mail~]# cp -f /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
[root@mail~]# vim /etc/my.cnf
#skip-locking
skip-external-locking
.. ..
5)mysql执行优化、添加库路径
[root@mail~]# ln -sf /usr/local/mysql/bin/* /usr/local/bin/
[root@mail~]# vim /etc/ld.so.conf.d/mysql-64.conf
/usr/local/mysql/lib/mysql
[root@mail~]#ldconfig
6)建立 mysqld 服务控制脚本
[root@mail~]# cp -f /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[root@mail~]# chmod +x /etc/init.d/mysqld
[root@mail~]# chkconfig --add mysqld
3. 编译安装 php
1)安装
[root@mail~]# tar zxf /软件包路径/php-5.4.24.tar.gz -C /usr/src/
[root@mail~]# cd /usr/src/php-5.4.24/
[root@mailphp-5.4.24]# ./configure --prefix=/usr/local/php\
--enable-mbstring --enable-sockets \
--with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php
[root@mailphp-5.4.24]# make
[root@mailphp-5.4.24]# make install
2)启用httpd的PHP网页支持
[root@mail~]# vim /usr/local/httpd/conf/httpd.conf
.. ..
LoadModule php5_module modules/libphp5.so
<IfModuledir_module>
DirectoryIndex index.html index.php
</IfModule>
AddType application/x-httpd-php .php
.. ..
4. 启动LAMP平台、测试
[root@mail~]# service mysqld restart
[root@mail~]# service httpd restart
[root@svr5~]# vim /usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘1234567‘);
if($link) echo "Success !!";
else echo "Failure !!";
mysql_close();
?>
从浏览器访问http://服务器地址/test2.php,应显示“Success!!”
############################### END ######################################
原文地址:http://kupig.blog.51cto.com/8929318/1580196