说明:[Linux86]:Apache主机 [Linux87]:PHP主机 [Linux88]:MySQL主机
内部测试;需在windows下需要更改hosts文件解析到httpd的主机
例子中的hosts文件添加:172.16.251.86 Androidj.com
172.16.251.86
--------------------------------------------------------------------------------
LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写:
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置
CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)
RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind
LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP
1、Linux;操作系统;
2、Apache;网页服务器;
3、MariaDB或MySQL,数据库管理系统(或者数据库服务器);
4、PHP、Perl或Python,脚本语言;
在编译安装之前我们需要先了解下它们之间分开的工作模式:
上图大致的标出Apache、php和mysql分离各自为单独服务器时的工作模式;下面就直接进行编译安装;首先准备好三个虚拟机。测试机版本:
[Linux86]#lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
由于其中操作都是插入代码的;所以命令执行过程并没有把代码都贴出来,只贴出最后几行;
一、编译安装Apache2.4.9
1、解决依赖关系:
[Linux86]#yum grouplist
#
Installed Groups:
Additional Development
Base
Console internet tools
Desktop
Desktop Platform
Development tools #查看包组是否安装
Server Platform Development #查看包组是否安装
如未安装;请先安装这两个包组
#
[Linux86]#rpm -qa pcre-devel
pcre-devel-7.8-6.el6.x86_64
#
查看是否安装;未安装需事先安装
[Linux86]#ls
apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.9.tar.bz2
[Linux86]#
#先安装apr包;解压后进入该目录
[Linux86]#pwd
/root/program/apr-1.5.0
[Linux86]#./configure --prefix=/usr/local/apr
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged #没有报错就继续
[Linux86]#make && make install
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config#没有报错就继续安装apr-util包
[Linux86]#
#解压进入目录
[Linux86]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[Linux86]#make && make install
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[Linux86]#都以安装成功
2、编译Apache:
[Linux86]#rpm -qa httpd
httpd-2.2.15-29.el6.centos.x86_64
#
#系统自己本身已安装了httpd2.2版本的;这里编译2.4的;但是老版本不需要卸载;
#因为卸载后会造成依赖关系不稳定;且后续安装模块时还是会自动安装上的;
#编译是只要不指定到默认路径即可;确保安装前原来的是停止的;且关闭开启自动启动
#
#
[Linux86]#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event --enable-proxy --enable-proxy-fcgi
参数可以通过./configure --help查看;开启自己需要的即可
#如没有报错直接下一步安装
[Linux86]#make && make install
mkdir /usr/local/apache/build
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/program/httpd-2.4.9'#安装完成
[Linux86]#
3、配置Apache:
#由于之前的httpd没有卸载;那么可以cp一个启动脚本当目前的httpd脚本;更改下里面的参数
#
[Linux86]#cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24
[Linux86]#vi /etc/rc.d/init.d/httpd24
# Path to the apachectl script, server binary, and short-form for messages.
#以下几个变量定义为目前的路径;并在主配置文件中更改对应的值
achectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
#修改主配置文件
[Linux86]#vi /etc/httpd24/httpd.conf
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/usr/local/apache"
pifile "/var/run/httpd/httpd.pid" #加一行pid文件路径;与脚本文件对应
#保存退出
[Linux86]#service httpd24 start
Starting httpd: [ OK ]
[Linux86]#ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::111 :::*
LISTEN 0 128 *:111 *:*
LISTEN 0 128 :::80 :::*
#80端口已监听
到这里Apache已编译安装完成了;也可以在浏览器输入IP地址测试下。