设为首页 收藏本站
查看: 1220|回复: 0

分布式部署LAMP

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-4-25 09:47:32 | 显示全部楼层 |阅读模式
分主机部署lamp

httpd主机:192.168.152.140

php-fpm主机:192.168.152.141

mariadb主机:192.168.152.142
httpd

yum -y install httpd

vim /etc/httpd/conf.d/vhosts.conf

AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
<VirtualHost *:80>
    ServerName www.test.com.
    DocumentRoot /http/vhosts/test.com
    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.152.141:9000/var/www/test.com/$1     #192.168.152.141为php-fpm主机地址

    <Directory "/http/vhosts/test.com">
            Options none
            AllowOverride none
            Require all granted
    </Directory>
</Virtualhost>

<VirtualHost *:80>
    ServerName www.test1.com
    DocumentRoot /http/vhosts/test1.com
    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.152.141:9000/var/www/test1.com/$1

    <Directory "/http/vhosts/test1.com">
            Options FollowSymLinks
            AllowOverride none
            Require all granted
    </Directory>
</Virtualhost>

注释掉/etc/httpd/conf/httpd.conf中的DocumentRoot

mkdir -pv /http/vhosts/test.com
php

yum -y install php php-fpm php-mysql

vim /etc/php-fpm.d/www.conf

listen = 192.168.152.141:9000   #此ip为监听php-fpm本机的9000端口,如只保留端口号即为监听任意ip的9000端口

listen.allowed_clients = 192.168.152.140   #此ip为允许访问php-fpm的主机,即httpd主机,注释掉表示允许任意主机访问

mkdir -pv /var/www/test.com

vim /var/www/test.com/index.php

<?php
    phpinfo();
?>

访问140主机出现php信息页说明httpd和php部署成功
mariadb

yum -y install mariadb-server

vim /etc/my.cnf

[mysqld]

innodb_file_per_table = ON
skip_name_resolve = ON

mysql

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.152.141' IDENTIFIED BY PASSWORD 'passwd'  #ip为需要访问mysql的php-fpm的主机地址,即授权php-fpm主机可以访问mariadb

编辑141主机,测试php-mysql连通性

vim /var/www/test.com/index.php

<?php
    $link = mysql_connect('192.168.152.142','root','12345678');
    if($link)
            echo "Success...";
    else
            echo "Failed....";
    mysql_close;
?>

页面出现Success即为成功
xcache

yum -y groupinstall "Development Tools" "Server Platform Development"

yum install php-devel

wget xcache-3.2

tar xf xcache-3.2.tar.bz2

cd xcache-3.2.0

phpize   #generate configure script to php environment

./configure --enable-xcache --with-php-config=/usr/bin/php-config

make && make install

cp xcache.ini /etc/php.d/

vim /etc/php.d/xcache.ini   #makesure xcache.admin.enable_auth = ON;xcache.size = 60M

systemctl restart httpd.service
wordpress

192.168.152.140

cd /http/vhosts/test.com

wget https://cn.wordpress.org/wordpress-4.5-zh_CN.tar.gz

tar xf wordpress-4.5-zh_CN.tar.gz

cd wordpress/

cp wp-config-sample.php wp-config.php

vim wp-config.php

/** WordPress数据库的名称 */
define('DB_NAME', 'wordpressdb');

/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL数据库密码 */
define('DB_PASSWORD', '12345678');

/** MySQL主机 */
define('DB_HOST', '127.0.0.1');

192.168.152.141

cd /var/www/test.com

wget https://cn.wordpress.org/wordpress-4.5-zh_CN.tar.gz

tar xf wordpress-4.5-zh_CN.tar.gz

cd wordpress/

cp wp-config-sample.php wp-config.php

vim wp-config.php

/** WordPress数据库的名称 */
define('DB_NAME', 'wordpressdb');

/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL数据库密码 */
define('DB_PASSWORD', '12345678');

/** MySQL主机 */
define('DB_HOST', '127.0.0.1');

phpmyadmin

192.168.152.141

yum -y install php-mbstring

cd /var/www/test1.com

wget https://files.phpmyadmin.net/php ... l-languages.tar.bz2

tar xf phpMyAdmin-4.4.15.5-all-languages.tar.bz2

ln -sv phpMyAdmin-4.4.15.5-all-languages pma

cd phpMyAdmin-4.4.15.5-all-languages/

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

yum -y install php-mbstring

openssl rand -base64 20

vim config.inc.php

$cfg['blowfish_secret'] = '4Nf696qH4QG/rZM5EOkkSJyXFBs'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

192.168.152.140

cd /http/vhosts/test.com

wget https://files.phpmyadmin.net/php ... l-languages.tar.bz2

tar xf phpMyAdmin-4.4.15.5-all-languages.tar.bz2

ln -sv phpMyAdmin-4.4.15.5-all-languages pma

cd phpMyAdmin-4.4.15.5-all-languages/

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

yum -y install php-mbstring

openssl rand -base64 20

vim config.inc.php

$cfg['blowfish_secret'] = '4Nf696qH4QG/rZM5EOkkSJyXFBs'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

https

为phpmyadmin添加https访问

192.168.152.141作CA

192.168.152.140作SERVER

CA

cd /etc/pki/CA

(umask 077;openssl genrsa -out private/cakey.pem 2048)

openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3655

country name
state or province name
locality name
organization name
organization unit name
common name
email address

touch serial index.txt

echo 01 > serial

SERVER

cd /etc/httpd/

mkdir ssl

(umask 077;openssl genrsa -out httpd.key 1024)

openssl req -new -key httpd.key -out httpd.csr

country name
state or province name
locality name
organization name
organization unit name
common name
email address

把生成的证书签署请求httpd.csr发送到CA端作签署

CA端签署证书

openssl ca -in /任意目录/httpd.csr -out /etc/pki/CA/certs/httpd.crt

把签署完的证书发还到SERVER

在SERVER端

yum -y install mod_ssl  #安装支持ssl的模块

vim /etc/httpd/conf.d/ssl.conf  #编辑ssl配置文件 编辑前做好备份

<VirtualHost _default_:443>

    ServerName www.test1.com
    DocumentRoot /http/vhosts/test1.com
    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.152.141:9000/var/www/test1.com/$1

    <Directory "/http/vhosts/test1.com">
            Options FollowSymLinks
            AllowOverride none
            Require all granted
    </Directory>

    SSLEngine on

    SSLCertificateFile /etc/httpd/ssl/httpd.crt

    SSLCertificateKeyFile /etc/httpd/ssl/httpd.key

</VirtualHost>

把/etc/httpd/conf.d/vhosts.conf配置文件中第二个VirtualHost注释掉避免冲突

httpd -t    #检查语法错误

systemctl restart httpd.service   #重启httpd服务使配置生效

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-208530-1-1.html 上篇帖子: LNMP新版安装 下篇帖子: CentOS7搭建lamp(module)并实现Xcache、https访问
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表