手工编译LAMP
LAMP 编译安装基本步骤
前提准本好要编译的的安装包,apache是httpd-2.2.17.tar.gz,mysql使用绿色安装版,当然手动编译也行;php的源码包为5.3.5.tar.bz2.在这之前,需要搭建号编译平台
,安装 Develoopment Librarys,和Development tools.还有,编译之后测试时要关闭
selinux,所以要编辑/etc/selinux/config文件把改为selinux=disabled,然后重启,
当然临时关闭允许selinux也行,setenforce=0.
一、编译安装Apache 1 .编译 tar zxvf httpd-2.2.17.tar.gz #解压文件会生成httpd-2.2.17目录 cd httpd-2.2.17 #切换进目录 ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-modules=most --enable-mods-shared=most --
with-mpm=worker --enable-proxy --enable-rewrite #配置编译的需求 --
prefix=/usr/local/apache将apache安装在/usr/local/apache目录下--enable-
module=so这是安装必要用到的模块,其余的参考上一篇博客内容。
make #编译 make install #安装2.调整apache服务
将apachectl添加到配置文件/etc/profile,成为环境变量,可以随时启动
vim /etc/profile 在export之前添加到PATH路径 PATH=$PATH:/usr/local/apache/bin(默认apache安装后启动脚本在此) 保存退出。 重读配置文件 source /etc/profile(生效) 链接头文件 ln -sv /usr/local/apache/include /usr/include/httpd 检查一下 ls /usr/include/httpd 添加编辑库文件 /etc/ld.so.conf.d/httpd.conf vim /etc/ld.so.conf.d/httpd.conf 添加一句 /usr/local/apache/lib 保存退出 检测一下 ldconfig -v 配置man文档可以随时查看httpdman文档 vim /etc/man.config 添加MANPATH路径 MANPATH=/usr/local/apache/man 这是就可以检查一下 man httpd 这时apache就可以运行了,apache start,可以加载进启动服务chckconfig --addapache && chkconfig apache on
二、mysql安装(采用绿色版,加快速度,亦可以编译源码包,配置大同小异) 本文采用mysql-5.1.45-linux-i686-glibc23.tar.bz2 tar xzf mysql-5.1.45-linux-i686-glibc23.tar.gz -C /usr/local(解压到目标/usr/local)
cd /usr/local 创建软连接 ln -sv mysql-5.1.45-linux-i686-glibc23 mysql (方便操作)
开始安装 cd mysql ls 一下,你会发现有一篇文档INSTALL-BINARY,详细介绍了怎么安装这个mysql,接下来开始按照步骤来。如果了解,可以自己安装。
shell>; groupadd mysql shell>; useradd -g mysql mysql shell>; cd /usr/local shell>; tar zxvf mysql.tar.gz shell>; cd mysql shell>; ./configure –prefix=/usr/local shell>;make;make install shell>; scripts/mysql_install_db --user=mysql shell>; chown -R root . shell>; chown -R mysql var shell>; chgrp -R mysql . shell>; bin/mysqld_safe --user=mysql & 建立启动脚本: cp ./support-files/mysql.server /etc/init.d/mysqld 加载服务 chkconfig --add mysqld && chkconfig mysqld on 启动服务 service mysqld start 检查是否启动 netstat -tnlp | grep 3306(mysql服务启动的事3306端口) 链接头文件 ln -sv /usr/local/mysql/include /usr/include/mysql/lib 保存退出;并检查 ldconfig -v
配置PATH路径 vim /etc/profile 在export之前的PATH后添加 编辑库文件 vim /etc/ld.so.conf/mysqld.conf 添加一句 /usr/local/mysql/lib PATH=$PATH:/usr/local/apache/bin:/usr/local/mysql/bin:/usr/local/mysql/sbin 保存退出,重读配置文件 source /etc/profile 配置man文档可以随时查看httpdman文档 vim /etc/man.config,添加MANPATH路径 MANPATH=/usr/local/mysql/man,这是就可以检查一下 man httpd 至此,完成mysql安装 三、php编译安装 tar xf php-5.3.5.tar.bz2 cd php-5.3.5 ./configure --prefix=/usr/local/php5 --sysconfdir=/etc/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring (这个选项一定要有,否则在访问页面的时候会出现mb_ereg()函数未定义的提示)
配置成功会提示: +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP.make
make test(检查一下有没有出错) makeinstall cp php.ini-production /etc/php.ini 配置httpd.conf文件使之可以识别php vim /etc/httpd/httpd.conf 最后添加 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 保存退出 编辑一些php网页 cd /usr/local/apache/htdocs vim info.php <?php phpinfo(); ?> 保存退出 这是可以启动服务了测试一下 apache restart