lnmp项目案例----搭建WordPress、wecenter网站

news/2024/5/11 0:26:27/文章来源:https://blog.csdn.net/givenchy_yzl/article/details/116274569

1、拆分机器
在这里插入图片描述

2、搭建backup服务器

# 软件 rsync # 关闭防火墙、selinux# 安装rsync# 编写配置文件
[root@backup ~]# vim /etc/rsyncd.conf 
## 前端代码仓库、数据库备份、上传文件的备份
uid=www
gid=www
port=873
fake super=yes
use chroot=no
max connection=200
timeuot=600
ignore errors
read only=false
list=false
auth users=ytt
secrets file=/etc/rsync.passwd
log file=/var/log/rsyncd/log
###################################
[web]
comment="前端代码仓库"
path=/backup/web
[database]
comment="数据库备份"
path=/backup/database
[download]
comment="上传文件备份"
path=/backup/download# 同一用户
[root@backup ~]# useradd -u1000 www# 创建仓库
[root@backup ~]# mkdir /backup/web -p
[root@backup ~]# mkdir /backup/database
[root@backup ~]# mkdir /backup/download# 授权
[root@backup ~]# chown www.www -R /backup/# 创建密码文件
[root@backup ~]# echo "ytt:123" > /etc/rsync.passwd
[root@backup ~]# chmod 600 /etc/rsync.passwd# 启动
[root@backup ~]# systemctl enable --now rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

3、搭建NFS服务器

# 软件 nfs-utils rpcbind# 安装软件
[root@nfs ~]# yum install nfs-utils rpcbind -y# 创建用户
[root@nfs ~]# useradd www -u1000# 创建前端代码仓库、数据库备份、上传文件的备份
[root@nfs ~]# mkdir /nfs/web -p
[root@nfs ~]# mkdir /nfs/database
[root@nfs ~]# mkdir /nfs/download# 授权
[root@nfs ~]# chown www.www -R /nfs/# 设置挂载点
[root@nfs ~]# vim /etc/exports
/nfs/web      172.16.1.0/20(rw,sync,all_squash,anonuid=1000,anongid=1000)
/nfs/database 172.16.1.0/20(rw,sync,all_squash,anonuid=1000,anongid=1000)
/nfs/download 172.16.1.0/20(rw,sync,all_squash,anonuid=1000,anongid=1000)# 重启
[root@nfs ~]# systemctl restart nfs 
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.# 检测
[root@nfs ~]# showmount -e
Export list for nfs:
/nfs/download 172.16.1.0/20
/nfs/database 172.16.1.0/20
/nfs/web      172.16.1.0/20#第二种检查方法
[root@nfs ~]# cat /var/lib/nfs/etab 
/nfs/download	172.16.1.0/20(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1000,anongid=1000,sec=sys,rw,secure,root_squash,all_squash)
/nfs/database	172.16.1.0/20(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1000,anongid=1000,sec=sys,rw,secure,root_squash,all_squash)
/nfs/web	172.16.1.0/20(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1000,anongid=1000,sec=sys,rw,secure,root_squash,all_squash)

4、搭建数据库

# 软件:mariadb# 安装
[root@db01 ~]# yum install mariadb-server -y# 启动
[root@db01 ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.# 创建密码并登录数据库
[root@db01 ~]# mysqladmin -uroot password '123'
[root@db01 ~]# mysql -uroot -p123#创建对应数据库
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> create database zhihu;
Query OK, 1 row affected (0.00 sec)# 创建用户并授权给数据库
MariaDB [(none)]> grant all privileges on wordpress.* to ytt@'%''123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zhihu.* to ytt@'%''123';
Query OK, 0 rows affected (0.00 sec)#重载数据库
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)# 数据备份

5、搭建web服务器

点击xshell中的工具—》发送键输入到所有会话

# 安装官方源
[root@web01 ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true[root@web01 ~]# yum clean all# 安装nginx
[root@web01 ~]# yum install nginx -y# 启动
[root@web01 ~]# systemctl enable --now nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

6、安装PHP

#上传代码包
[root@web01 ~]# rz -E
rz waiting to receive.#解压并安装
[root@web01 ~]# tar -xf php.tar.gz && yum localinstall -y *.rpm# 修改配置文件
[root@web01 ~]# vim /etc/php-fpm.d/www.conf 
user = www
group = www#创建用户
[root@web01 ~]# useradd www -u1000# 启动php
[root@web01 ~]# systemctl enable --now php-fpm.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

7、搭建wordpress页面

# 共享代码、共享数据、共享nginx配置
## 在nfs服务器上创建/nfs/conf目录
[root@nfs web]# mkdir /nfs/conf## 授权/nfs/conf
[root@nfs web]# chown www.www /nfs/conf## 加入nfs配置文件
[root@nfs web]# vim /etc/exports
/nfs/conf     172.16.1.0/20(rw,sync,all_squash,anonuid=1000,anongid=1000)## 重启nfs
[root@nfs web]# systemctl restart nfs-server rpcbind#创建密码文件与用户
[root@web01 ~]# htpasswd -c /etc/nginx/conf.d/auth_basic linux## 增加wordpress配置并加入密码模块
[root@web01 ~]# vim wordpress.conf 
server {listen 80;server_name linux.wps.com;root /www/wordpress;client_max_body_size 10m;location / {index index.php;}location ~* \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}location =/wp-admin {auth_basic "小老弟,暗号:天王盖地虎";auth_basic_user_file /etc/nginx/conf.d/auth_basic;index index.php;}
}#创建站点目录
[root@web01 ~]# mkdir /www#挂载
[root@web01 ~]# mount  -t nfs 172.16.1.31:/nfs/web /www
[root@web01 ~]# mount -t nfs 172.16.1.31:/nfs/conf /etc/nginx/conf.d#上传压缩包
[root@web01 ~]# cd /www
[root@web01 www]# rz -E
rz waiting to receive#解压
[root@web01 www]# cd /www
[root@web01 www]# tar -xf wordpress.tar.gz 

8、搭建WeCenter

[root@web01 www]# unzip zhihu.zip 
[root@web01 www]# chown www.www -R /www
[root@web01 www]# vim /etc/nginx/conf.d/wecenter.conf 
server {listen 80;server_name linux.wecenter.cluster.local.com;root /www/zhihu;location / {index index.php;}location ~* \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
}# 重启
[root@web01 conf.d]# systemctl restart nginx

9、数据库备份

#创建目录
[root@db01 ~]# mkdir /databases[root@db01 databases]# mount -t nfs 172.16.1.31:/nfs/database /databases/# 编写备份脚本
[root@db01 ~]# vim /databases/mysql_dump.sh 
#!/bin/bash
DATE=`date +%F`
BACKUP="/databases"
cd $BACKUP
mysqldump -uroot -p123 --all-databases --single-transaction > mysql-all-${DATE}.sql
tar -czf mysql-all-${DATE}.tar.gz mysql-all-${DATE}.sql
rm -rf mysql-all-${DATE}.sql#创建用户并授权
[root@db01 databases]# useradd www -u1000
[root@db01 databases]# chown www.www /databases/# 脚本加入定时任务
[root@db01 ~]# crontab -e
01 00 * * *  /databases/mysql_dump.sh

10、将web02和web03加入集群

[root@web02 ~]# mkdir /www
[root@web02 ~]# chown -R www.www /www/
[root@web02 ~]# mount  -t nfs 172.16.1.31:/nfs/web /www
[root@web02 ~]# mount -t nfs 172.16.1.31:/nfs/conf /etc/nginx/conf.d
[root@web02 ~]# systemctl restart nginx[root@web03 ~]# mkdir /www
[root@web03 ~]# chown -R www.www /www/
[root@web03 ~]# mount  -t nfs 172.16.1.31:/nfs/web /www
[root@web03 ~]# mount -t nfs 172.16.1.31:/nfs/conf /etc/nginx/conf.d/
[root@web03 ~]# systemctl restart nginx

11、数据备份与同步

#上传实时备份软件
[root@nfs ~]# cd /nfs/download
[root@nfs download]# rz -E
rz waiting to receive.
[root@nfs download]# tar -xf sersync.gz
[root@nfs download]# cd GNU-Linux-x86/
[root@nfs GNU-Linux-x86]# vim confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5"><host hostip="localhost" port="8008"></host><debug start="false"/><fileSystem xfs="false"/><filter start="false"><exclude expression="(.*)\.svn"></exclude><exclude expression="(.*)\.gz"></exclude><exclude expression="^info/*"></exclude><exclude expression="^static/*"></exclude></filter><inotify><delete start="true"/><createFolder start="true"/><createFile start="true"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="true"/><modify start="true"/></inotify><sersync><localpath watch="/nfs/download"><remote ip="172.16.1.41" name="download"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-az"/><auth start="true" users="ytt" passwordfile="/etc/rsync.passwd"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync><failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once--><crontab start="false" schedule="600"><!--600mins--><crontabfilter start="false"><exclude expression="*.php"></exclude><exclude expression="info/*"></exclude></crontabfilter></crontab><plugin start="false" name="command"/></sersync><plugin name="command"><param prefix="/bin/sh" suffix="" ignoreError="true"/>	<!--prefix /opt/tongbu/mmm.sh suffix--><filter start="false"><include expression="(.*)\.php"/><include expression="(.*)\.sh"/></filter></plugin><plugin name="socket"><localpath watch="/opt/tongbu"><deshost ip="192.168.138.20" port="8009"/></localpath></plugin><plugin name="refreshCDN"><localpath watch="/data0/htdocs/cms.xoyo.com/site/"><cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/><sendurl base="http://pic.xoyo.com/cms"/><regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/></localpath></plugin>
</head>
[root@nfs GNU-Linux-x86]# echo "123"> /etc/rsync.passwd
[root@nfs GNU-Linux-x86]# ./sersync2 -dro confxml.xml [root@nfs ~]# cd /nfs/database
[root@nfs download]# rz -E
rz waiting to receive.
[root@nfs download]# tar -xf sersync.gz
[root@nfs download]# cd GNU-Linux-x86/
[root@nfs GNU-Linux-x86]# vim confxml.xml
cat confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5"><host hostip="localhost" port="8008"></host><debug start="false"/><fileSystem xfs="false"/><filter start="false"><exclude expression="(.*)\.svn"></exclude><exclude expression="(.*)\.gz"></exclude><exclude expression="^info/*"></exclude><exclude expression="^static/*"></exclude></filter><inotify><delete start="true"/><createFolder start="true"/><createFile start="true"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="true"/><modify start="true"/></inotify><sersync><localpath watch="/nfs/database"><remote ip="172.16.1.41" name="database"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-az"/><auth start="true" users="ytt" passwordfile="/etc/rsync.passwd"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync><failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once--><crontab start="false" schedule="600"><!--600mins--><crontabfilter start="false"><exclude expression="*.php"></exclude><exclude expression="info/*"></exclude></crontabfilter></crontab><plugin start="false" name="command"/></sersync><plugin name="command"><param prefix="/bin/sh" suffix="" ignoreError="true"/>	<!--prefix /opt/tongbu/mmm.sh suffix--><filter start="false"><include expression="(.*)\.php"/><include expression="(.*)\.sh"/></filter></plugin><plugin name="socket"><localpath watch="/opt/tongbu"><deshost ip="192.168.138.20" port="8009"/></localpath></plugin><plugin name="refreshCDN"><localpath watch="/data0/htdocs/cms.xoyo.com/site/"><cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/><sendurl base="http://pic.xoyo.com/cms"/><regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/></localpath></plugin>
</head>
[root@nfs GNU-Linux-x86]# ./sersync2 -dro confxml.xml 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_842148.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

iis怎么切换网站php版本,IIS下PHP的切换

wordpress安装包下载解压后有个readme.html网页&#xff0c;打开后有下面一段话&#xff1a;system requirements是指服务器配置需求&#xff0c;最低要求是PHP版本5.2.4以上&#xff0c;mysql版本5.0以上。recommendations是推荐配置&#xff0c;推荐的是&#xff1a;PHP版本7…

网站上抓取数据并且自动发帖到论坛程序

近期本人闲来没事做了一个程序自动从一些BT网站上抓取数据并且自动发帖到我自己的论坛上&#xff0c;试用了几个月效果比较好&#xff0c;现在公布源代码供perl爱好者参考&#xff0c;欢迎广大perl爱好者一起沟通交流。分几个程序组成readcokie.pl 获取要上传主机的cookie一次获…

网站实时监控系统的设计与实现

引言  对网页监控比较成熟的技术是定时监控&#xff0c;即由用户设定时间间隔&#xff0c;系统按时对需监控的网页文件轮询一遍&#xff0c;来判断文件是否被非法删除或篡改。若发现&#xff0c;立即用备份盘上的备份文件进行恢复。这样的监控存在一个缺陷&#xff1a;被非法…

[BOF]高性能网站设计、开发、部署

北京 TechED 上&#xff0c;计划中的一个BOF&#xff08;同类人&#xff09;的主题是&#xff1a;高性能网站设计、开发、部署&#xff0c;下面是我初步整理需要讨论的主题&#xff1a; 网站是信息展示平台&#xff0c;它的核心职责是把信息展示出来。当然&#xff0c;他也有部…

值得网站开发者收藏的JAVASCRIPT图形图表库

http://www.uirss.com/blog-39451-6411.html 图表是数据图形化的表示&#xff0c;通过形象的图表来展示数据&#xff0c;比如条形图&#xff0c;折线图&#xff0c;饼图等等。可视化图表可以帮助开发者更容易理解复杂的数据&#xff0c;提高生产的效率和Web应用和项目的可靠性。…

seo按天扣费系统_扒拉一些搞SEO关键词排名赚钱的几个行业秘密

互联网上的赚钱方式各式各样&#xff0c;干什么的几乎都有&#xff0c;但是搞网站的、搞SEO的&#xff0c;最终目的也是赚钱&#xff0c;可是赚钱跟赚钱相比&#xff0c;SEO排名赚钱的还是出现了几个极端化。今天诺伊网小编给你深扒一些SEO行业的秘闻吧&#xff0c;估计很多干货…

:https web服务器ssl认证项目,网站启用https后的SSL的安全配置和检测

现在的网站通常开启SSL已经是标配了&#xff0c;不过&#xff0c;配置好了SSL后&#xff0c;还需要判断一下服务器部署的是否安全&#xff0c;如果没有配置好的话&#xff0c;会带来很多安全隐患。SSL/TLS 系列中有六种版本&#xff1a;SSL v2&#xff0c;SSL v3&#xff0c;TL…

国内的服务器网站,国内主流网站服务器

国内主流网站服务器 内容精选换一换在大型网络应用中&#xff0c;通常会使用多台服务器提供同一个服务。为了平衡每台服务器上的访问压力&#xff0c;通常会选择采用负载均衡来实现&#xff0c;提高服务器响应效率。云解析服务支持解析的负载均衡&#xff0c;也叫做带权重的记录…

国内外IGS数据及产品下载网站

国内外 IGS数据及产品下载网站 连接有所变更&#xff1a; CLK ,SP3 https://cddis.nasa.gov/archive/gnss/products/2220/ 本文是转载博客地址&#xff1a;https://blog.csdn.net/SmartTiger_CSL/article/details 一、转自http://geodesy.blog.sohu.com/274775667.html IG…

好吧我摊牌了,这是C++最好的5 个网站

相对其他语言来说&#xff0c;C 算是难度比较高的了&#xff0c;这一点无法否认。但是如果能有一些好的网站&#xff0c;则会让 C 的学习事半功倍。 那就来介绍几个最常用的&#xff08;最好的&#xff09;吧&#xff0c;包含了参考手册、教程、框架/库列表 ...... 1.cpprefer…

谷歌浏览器使用bing搜索引擎发现打开网站会替换搜索页

今天更新谷歌浏览器发现搜索东西&#xff0c;点击搜索结果网站&#xff0c;打开后的网站页会替换掉当前搜索页&#xff0c;就得点回退&#xff0c;很烦 后来发现不是谷歌浏览器的问题&#xff0c;是搜索引擎的问题&#xff0c;设置下搜索引擎就行 我使用的是bing搜索引擎 勾…

网站如何集成markdown编辑器

收藏(4)Markdown是一种可以使用普通文本编辑器编写的标记语言&#xff0c;通过简单的标记语法&#xff0c;它可以使普通文本内容具有一定的格式。它用简洁的语法代替排版&#xff0c;而不像一般我们用的文字处理软件 Word 等有大量的排版、字体设置。这使得我们能够专心的码字&…

Linux测试网速(linux服务器测试网站,命令行)

第一步&#xff1a;wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py 第二步&#xff1a; chmod arx speedtest.py 第三步&#xff1a; sudo mv speedtest.py /usr/local/bin/speedtest 第四步&#xff1a;sudo chown root:root /usr/local…

巧用VS2005解决VS2005网站发布不便问题

关键字:VS2005,网站发布,编译一、问题引入在VS2005网站开发过程中,网站发布问题一直是个问题.VS2005创建的网站有几个默认的目录:App_Code,App_Data,App_Themes........如果是但cs/vb文件,比如UploadFile.cs类UploadFile,这个类文件没有可视的aspx文件,那么这个文件就必须放到A…

各类常见的网站检查工具

一、网站基础查询 1.域名基础信息查询 http://tool.chinaz.com/Ip/Whois.asp 通过在线查询你可以知道自己网站的基本信息&#xff0c;当然很多时候你是清楚自己网站的情况的。但是你不一定知道对手网站的情况。 2.详细的网站历史查询 http://www.archive.org/web/web.php 3.网站…

USTC一个开源下载的网站

QT下载路径&#xff0c;版本5.12.6 http://mirrors.ustc.edu.cn/qtproject/official_releases/qt/5.12/5.12.6/

最新10款精美的免费PSD网站模板下载

这篇文章收集了10款免费的 PSD 网站模板分享给大家&#xff0c;您可以免费下载使用。这些高质量的免费 PSD 网站模板可以让您的工作得心应手&#xff0c;帮助您节省大量的时间和精力。感谢那些优秀的设计师分享他们的劳动成果&#xff0c;让更多的人可以使用他们的创意设计&…

精选30个富有想象力的网站设计作品

在设计网站的时候&#xff0c;有几项事情需要牢记&#xff0c;其中很重要的事情之一就是为设计的品牌选择合适的风格。在这篇文章中&#xff0c;你将发现很多创意的&#xff0c;吸引眼球的网站设计作品&#xff0c;设计师们可通过这些优秀的设计作品来获取创作灵感&#xff0c;…

一个网站直接跳转引起的一些思考

近日看了一个站&#xff0c;网站的界面是这样的。 发现鼠标放上去&#xff0c;都是直接跳转&#xff0c;于是我查看了一下源代码 复制代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transit…

IIS6.0asp网站文件上传大小限制和图片上传大小的限制解决方法

win2003的iis6限制了asp的上传文件大小为200k&#xff0c;aspx的上传程序没有影响1、先勾选IIS设置中的选项&#xff1a;IIS服务器属性&#xff0d;&#xff0d;&#xff1e;允许直接编辑配置数据库2、在服务里关闭iis admin service服务.3、找到windows\system32\inesrv\下的m…