手动配置LAMP
1.首先准备一个干净的RHCE5主机,准备开发环境,用yum安装编译开发包:
#yum groupinstall "Development Libraries"
#yum groupinstall "Development Tools"
#yum groupinstall "X Software Development"
2.从网上下载LAMP所需要的源码包和二进制包:
httpd-2.2.16.tar.bz2
mysql-5.1.50-linux-i686-glibc23.tar.gz
php-5.3.2.tar.bz2
3.安装Mysql:
#tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz -C /usr/local
#cd /usr/local/
创建mysql用户和用户组:
#ln -sv mysql-5.1.50-linux-i686-glibc23 mysql
#groupadd -r mysql
#useradd -g mysql -s /sbin/nologin -M -r mysql
查看mysql用户信息:
#id mysql
uid=101(mysql) gid=104(mysql) groups=104(mysql) context=root:system_r:unconfined_t:SystemLow-SystemHigh
创建数据库数据存放的目录:
#mkdir -pv /mysql/data
修改文件目录的用户用户组为mysql
#cd mysql
#chown -R mysql:mysql .
#chown -R mysql:mysql /mysql/
启用脚本安装MySQL:
#scripts/mysql_install_db --user=mysql --datadir=/mysql/data
把除数据库数据部分目录用户的属主改回root:
#chown -R root .
拷贝MySQL主配置文件到/etc目录下,改名为my.cnf
#cp support-files/my-large.cnf /etc/my.cnf
#vim /etc/my.cnf
**************************************************************
[mysqld]
datadir = /mysql/data (添加)
**************************************************************
第一次启动MySQL:
#bin/mysqld_safe --user=mysql --datadir=/mysql/data &
修改PATH环境变量:
#vim /etc/profile
**************************************************************
PATH=$PATH:/usr/local/mysql/bin (添加)
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
**************************************************************
#. /etc/profile
把MySQL启动、重启、查看状态脚本拷贝到/etc/init.d/目录下:
#cp support-files/mysql.server /etc/init.d/mysqld
#service mysqld restart
#chkconfig --add mysqld
#chkconfig mysqld on
配置MySQL的链接库文件:
#vim /etc/ld.so.conf.d/mysql.conf
**************************************************************
/usr/local/mysql/lib (添加)
**************************************************************
#ldconfig -v
配置MySQL的头文件:
#ln -sv /usr/local/mysql/include /usr/include/mysql
4.安装Apache:
#tar jxvf httpd-2.2.16.tar.bz2
#cd httpd-2.2.16
#./configure
--prefix=/usr/local/apache
--sysconfdir=/etc/httpd
--enable-so
--enable-ssl
--with-ssl=/usr/local/ssl
--enable-track-vars
--enable-rewrite
--with-zlib
--enable-mods-shared=most
--enable-suexec
--with-suexec-caller=daemon
#make
#make install
使Apache开机时启动:
echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local
配置Apache的命令环境变量:
#vim /etc/profile
**************************************************************
PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin (修改)
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
**************************************************************
#. /etc/profile
创建网页存放目录:
#mkdir -pv /www/htdocs
修改Apache的主配置文件:
#vim /etc/httpd/httpd.conf
**************************************************************
DocumentRoot "/www/htdocs" (修改)
<Directory "/www/htdocs"> (修改)
**************************************************************
为Apache设置一个主页:
#echo "This is a Apache" > /www/htdocs/index.html
配置Apache的man文档:
#vim /etc/man.config
**************************************************************
MANPATH /usr/local/apache/man (添加)
**************************************************************
5.安装PHP:
#tar jxvf php-5.3.2.tar.bz2
#cd php-5.3.2
#mkdir -pv /usr/local/php
#./configure --prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-xml
--with-png
--with-jpeg
--with-zlib
--with-freetype
--with-gd
--enable-track-vars
--enable-mbstring=all
#make
#make install
拷贝php的主配置文件到/usr/local/php/lib目录下:
#cp php.ini-development /usr/local/php/lib/php.ini
6.配置Apache使之支持PHP:
# vi /etc/httpd/httpd.conf
进行如下修改:
************************************************************
AddType application/x-httpd-php .php (添加)
AddType application/x-httpd-php-source .phps (添加)
DirectoryIndex index.php index.html (修改)
************************************************************
7.重启MySQL和httpd服务,测试PHP是否连接成功:
#apachectl restart
#service mysqld restart
验证php安装成功:
#cd /www/htdocs/
#mv index.html index.php
#vim index.php
***********************************************************
<?php
phpinfo();
?>
***********************************************************
然后用浏览器打开主页,若显示php的介绍则表示php链接Apache成功
之后在修改此文件:
#vim index.php
***********************************************************
<?php
$Link=mysql_connect('localhost''root''123456');
if ($LINK)
echo "Success......";
else
echo "Failure......";
?>
***********************************************************
在mysql服务启动时,浏览器打印出"Success......"则表示php链接mysql成功.