部署社交网站(步骤超详细)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了部署社交网站(步骤超详细)相关的知识,希望对你有一定的参考价值。

实验具体任务要求:
1:部署SVN服务器为php程序员创建repo目录的访问账户,通知程序员可以导入代码
2:部署mysql主从服务器,根据PHP程序员要求创建数据库与表
3:部署nginx服务器
4:部署PHP服务器
5:部署MFS,将MFS文件系统挂载在前端PHP服务器的相关目录下
6:通知上线部署人员可以发布上线
7:保住数据库服务、PHP服务、Nginx服务依次启动,并通知测试人员开始测试,网站维护人员检查Nginx、PHP与数据库服务器是否正常工作
实验拓扑图:
技术分享图片
实验环境介绍:
技术分享图片
具体实验步骤:

-------一:SVN部署 192.168.120.128-----------------------

hostnamectl set-hostname svn
bash
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]# yum install subversion -y
[[email protected] ~]# mkdir -p /opt/svn/repo #创建目录
[[email protected] ~]# svnadmin create /opt/svn/repo #创建一个新的仓库
[[email protected] ~]# vim /opt/svn/repo/conf/svnserve.conf

第19行 anon-access = none #匿名用户u没有任何权限
第20行 auth-access = write #认证用户具有写的权限
第27行 password-db = /opt/svn/repo/conf/passwd #用户的密码文件
第34行 authz-db = /opt/svn/repo/conf/authz #用户的信息文件

[[email protected] ~]# svnserve -d -r /opt/svn/repo/
[[email protected] ~]# netstat -natp | grep svnserve
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 49381/svnserve
#创建一个用户配置passwd文件
[[email protected] ~]# vim /opt/svn/repo/conf/passwd
末尾插入
zhangsan=123
sysadmin=123

#配置authz文件给zhangsan用户赋权读写
[[email protected] ~]# vim /opt/svn/repo/conf/authz

末尾插入
[/]
zhangsan = rw
sysadmin = rw

[/webphp]
zhangsan = rw
sysadmin = rw

#注释用不到的
#[aliases]
#[groups]
[[email protected] ~]# cd /opt/svn/repo/
[[email protected] repo]# mkdir webphp #创建webphp文件夹
[[email protected] repo]# touch webphp/abc.txt webphp/123.txt #导入webphp测试文件
[[email protected] repo]# svn import webphp file:///opt/svn/repo/webphp -m "initial" #初始化webphp目录
正在增加 webphp/abc.txt
正在增加 webphp/123.txt
提交后的版本为 1。

-------------------------二:部署Nginx服务器 192.168.120.139---------------------
#安装环境包
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]# yum install pcre-devel zlib-devel -y
[[email protected] ~]# useradd -M -s /sbin/nologin nginx #添加管理nginx的用户和组
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc
[[email protected] abc]# cd LNMP/
[[email protected] LNMP]# tar xzvf nginx-1.6.0.tar.gz -C /opt
[[email protected] LNMP]# cd /opt/nginx-1.6.0/
[[email protected] nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[[email protected] nginx-1.6.0]# make && make install
#编译安装
修改nginx配置文件中的fastcgi访问接口,用于访问PHP页面。
末尾插入
[[email protected] nginx-1.6.0]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html/webphp;
index index.html index.htm;
}

    location ~.php$ {
        root /var/www/html/webphp;  #指定PHP服务器站点家目录
     fastcgi_pass 192.168.137.12:9000;  #指定PHP服务器地址及端口
    fastcgi_index index.php;
    include fastcgi.conf;
    }

[[email protected] nginx-1.6.0]# nginx
[[email protected] nginx-1.6.0]# netstat -ntap | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8149/nginx: master

---------------------------三:部署PHP服务器 192.168.137.12------------------
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
ps:通过配置php-fpm进程监听9000端口来接受Nginx的请求
#安装环境包和依赖包
[[email protected] ~]# yum install gd libxml2-devel libjpeg-devel libpng-devel mysql-devel gcc gcc-c++ make -y
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc/Y2C/
[[email protected] ~]# tar zxvf php-5.3.28.tar.gz -C /opt/
[[email protected] Y2C]# cd /opt/php-5.3.28/
[[email protected] php-5.3.28]# useradd -M -s /sbin/nologin php
[[email protected] php-5.3.28]# cp /usr/lib64/mysql/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so
[[email protected] php-5.3.28]# ./configure --prefix=/usr/local/php --with-gd --with-zlib --with-mysql --with-mysqli --with-mysql-sock --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
[[email protected] php-5.3.28]# make && make install
#修改配置文件和进行一些优化
[[email protected] php-5.3.28]# cp php.ini-development /usr/local/php/php.ini
[[email protected] php-5.3.28]# ln -s /usr/local/php/bin/ /usr/local/bin/
[[email protected] php-5.3.28]# ln -s /usr/local/php/sbin/
/usr/local/sbin/
#开启fpm模块
[[email protected] php-5.3.28]# cd /usr/local/php/etc
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# vim php-fpm.conf

;pid = run/php-fpm.pid
;user = php
;group = php
;listen = 0.0.0.0:9000
;pm.max_childre = 50
;pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35

listen = 0.0.0.0:9000 #监听所有ip

#启动php-fpm进程,查看9000端口开启
[[email protected] etc]# /usr/local/sbin/php-fpm
[[email protected] etc]# netstat -ntap | grep 9000
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 22353/php-fpm: mast
#创建php服务器站点
[[email protected] etc]# mkdir -p /var/www/html/webphp
[[email protected] etc]# vim /var/www/html/webphp/index.php
this is web

-----------四:部署MySQL 主从服务 192.168.120.145/192.168.120.146------------------
(以下步骤两台同样操作)
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]# yum install gcc gcc-c++ make cmake ncurses-devel bisonlibaio-devel -y
[[email protected] ~]# useradd -s /sbin/nologin mysql
[[email protected] ~]# mkdir -p /usr/local/mysql
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc/LAMP/
[[email protected] LAMP]# tar zxvf mysql-5.5.24.tar.gz -C /opt/
[[email protected] LAMP]# cd /opt/mysql-5.5.24/
[[email protected] mysql-5.5.24]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/home/mysql
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306

[[email protected] mysql-5.5.24]# make && make install
[[email protected] mysql-5.5.24]# chown -R mysql.mysql /usr/local/mysql
[[email protected] mysql-5.5.24]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[[email protected] mysql-5.5.24]# vim /etc/profile
末尾添加
export PATH=$PATH:/usr/local/mysql/bin/
[[email protected] mysql-5.5.24]# source /etc/profile
[[email protected] mysql-5.5.24]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql-5.5.24]# chkconfig --add mysqld
[[email protected] mysql-5.5.24]#chkconfig mysqld --level 35 on
#初始化mysql
[[email protected] mysql-5.5.24]#/usr/local/mysql/scripts/mysql_install_db
--user=mysql
--ldata=/var/lib/mysql
--basedir=/usr/local/mysql
--datadir=/home/mysql

[[email protected] mysql-5.5.24]# chmod +x /etc/init.d/mysqld
[[email protected] mysql-5.5.24]# ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
[[email protected] mysql-5.5.24]# vim /etc/init.d/mysqld
第46行 basedir=/usr/local/mysql
第47行 datadir=/home/mysql

#启动MySQL服务
[[email protected] mysql-5.5.24]# systemctl daemon-reload
[[email protected] mysql-5.5.24]# service mysqld start
Starting MySQL.. SUCCESS!
#给root用户设置密码
[[email protected] mysql-5.5.24]# mysqladmin -u root -p password ‘123123‘
Enter password:
#登录MySQL
[[email protected] mysql-5.5.24]# mysql -u root -p
Enter password:
-----------------MySQL主从配置----------------------------------
##Master服务器配置##
[[email protected] mysql-5.5.24]# vim /etc/my.cnf
第57行 server-id = 11
第58行 log-slave-updates=true

[[email protected] mysql-5.5.24]# systemctl restart mysqld.service
[[email protected] mysql-5.5.24]# mysql -u root -p
mysql> grant replication slave on . to ‘adm‘@‘192.168.120.%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.00 sec)#授权给192.168.120.0网段的服务器同步权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)#刷新
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 332 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

##Slave服务器配置##
[[email protected] mysql-5.5.24]# vim /etc/my.cnf
第57行 server-id = 22 //id和主服务器不能一致//
第58行 relay-log=relay-log-bin //从主服务器上同步日志文件记录到本地//
第59行 relay-log-index=slave-relay-bin.index //定义relay-log的位置和名称//

[[email protected] mysql-5.5.24]# systemctl restart mysqld.service
[[email protected] mysql-5.5.24]# mysql -u root -p
mysql> change master to master_host=‘192.168.120.145‘,master_user=‘adm‘,master_password=‘123‘,master_log_file=‘mysql-bin.000004‘,master_log_pos=332;
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

##两条YES则MYSQL主从复制完成##

-------------五:MFS 文件系统部署----------------------------
master server 192.168.120.134
metalogger 192.168.120.147
chunk1 192.168.120.135
chunk2 192.168.120.148
chunk3 192.168.120.137

##搭建Master Server##
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]#yum install gcc gcc-c++ zlib-devel -y
[[email protected] ~]# useradd -s /sbin/nologin mfs
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc/Y2C
[[email protected] Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[[email protected] Y2C]# cd /opt/mfs-1.6.27/
[[email protected] mfs-1.6.27]#./configure
--prefix=/usr/local/mfs
--with-default-user=mfs
--with-default-group=mfs
--disable-mfschunkserver
--disable-mfsmount
[[email protected] mfs-1.6.27]# make && make install
[[email protected] mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[[email protected] mfs]# ls
mfsexports.cfg.dist mfsmaster.cfg.dist mfsmetalogger.cfg.dist mfstopology.cfg.dist
[[email protected] mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[[email protected] mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg
[[email protected] mfs]# cp mfstopology.cfg.dist mfstopology.cfg
[[email protected] mfs]# cd /usr/local/mfs/var/mfs/
[[email protected] mfs]# cp metadata.mfs.empty metadata.mfs
[[email protected] mfs]# /usr/local/mfs/sbin/mfsmaster start
working directory: /usr/local/mfs/var/mfs
lockfile created and locked
initializing mfsmaster modules ...
loading sessions ... file not found
if it is not fresh installation then you have to restart all active mounts !!!
exports file has been loaded
mfstopology: incomplete definition in line: 7
mfstopology: incomplete definition in line: 7
mfstopology: incomplete definition in line: 22
mfstopology: incomplete definition in line: 22
mfstopology: incomplete definition in line: 28
mfstopology: incomplete definition in line: 28
topology file has been loaded
loading metadata ...
create new empty filesystemmetadata file has been loaded
no charts data file - initializing empty charts
master <-> metaloggers module: listen on :9419
master <-> chunkservers module: listen on
:9420
main master server module: listen on :9421
mfsmaster daemon initialized properly
[[email protected] mfs]# netstat -ntap | grep mfsmaster
tcp 0 0 0.0.0.0:9419 0.0.0.0:
LISTEN 47534/mfsmaster
tcp 0 0 0.0.0.0:9420 0.0.0.0: LISTEN 47534/mfsmaster
tcp 0 0 0.0.0.0:9421 0.0.0.0:
LISTEN 47534/mfsmaster

##搭建MetalLogger Server##
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]#yum install gcc gcc-c++ zlib-devel -y
[[email protected] ~]# useradd -s /sbin/nologin mfs
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc/Y2C/
[[email protected] Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[[email protected] Y2C]# cd /opt/mfs-1.6.27/
[[email protected] mfs-1.6.27]# ./configure
--prefix=/usr/local/mfs
--with-default-user=mfs
--with-default-group=mfs
--disable-mfschunkserver
--disable-mfsmount
[[email protected] mfs-1.6.27]# make && make install
[[email protected] mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[[email protected] mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[[email protected] mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg
[[email protected] mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg
[[email protected] mfs]# vim mfsmetalogger.cfg

第15行 MASTER_HOST = 192.168.120.134 #去除注释,改地址指向主服务器

[[email protected] etc]# cd /usr/local/mfs/var/mfs/
[[email protected] mfs]# cp metadata.mfs.empty metadata.mfs
[[email protected] mfs]# /usr/local/mfs/sbin/mfsmetalogger start
working directory: /usr/local/mfs/var/mfs
[[email protected] mfs]# netstat -ntap | grep mfs
tcp 0 0 192.168.120.147:57462 192.168.120.134:9419 ESTABLISHED 52148/mfsmetalogger

-------------------六:搭建Chunk Server(三台搭建一样)---------------------
#关闭防火墙
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]# yum install gcc gcc-c++ zlib-devel -y
[[email protected] ~]# useradd -s /sbin/nologin mfs
[[email protected] ~]# mkdir /abc
[[email protected] ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for [email protected]//192.168.100.10/rhel6:
[[email protected] ~]# cd /abc/Y2C/
[[email protected] Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[[email protected] Y2C]# cd /opt/mfs-1.6.27/
[[email protected] mfs-1.6.27]#./configure
--prefix=/usr/local/mfs
--with-default-user=mfs
--with-default-group=mfs
--disable-mfsmaster
--disable-mfsmount
[[email protected] mfs-1.6.27]# make && make install
[[email protected] mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[[email protected] mfs]# cp mfschunkserver.cfg.dist mfschunkserver.cfg
[[email protected] mfs]# cp mfshdd.cfg.dist mfshdd.cfg
[[email protected] mfs]# vim mfschunkserver.cfg
第12行 MASTER_HOST = 192.168.120.134

[[email protected] mfs]# vim mfshdd.cfg
#按G到末尾插入路径
/data

[[email protected] mfs]# mkdir /data
[[email protected] mfs]# chown -R mfs.mfs /data/
[[email protected] mfs]# /usr/local/mfs/sbin/mfschunkserver start
working directory: /usr/local/mfs/var/mfs
[[email protected] mfs]# netstat -ntap | grep mfschunkserve
tcp 0 0 0.0.0.0:9422 0.0.0.0:* LISTEN 14274/mfschunkserve
tcp 0 0 192.168.120.135:44916 192.168.120.134:9420 ESTABLISHED 14274/mfschunkserve

----------------七:MFS挂载(到PHP上192.168.120.144)------------------------

[[email protected] ~]# cd /abc/Y2C/
[[email protected] Y2C]# tar zxvf fuse-2.9.2.tar.gz -C /opt
[[email protected] Y2C]# cd /opt/fuse-2.9.2/
[[email protected] fuse-2.9.2]# ./configure
[[email protected] fuse-2.9.2]# make && make install
[[email protected] fuse-2.9.2]# vim /etc/profile
按G到末尾插入
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

[[email protected] fuse-2.9.2]# source /etc/profile
[[email protected] fuse-2.9.2]# cd /abc/Y2C/
[[email protected] Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[[email protected] Y2C]# cd /opt/mfs-1.6.27/
[[email protected] mfs-1.6.27]#./configure
--prefix=/usr/local/mfs
--with-default-user=mfs
--with-default-group=mfs
--disable-mfsmaster
--disable-mfschunkserver
--enable-mfsmount

[[email protected] mfs-1.6.27]# make && make install
[[email protected] mfs-1.6.27]# mkdir /opt/mfs
[[email protected] mfs-1.6.27]# modprobe fuse
[[email protected] mfs-1.6.27]# /usr/local/mfs/bin/mfsmount /opt/mfs -H 192.168.120.134
[[email protected] mfs-1.6.27]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 20G 4.5G 16G 23% /
devtmpfs 474M 0 474M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 14M 475M 3% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda2 10G 35M 10G 1% /home
/dev/sda3 5.0G 303M 4.7G 6% /opt
/dev/sda6 1018M 329M 689M 33% /var
tmpfs 98M 32K 98M 1% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
//192.168.100.10/rhel6 311G 206G 106G 67% /abc
192.168.120.134:9421 47G 0 47G 0% /opt/mfs

-------------------------八:发布上线------------------------
[[email protected] ~]# yum install subversion -y
[[email protected] ~]# cd /usr/local/nginx/html/
[[email protected] html]# svn co svn://192.168.120.128/webphp
//根据提示使用账户 sysadmin 登录,即可部署代码
总结:内容很多,具体安装包,在我往期博客中有下载地址。

以上是关于部署社交网站(步骤超详细)的主要内容,如果未能解决你的问题,请参考以下文章

centos7+tomcat部署JavaWeb项目超详细步骤

转载centos7+tomcat部署JavaWeb项目超详细步骤

瞬间心情愉悦,头发都少掉了几根!---Django+uwsgi+Nginx项目部署超详细步骤

瞬间心情愉悦,头发都少掉了几根!---Django+uwsgi+Nginx项目部署超详细步骤

用lnmp架构部署wordpress网站详细步骤

用lnmp架构部署wordpress网站详细步骤