1、解压软件包:
#tar xf mysql-5.5.20-linux2.6-i686.tar.gz -C /usr/local
#ln -sv mysql-5.5.20-linux2.6-i686 mysql
#cd /usr/local/mysql
2、初始化数据库
#chown mysql:mysql ./*
#scripts/mysql_install_db --user=mysql --datadir=/mydata/data
#chown -R root ./*
3、为mysql提供主配置文件:
#cd /usr/local/mysql
#cp support-files/my-large.cnf /etc/my.cnf
并修改此文件中thread_concurrency 的值为你的CPU个数乘以2
添加mysql数据文件的存放位置:
datadir = /mydata/data
4、为mysql 提供sysv服务脚本:
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
5、添加至服务列表:
#chkconfig --add mysqld
#chkconfig mysql on
6、输出mysql的man手册至man命令的查找路径:
编辑/etc/man.config 添加此行:
MANPATH /usr/local/mysql/man
7、输出mysql的头文件至系统头文件路径 /usr/include:
#ln -sv /usr/local/mysql/include /usr/include/mysql
8、输出mysql的库文件给系统库查找路径:
#echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
系统重新载入系统库:
#ldconfig
9、修改PATH环境变量,让系统可以直接使用mysql的相关命令
#vim /etc/profile
PATH=$PAHT:/usr/local/mysql/bin
#source /etc/profile
10、启动服务并为mysql的root用户的本地登录设置密码;
#service mysqld start
#mysqladmin -u root -h localhost -p password “PASSWORD”
四、编译安装php-5.3.10
解决依赖关系
# yum -y groupinstall "X Software Development"
#rpm -ivh libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm
为了使php支持mcrypt扩展
编译
# tar xf php-5.3.10.tar.bz2
# cd php-5.3.10
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt
#make
#make install
为php提供配置文件:
# cp php.ini-production /usr/local/php/lib/php.ini
编辑apache配置文件httpd.conf,以apache支持php
# vim /etc/httpd/httpd.conf
1、添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2、定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
至此LAMP搭建成功:
可在/var/www/html/中添加index.php文件
vim /index.php
<?php
phpinfo();
?>