前序:
查考文章:http://www.cnblogs.com/mchina/archive/2012/11/28/2778779.html
http://www.centos.bz/2011/09/centos-compile-lamp-apache-mysql-php/comment-page-1/#comments
安装:
1、安装libxml2 # cd /usr/local/src/lamp/libxml2-2.6.30 # ./configure --prefix=/usr/local/libxml2 # make && make install
2、安装libmcrypt # cd ../libmcrypt-2.5.8 # ./configure --prefix=/usr/local/libmcrypt # make && make install
3、安装zlib cd ../zlib/1.2.3/ # ./configure # make && make install
4、安装libpng [root@166 1.2.3]# cd ../../libpng-1.2.31/ ./configure --prefix=/usr/local/libpng # make && make install
5、安装jpeg6 这个软件包安装有些特殊,其它软件包安装时如果目录不存在,会自动创建,但这个软件包安装时需要手动创建。 # mkdir /usr/local/jpeg6 # mkdir /usr/local/jpeg6/bin # mkdir /usr/local/jpeg6/lib # mkdir /usr/local/jpeg6/include # mkdir -p /usr/local/jpeg6/man/man1 [root@166 libpng-1.2.31]# cd ../jpeg-6b/ make 报错:http://hi.baidu.com/lz958942/item/0e89ff2ce38d740473863efa make: ./libtool:命令未找到 问题描述: [root@bogon jpeg-6b]# ; make install ./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c make: ./libtool:命令未找到 make: *** [jcapimin.lo] 错误 127 ./libtool --mode=compile gcc -O2 -I. -c ./cjpeg.c make: ./libtool:命令未找到 make: *** [cjpeg.lo] 错误 127 解决办法: 首先看有没有安装 及 libtool-ltdl-devel rpm -qa | grep libtool 然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.) cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . 也就是把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件 make clean 再重新configure 没有权限的时候先建立对应的文件夹,再次make install就行了 ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static make make install
6、安装freetype [root@166 jpeg-6b]# cd ../freetype-2.3.5/ [root@166 freetype-2.3.5]# ./configure --prefix=/usr/local/freetype make make install
7、安装autoconf [root@166 freetype-2.3.5]# cd ../autoconf-2.61/ # ./configure # make && make install
8、安装GD库 [root@166 autoconf-2.61]# cd ../gd/2.0.35/ # ./configure --prefix=/usr/local/gd2/ --enable-m4_pattern_allow --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ # make make install
9、安装Apache cd ../../httpd-2.2.9 # ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-z=/usr/local/zlib --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support make 报错:http://hi.baidu.com/kinzhu/item/9a0f4970ec3cab41ef1e5326 原因是64为系统 详细可见 然后重现安装gd库的支持
安装mysql
groupadd mysql useradd -g mysql mysql cd /tmp/mysql-5.1.62 ./configure --prefix=/usr/local/mysql/ --localstatedir=/usr/local/mysql/data --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread make make install
mysql的设置:
更多编译参数请执行./configure --help命令查看。 cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件夹my.cnf /usr/local/mysql/bin/mysql_install_db --user=mysql //初始化数据库 chown -R root.mysql /usr/local/mysql chown -R mysql /usr/local/mysql/data cp /tmp/mysql-5.1.62/support-files/mysql.server /etc/rc.d/init.d/mysqld //init启动脚本 chown root.root /etc/rc.d/init.d/mysqld chmod 755 /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on ln -s /usr/local/mysql/bin/mysql /usr/bin ln -s /usr/local/mysql/bin/mysqladmin /usr/bin service mysqld start
设置root用户远程访问:
mysql -u root -p 回车
回车 (这时候密码为空)
mysql>grant all on *.* to root@'%' identified by 'morohstk22';
mysql>grant all on *.* to root@localhost identified by 'morohstk22';
mysql>quit
service mysqld restart
OK至此 mysql 远程root访问输入密码就可以了
安装php:
'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql=/usr/local/mysql/' '--with-libxml-dir=/usr/local/libxml2/' '--with-png-dir=/usr/local/libpng/' '--with-jpeg-dir=/usr/local/jpeg6/' '--with-freetype-dir=/usr/local/freetype/' '--with-gd' '--with-zlib-dir=/usr/local/zlib/' '--with-mcrypt=/usr/local/libmcrypt/' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--enable-soap' '--enable-mbstring=all' '--enable-sockets'
加载GD库的时候出问题 所以就yum -y install gd 然后用rpm的gd 了
详细的报错我也记不清楚了
make
make test
make install
15、配置PHP
创建配置文件
# cp php.ini-dist /usr/local/php/etc/php.ini
使用vi编辑apache配置文件
# vi /etc/httpd/httpd.conf
添加这一条代码
Addtype application/x-httpd-php .php .phtml
重启Apache
# /usr/local/apache2/bin/apachectl restart
以上安装步骤可以写成一个shell script,详细参考http://files.cnblogs.com/mchina/lamp.rar
16、安装Zend加速器
# cd /usr/local/src/ZendOptimizer-3.2.6-linux-glibc21-i386/
# ./install.sh