(五)、web集群部署
中小型规模网站集群架构:web集群部署
: Ago linux运维群:https://hankbook.cn
前言
此处坑多:主要就是用户权限问题
解决方案:自己找吧
Nginx的rpm或源码安装请参考:LNMP搭建
1.环境准备
1.模板下载
此次目录需要三个网站模板
分别是
1.DedeCMS
下载点击此处
2.Discuz
下载点击此处
3.wordpress
下载点击此处
#dedecms
wget http://updatenew.dedecms.com/base-v57/package/DedeCMS-V5.7-UTF8-SP2.tar.gz
#discuz
wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip
#wordpress
wget https://cn.wordpress.org/wordpress-4.7.3-zh_CN.tar.gz
2.模板部署
dedecms
mkdir /application/nginx/html/{www,bbs,blog} -p
tar xf DedeCMS-V5.7-UTF8-SP2.tar.gz
cd DedeCMS-V5.7-UTF8-SP2
mv docs/* /application/nginx/html/www/
\mv uploads/* /application/nginx/html/www/
discuz
unzip Discuz_X3.3_SC_UTF8.zip -d /application/nginx/html/bbs/
cd /application/nginx/html/bbs/
ls
wordpress
tar xf wordpress-4.7.3-zh_CN.tar.gz -C /application/nginx/html/blog/
3.修改配置文件
nginx.conf
mkdir /application/nginx/conf/extra
vi /application/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
include extra/status.conf;
}
三个站点目录配置文件
cd /application/nginx/conf/extra/
www.conf
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/www;
index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
access_log logs/www_access.log main;
}
bbs.conf
server {
listen 80;
server_name bbs.etiantian.org;
location / {
root html/bbs;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/bbs;
index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
access_log logs/bbs_access.log main;
}
blog.conf
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/blog;
index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
access_log logs/blog_access.log main;
}
最终:ansible剧本
---
- hosts: web
tasks:
- name: base
include: /server/playbook/base.yml
- name: "install nginx"
yum:
name: nginx-web
state: installed
- name: "install php"
yum:
name: php
state: installed
- name: "start nginx and php"
shell: /application/nginx/sbin/nginx ; /application/php/sbin/php-fpm
- name: install NFS
yum:
name: nfs-utils
state: installed
- hosts: 172.16.1.8
tasks:
- name: "before mount wordpress"
shell: " mkdir -p /application/nginx/html/blog/wp-content/tmp && mv /application/nginx/html/blog/wp-content/uploads/* /application/nginx/html/blog/wp-content/tmp"
- name: "before mount dedecms"
shell: "mkdir /application/nginx/html/www/tmp && mv /application/nginx/html/www/uploads/* /application/nginx/html/www/tmp"
- name: "beffore mount discuz"
shell: "mkdir /application/nginx-1.10.2/html/bbs/tmp && mv /application/nginx-1.10.2/html/bbs/data/* /application/nginx-1.10.2/html/bbs/tmp"
- hosts: web
tasks:
- name: "mount wordpress"
mount:
fstype: nfs
opts: nosuid,noexec,nodev,noatime,nodiratime,rsize=131071,wsize=131072,hard,intr
name: /application/nginx/html/blog/wp-content/uploads
src: "172.16.1.31:/nfsdata/wordpress"
state: mounted
- name: "mount dedecms"
mount:
fstype: nfs
opts: nosuid,noexec,nodev,noatime,nodiratime,rsize=131071,wsize=131072,hard,intr
name: /application/nginx/html/www/uploads
src: "172.16.1.31:/nfsdata/dedecms"
state: mounted
- name: "mount discuz"
mount:
fstype: nfs
opts: nosuid,noexec,nodev,noatime,nodiratime,rsize=131071,wsize=131072,hard,intr
name: /application/nginx-1.10.2/html/bbs/data
src: "172.16.1.31:/nfsdata/discuz"
state: mounted
- hosts: 172.16.1.8
tasks:
- name: "after mount wordpress"
shell: " mv /application/nginx/html/blog/wp-content/tmp/* /application/nginx/html/blog/wp-content/uploads"
ignore_errors: True
- name: "after mount dedecms"
shell: " mv /application/nginx/html/www/tmp/* /application/nginx/html/www/uploads"
ignore_errors: True
- name: "after mount discuz"
shell: " mv /application/nginx-1.10.2/html/bbs/tmp/* /application/nginx-1.10.2/html/bbs/data"
ignore_errors: True