Social networking Site Deployment--nginx Server +php Server build +mysql master-slave cluster

Source: Internet
Author: User
Tags fpm install php php language php server nginx server

Case overview

A 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. In order to ensure data security, MySQL database is required to build a master-slave cluster.

The social networking site project contains the user's album feature, allows users to upload photos, upload photos to be stored using shared storage. There are many open source solutions available for shared storage, such as MFS, Fastdfs, and so on. The company decided to use the MFS Distributed file system to implement, and the MFS mounted in the PHP server related directory.

Case implementation

Depending on 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 import the code.
    • Deploy MySQL master-slave server, create database and table according to PHP Programmer's requirement.
    • Deploy an Nginx server. Deploy the 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.
Deploying Nginx server 1, nginx server installation
yum -y install pcre-devel zlib-devel gcc gcc-c++ make        //安装环境包依赖包useradd -M -s /sbin/nologin nginx         //创建管理用户tar xzvf nginx-1.6.0.tar.gz -C /optcd /opt/nginx-1.6.0/ ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module             make && make install
2. Modify Nginx Configuration

Need to configure the FastCGI access interface for the back-end PHP Program

vim /usr/local/nginx/conf/nginx.conf       //配置后端PHP程序的fastcgi访问接口location / {            root   html/webphp;            index  index.html index.htm;        }location ~ \.php$ {        root           /var/www/html/webphp;        fastcgi_pass   192.168.43.117:9000;         //PHP服务器 IP地址:端口        fastcgi_index  index.php;        include        fastcgi.conf;}ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/    //方便管理,建立软链接

3. Open Nginx
nginx          //开启Nginxnetstat -antp | grep nginxtcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6502/nginx: mastersystemctl stop firewalld.service setenforce 0             //关闭防火墙和安全功能#nginx -t       //检查#nginx          //启动#killall -1 nginx   //重启#killall -3 nginx   //停止

Deploy PHP server 1, install PHP, and receive nginx requests by configuring the PHP-FPM process to listen on port 9000
yum -y install gd libxml2-devel libjpeg-devel libpng-devel zlib-devel mysql-devel bzip2-devel gcc gcc-c++ make        //安装环境包,依赖包useradd -M -s /sbin/nologin php       //创建管理用户tar xzvf php-5.3.28.tar.gz -C /opt/cd /opt/php-5.3.28/cp /usr/lib64/mysql/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so       //PHP默认去/usr/lib搜索libmysqlclient.so./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 --with-jpeg-dir=/usr/lib --enable-fpmmake && make install
2. Modify php-fpm.conf file to accept Nginx request
cd /usr/local/php/etc/cp php-fpm.conf.default php-fpm.conf    //配置php-fpm 进程监听9000端口来接受nginx请求vim php-fpm.conf......pid = run/php-fpm.piduser = phpgroup = phplisten = 0.0.0.0:9000pm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35
3. Open Service and test
/usr/local/php/sbin/php-fpm        //开启php-fpm进程netstat -ntap | grep 9000tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      104389/php-fpm: massystemctl stop firewalld.service setenforce 0         //关闭防火墙和安全功能

4. Create test page, browser access test
mkdir -p /var/www/html/webphpvim /var/www/html/webphp/index.php<?phpphpinfo();?>

Browser Input: http://192.168.43.222/index.php authentication

MySQL Master-slave cluster

Reference post: http://blog.51cto.com/13620936/2150981

Social networking Site Deployment--nginx Server +php Server build +mysql master-slave cluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.