CentOS下编译安装LAMP并分离为多台服务器

2020-06-05 12:14

CentOS下编译安装LAMP并分离为多台服务器

说明:[Linux86]:Apache主机

[Linux87]:PHP主机 [Linux88]:MySQL主机

内部测试;需在windows下需要更改hosts文件解析到httpd的主机 例子中的hosts文件添加:172.16.251.86 www.soul.org 172.16.251.86 www.pipi.com

LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写:

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:pri nting-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 \

pifile \#加一行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地址测试下。

二、编译安装PHP

编译之前都是需要检查开发环境;需要安装的包是否都已安装

[Linux87]#rpm -qa bzip2-devel libmcrypt-devel libxml2-devel

libxml2-devel-2.7.6-14.el6.x86_64 bzip2-devel-1.0.5-7.el6_0.x86_64 libmcrypt-devel-2.5.8-9.el6.x86_64 [Linux87]#

#如未安装;需要先用yum安装上

1、这边是每个服务单独作为一个服务器;所以编译时与放在一台机器上是有分别的;而且也不需要先安装mysql;下面来直接编译PHP

[Linux87]#ls

php-5.4.26.tar.bz2 xcache-3.1.0.tar.bz2 [Linux87]#tar xf php-5.4.26.tar.bz2

[Linux87]#./configure --prefix=/usr/local/php --enable-fpm

--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-libxml-dir=/usr --with-openssl --with-zlib --with-bz2

--with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mcrypt --enable-sockets --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd #注意:--with-mysql几个选项都要为mysqlnd;因为mysql服务器单独为另一台机器

+--------------------------------------------------------------------+

| 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.

出现上述字符就说明可以继续安装了; [Linux87]#make && make install

Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.3.11 [PEAR] Console_Getopt - installed: 1.3.1 warning: pear/PEAR requires

package \

warning: pear/PEAR requires package \version 1.2.1)

[PEAR] PEAR - installed: 1.9.4

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path [PEAR] Structures_Graph- installed: 1.0.4 [PEAR] XML_Util - installed: 1.2.1


CentOS下编译安装LAMP并分离为多台服务器.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:外研版五年级英语下册1-10模块单元练习题 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: