CentOS 6编写翻译安装lamp,并分别安装event模块方式和FPM方式的PHP

CentOS下搭建分离式LAMP服务器平台

图片 1

LAMP平台规划

主机1:httpd+php

IP地址:10.170.2.60,安装httpd-2.4.9和php-5.4.26

主机2:mariadb

IP地址:10.170.2.50,安装mariadb-5.5.36

配置主机1

编译安装apr-1.5.0

# tar xf apr-1.5.0.tar.bz2

# cd apr-1.5.0

# ./configure –prefix=/usr/local/apr

# make && make install

编译安装apr-util-1.5.3

# tar xf apr-util-1.5.3.tar.bz2

# cd apr-util-1.5.3

# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/

# make && make install

编译安装httpd-2.4.9

# tar xf httpd-2.4.9.tar.bz2

# cd httpd-2.4.9

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

# make && make install

修改httpd主配置文件,设置Pid文件的路径

# vim /etc/httpd24/httpd.conf

在ServerRoot “/usr/local/apache”行下面添加一行:

PidFile “/var/run/httpd.pid”

提供SysV服务脚本/etc/rc.d/init.d/httpd24,这个文件需要新建

# vim /etc/rc.d/init.d/httpd24

说明:由于脚本内容较长,此处没有将其贴出,非常抱歉

# chmod +x /etc/rc.d/init.d/httpd24

# chkconfig –add httpd24

# chkconfig httpd24 on

启动http24服务并测试

# service httpd24 start

启动httpd24服务时存在下面一段信息:

Starting httpd: AH00558: httpd: Could not reliably determine the
server’s fully qualified domain name, using localhost.localdomain. Set
the ‘ServerName’ directive globally to suppress this message

解决办法:

# vim /etc/httpd24/httpd.conf

将文件中的#ServerName www.example.com:80这一行启用,你可以修改为你想要
的服务器名,例如:ServerNamewww.muluhe.com,然后重启httpd24服务

# service httpd24 restart

编译安装php-5.4.26

# tar xf php-5.4.26.tar.bz2

# cd php-5.4.26

#./configure –prefix=/usr/local/php5 –with-mysql=mysqlnd
–with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –with-openssl
–enable-mbstring –with-freetype-dir

–with-jpeg-dir–with-png-dir –with-zlib –with-libxml-dir=/usr
–enable-xml

–enable-sockets –enable-fpm –with-mcrypt –with-config-file-path=/etc

–with-config-file-scan-dir=/etc/php.d –with-bz2

# make && make install

为php提供配置文件

# cp php.ini-production /etc/php.ini

编辑httpd配置文件,以支持php

# vim /etc/httpd24/httpd.conf

在AddType application/x-gzip .gz .tgz行下面添加下面两行:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

将DirectoryIndex index.html这一行改为:

DirectoryIndex index.php index.html

为php提供SysV启动脚本

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# chmod +x /etc/init.d/php-fpm

# chkconfig –add php-fpm

# chkconfig php-fpm on

为php提供配置文件并编辑配置文件

# cp
/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf

# vim /usr/local/php5/etc/php-fpm.conf

pm.max_children = 50

pm.start_servers = 5

pm.min_spare_servers = 2

pm.max_spare_servers = 8

pid = /usr/local/php5/var/run/php-fpm.pid

listen = 10.170.2.60:9000

创建虚拟主机并开启虚拟主机,结合php

# vim /etc/httpd24/httpd.conf

开启下面两个装载模块:

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

开启虚拟主机,默认情况是关闭的:

Include /etc/httpd24/extra/httpd-vhosts.conf

编辑虚拟主机配置文件

# vim /etc/httpd24/extra/httpd-vhosts.conf

<VirtualHost *:80>

DocumentRoot “/var/www/php”

ServerName www.muluhe.com

ProxyRequests Off

ProxyPassMatch ^/(.*.php)$ fcgi://10.170.2.60:9000/var/www/php/$1

<Directory “/var/www/php”>

Options none

AllowOverride none

Require all granted

</Directory>

</VirtualHost>

创建/var/www/php目录并添加测试页

# mkdir /var/www/php

# cd /var/www/php

# vim index.php

<?php

phpinfo();

?>

重启httpd24和php服务,测试httpd和php结合

# service httpd24 restart

# service php-fpm restart

图片 2

配置主机2


编译安装mariadb-5.5.36

# tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local

# cd /usr/local/

创建mariadb-5.5.36-linux-x86_64符号链接:

# ln -sv mariadb-5.5.36-linux-x86_64/ mysql

创建mysql组和mysql用户:

# groupadd -r mysql

# useradd -g mysql -r mysql

为数据库提供配置文件:

# cd mysql

# mkdir /etc/mysql

# chown -R root.mysql ./*

# cp support-files/my-large.cnf /etc/mysql/my.cnf

修改文件/etc/mysql/my.cnf文件内容,在thread_concurrency =
8行下添加一行:

datadir = /mysql/data

创建存放数据库数据目录

# mkdir -pv /mysql/data

# chown -R mysql.mysql /mysql

# chown -R mysql.mysql /mysql/data

为数据库提供SysV启动脚本,并设置为开机启动:

# cp support-files/mysql.server /etc/init.d/mysqld

# chkconfig –add mysqld

# chkconfig mysqld on

初始化数据库并启动数据库:

# vim /etc/profile.d/mysql.sh

export PATH=/usr/local/mysql/bin:$PATH

# source /etc/profile.d/mysql.sh

# vim /etc/ld.so.conf.d/mysql.conf

/usr/local/mysql/lib

# ln -sv /usr/local/mysql/include/ /usr/include/mysql

# scripts/mysql_install_db –user=mysql –datadir=/mysql/data/

# service

测试分离式LAMP平台


创建数据库并授权:

设置数据库密码:

# mysqladmin -u root password

登录数据库并授权:

# mysql -u root -p

MariaDB [(none)]> CREATE DATABASE pma;

MariaDB [(none)]> GRANT ALL ON pma.* TO ‘pma’@’10.170.2.60’
IDENTIFIED BY ‘666666’;

MariaDB [(none)]> FLUSH PRIVILEGES;

MariaDB [(none)]> SHOW DATABASES;

解压文件phpMyAdmin-3.5.1-all-languages.tar.bz2到/var/www/php,然后进行一些设定:

# tar xf phpMyAdmin-3.5.1-all-languages.tar.bz2 -C /var/www/php

# cd /var/www/php

# mv phpMyAdmin-3.5.1-all-languages pma

# cd pma

# cp config.sample.inc.php config.inc.php

# vim config.inc.php

$cfg[‘blowfish_secret’] = ‘a8b7c6dabkekif7449’;

$cfg[‘Servers’][$i][‘host’] = ‘10.170.2.50’;

重启httpd24和php服务:

# service httpd24 restart

# service php-fpm restart

在浏览器下输入:10.170.2.60/pma可以得到结果,然后输入账号和密码进行登录:

图片 3

图片 4

LAMP平台规划
主机1:httpd+php IP地址:10.170.2.60,安装httpd-2.4.9和php-5.4.26
主机2:mariadb IP地址:10.170.2.50,安…

CentOS 6编译安装lamp,并分别安装event模块方式和FPM方式的PHP,centosfpm

 任务目标: 编译安装LAMP     要求(1) 安装一个模块化的PHP     要求(2) 安装一个FPM的PHP   注意PHP需要最后一个安装,因为需要前两者的支持. 所以这里的安装次序为 1.httpd 2.MariaDB 3.PHP

 

 

任务目标:

编译安装LAMP

CentOS 6编写翻译安装lamp,并分别安装event模块方式和FPM方式的PHP。    要求(1) 安装一个模块化的PHP

    要求(2) 安装一个FPM的PHP

 

注意PHP需要最后一个安装,因为需要前两者的支持.

所以这里的安装次序为

1.httpd

2.MariaDB

3.PHP

一、安装包组

# yum groupinstall “Development Tools” “Server Platform Development” –y

 

 

二、解决依赖关系

1.安装pcre

# yum install pcre-devel –y

 

2.安装apr

# tar xf apr-1.5.2.tar.bz2

# cd apr-1.5.2

# ./configure –prefix=/usr/local/apr

# make && make install

 

3.安装apr-util

# tar xf apr-util-1.5.4.tar.bz2

# cd apr-util-1.5.4

# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr

# make && make install

 

 

三、编译安装httpd 2.4

1.编译安装

# tar xf httpd-2.4.23.tar.bz2

# cd httpd-2.4.23

# ./configure –prefix=/usr/local/apache –sysconf=/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

# make && make install

 

各个参数解释:

–prefix=/usr/local/apache 设定安装目录为/usr/local/apache

–sysconf=/etc/httpd24 服务配置文件存放目录

–enable-so 支持DSO机制,开启模块化

–enable-ssl 支持ssl功能

–enable-cgi 支持CGI功能

–enable-rewrite 支持url重写

–with-zlib 支持传输压缩

–with-pcre 支持pcre正则表达式

–with-apr=/usr/local/apr 指明apr安装位置

–with-apr-util=/usr/local/apr-util/ 指明apr-util安装位置

–enable-modules=most 启用模块级别:most大多数

–enable-mpms-shared=all 编译所有支持的模式

–with-mpm=event 指明mpm模块为event模式

 

2.给新httpd提供一个脚本

# cd /etc/rc.d/init.d/

# cp httpd httpd24

# vim httpd24

大概42行

apachectl=/usr/local/apache/bin/apachectl

httpd=${HTTPD-/usr/local/apache/bin/httpd}

pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

保存退出

 

3.加入到服务列表

# chkconfig –add httpd24

 

4.移除hash缓存

# hash –r

 

5.将新的httpd添加到环境变量

# vim /etc/profile.d/httpd.sh

内容:

export PATH=/usr/local/apache/bin:$PATH

 

6.重读一下刚刚修改的环境变量

# . /etc/profile.d/httpd.sh

 

7.检查一下

# hash

 

8.检测配置文件语法

# httpd –t

 

9.先关掉2.2版本的httpd

# service httpd stop

 

10.启动2.4版本的httpd

# service httpd24 start

 

11.检查80端口

# ss -tnl

# ps aux | grep httpd

 

12.查看是否加载了event模块(mpm_event_module (shared))

# httpd –M

 

一、安装包组

# yum groupinstall “Development Tools” “Server Platform Development” –y

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注