Case overview
The company's social networking site in the PHP language development, in order to manage the code developed by PHP programmers, the senior leaders asked to build SVN server version control. The first version of the social networking site is deployed on top of the LNMP platform, with an Nginx server and access to the backend's PHP server via the FASTCGI protocol. To keep your data safe,
Request to build MySQL database master-slave cluster.
The social networking site project contains the user's album feature, allows users to upload photos, upload photos need to use the share
Storage to store. There are many open source solutions available for shared storage, such as MFS, Fastdfs, and so on. Public
Implemented using the MFS Distributed File system, and the MFS is mounted in the relevant directory division of the PHP server to determine
Case implementation
According to the company's needs, the implementation process is broadly divided into the following steps
Deploy the SVN server, create an access account for the PHP Programmer's Repo directory, and notify the programmer to
To import the code
Deploy MySQL master-slave server, create database and table according to PHP Programmer's requirements
Deploying Nginx Servers
Use keepalived to make hot spare for Nginx server
Deploying a PHP Server
Deploy MFS to mount the MFS file system in the relevant directory of the front-end PHP server
Notifies the on-line deployer to be released on-line.
Ensure that database services, PHP services, Nginx Services are started sequentially, and notify testers to start testing,
Site maintenance personnel Check Nginx, PHP and database server is working properly.
This article will deploy SVN and LNMP Architecture SVN deployment (IP:192.168.100.101)
yum install subversion subversion --version ##查看版本mkdir -p /opt/svn/repo ##创建目录svnadmin create /opt/svn/repo ##创建一个新的仓库vim /opt/svn/repo/conf/svnserve.conf[general] ##总体配置anon-access = none ##匿名用户没有任何权限auth-access = write ##认证用户具有写权限passwd-db = /opt/svn/repo/conf/passwd ##用户的密码文件auth-db = /opt/svn/repo/conf/authz ##用户信息文件!! svnserve.conf 配置文件有严格的格式要求,每一行前面不能有空格, 等号前后也都有空格。 如果格式正确仍然无法验证,可以更改passwd-db =passwdauth-db = authz 设为默认路径即可svnserve -d -r /opt/svn/repo ##启动svn服务netstat -tunlp | grep svnserve3690 端口开启如需关闭svn服务 可以通过kill PID方式为PHP 程序员zhangsan 建立账户,配置对 repo 仓库具有读写权限,并将账户信息及仓库目录信息反馈给PHP程序员。vim /opt/svn/repo/conf/passwd[users]zhangsan=abc123 ## 格式 用户名=密码vim /opt/svn/repo/conf/authz[/]zhangsan = r[/webphp]zhangsan = rw ##zhangsan用户具有读写权限mkdir /opt/svn/repo/webphpsvn import webphp file:///opt/svn/repo/webphp -m "init web" ## 导入webphp
The SVN deployment is complete, and PHP programmers can install the client in Windows/linux and then import the code to deploy the LNMP architecture-nginx Server (ip:192.168.100.102)
yum install pcre-devel zlib-devel -y ##安装依赖包useradd -M -s /sbin/nologin nginxtar xzvf nginx-1.6.0.tar.gzcd nginx-1.6.0./configure --prefix=/usr/local/nginx/ ##安装目录--user=nginx ##用户--group=nginx ##用户的基本组--with-http_stub_status_module ##开启监控模块vim /usr/local/nginx/conf/nginx.confuser nginx;location / { root html/webphp; index index.html index.htm;}location ~\/php$ { root /var/www/html/webphp; fastcgi_pass 192.168.100.103:9000; fastcgi_index index.php; include fastcgi.conf;}##配置后端PHP程序的fastcgi访问接口ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin ##创建软连接 系统识别命令路径nginx ##开启服务netstat -ntap | grep nginx80端口开启 即为 服务开启成功
Deploying the LNMP Architecture-php Server (ip:192.168.100.103)
Yum Install GD libxml2-devel libjpeg-devel libpng-devel mysql-devel-yuseradd-m-s/sbin/nologin phptar xzvf php-5. 3.28.TAR.GACD php-5.3.28cp/usr/lib64/mysql/libmysqlclient.so.18.0.0/usr/lib/libmysqlclient.so## php default to/usr/lib search Libmysqlclient.so./configure--prefix=/usr/local/php # # installation directory--with-gd--with-zlib--with-mysql--with-mysqli--with-mysql-sock--with-config-file-path=/usr/local/php # # Configuration file Directory--enable-mbstring # #配置mbstring和fpm模块--enalbe-fpm--with-jpeg-dir=/usr/dirmake && make installcd/usr/ LOCAL/PHP/ETCCP php-fpm.conf.default Php-fpm.confvim php-fpm.confpid = run/php-fpm.pid # #pid文件user = php # #用户g roup = php # #用户基本组listen = 0.0.0.0:9000 # #监听端口pm. Max_childre = #子进程最大存在数pm. start_servers = # #服务 Number of child processes at Start Pm.min_spare_servers = 5 # #最小等待运行的子进程数pm. max_spare_servers = # #最大等待运行的子进程数/USR/LOCAL/PHP/SBIN/PHP-FPM # #开启fpm模块mkdir-P/var/www/html/webphp/vim/var/www/html/webphp/index.php<?phpinfo ();? ># #编辑PHP首页
Hot standby of Nginx server via keepalived
备份Nging服务器 IP地址为 192.168.100.104配置如 第一台完全一样yum install keepalived ipvsadm -y在主服务器上vim /etc/keepalived/keepalived.confglobal_defs { router_id LVS_01 ##本路由的名称}vrrp_instance_VI_1 { state MASTER ##热备状态 此为主服务器状态 interface ens33 ##承载虚拟IP的物理接口 virtual_router_id 1 ##虚拟路由的ID,同热备组应在同一ID下 priority 100 ##优先级 数值越大级别越高 advert_int 1 ##通告间隔秒数 virtual_ipaddress { ##虚拟IP 192.168.100.200 }}在备份服务器上vim /etc/keepalived/keepalived.confglobal_defs { router_id LVS_02 ##本路由的名称}vrrp_instance_VI_1 { state BACKUP ##热备状态 此为备份服务器状态 interface ens33 ##承载虚拟IP的物理接口 virtual_router_id 1 ##虚拟路由的ID,同热备组应在同一ID下 priority 90 ##优先级 数值越大级别越高 advert_int 1 ##通告间隔秒数 virtual_ipaddress { ##虚拟IP 192.168.100.200 }}通过 systemctl start keepalived 开启服务
Test
Browser access to Nginx virtual IP 192.168.100.200/index.php to see the PHP interface
Switch off the master server keepalived service access virtual IP still see the PHP interface
Deploy social networking sites-SVN and LNMP architectures