In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
A detailed explanation of the construction of social networking sites
Social networking sites are built to manage the code developed by PHP programmers and require version control on the popular SVN server. The first version of the social networking site is deployed on the LNMP platform, the front end is the Nginx server, and the back-end PHP server is accessed through the fastcgi protocol. In order to ensure data security, the mysql database is built for master-slave replication.
The social networking project includes a user photo album function that allows users to upload photos, which need to be stored using shared storage. There are many open source solutions available for shared storage, such as NFS,MFS,FastDFS and so on. This paper simplifies the storage scheme, using NFS instead of MFS function, the current network is built according to the requirements of the company.
This case topology:
Case environment:
Host operating system IP address main software NginxCentOS 7192.168.88.128nginx-1.14.0.tar.gzPHPCentOS 7192.168.88.129
Php-5.6.38.tar.gz
MYSQL MasterCentOS 7192.168.88.130mysql-5.6.41.tar.gzMYSQL SlaveCentOS 7192.168.88.131mysql-5.6.41.tar.gzSVNCentOS 7192.168.88.132yum installation NFSRedhat 6192.168.88.133yum installation
All the software in this article is installed using wget and yum.
First, set up Nginx
1. Install the environment package
Yum install gcc gcc-c++ pcre pcre-devel zlib-devel-y
2. Create Nginx users
Useradd-M-s / sbin/nologin nginx
3. Download nginx
Cd / opt/ # is downloaded to the opt directory
Wget http://nginx.org/download/nginx-1.14.0.tar.gz # download nginx
4. Decompress, compile and install
Tar zxf nginx-1.14.0.tar.gz # decompression
Cd nginx-1.14.0/
. / configure\
-- prefix=/usr/local/nginx\ # specify the installation path
-- user=nginx\ # specify the user
-- group=nginx\ # specify the group
-- with-http_stub_status_module # opens the statistics module
Make & & make install # installation
5. Optimization
Ln-s / usr/local/nginx/sbin/* / usr/local/sbin/ # soft link optimization
Vim / etc/init.d/nginx # add startup script
#! / bin/bash
# chkconfig:-99 20
# this is nginx init
PROG= "/ usr/local/nginx/sbin/nginx"
PIDF= "/ usr/local/nginx/logs/nginx.pid"
Case "$1" in
Start)
$PROG
Stop)
Kill-s QUIT $(cat $PIDF)
Restart)
$0 stop
$0 start
Reload)
Kill-s HUP $(cat $PIDF)
*)
Echo "please use: {start | stop | restart | reload}"
Exit 1
Esac
Exit 0
# kill-s QUIT $(cat $PIDF) indicates that the Nginx process is terminated according to PID
# kill-s HUP $(cat $PIDF) indicates configuration based on process number overload
6. Modify the fastcgi access interface in the configuration file to access the PHP page.
Vim / usr/local/nginx/conf/nginx.conf # modify the configuration file
Location ~\ .php$ {
Root / var/www/html/webphp
Fastcgi_pass 192.168.88.131:9000
Fastcgi_index index.php
Include fastcgi.conf
}
Second, set up MYSQL master-slave server
1. Install the environment package
Yum install gcc gcc-c++ make cmake ncurses-devel bison libaio-devel autoconf-y
2. Download mysql5.6
Cd / opt/ # is downloaded to the opt directory
Download the wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.41.tar.gz # wget command
3. Create mysql users
Useradd-s / sbin/nologin mysql
4. Compile and install
Cd mysql-5.6.41/
Cmake\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DWITH_EXTRA_CHARSETS=all\
-DSYSCONFDIR=/etc\
-DMYSQL_DATADIR=/home/mysql/\
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DENABLED_LOCAL_INFILE=1\
-DWITH_SSL=system\
-DMYSQL_TCP_PORT=3306\
-DENABLE_DOWNLOADS=1\
-DWITH_SSL=bundled
Make & & make install # installation
5. Optimization
Cp support-files/my-default.cnf / etc/my.cnf # copy configuration file
Cp support-files/mysql.server / etc/init.d/mysqld # replication startup script
Vim / etc/init.d/mysqld # modify startup script
Basedir=/usr/local/mysql
Datadir=/home/mysql
Chmod + x / etc/init.d/mysqld # add execute permission
Chkconfig-- add mysqld # added to startup item
Chkconfig-- level 35 mysqld on # 35 mode startup
Echo "PATH=$PATH:/usr/local/mysql/bin/" > > / etc/profile # add environment variables
Source / etc/profile # refresh environment variables
Chown-R mysql.mysql / usr/local/mysql # changes the main group of the mysql installation directory
6. Initialize the database
/ usr/local/mysql/scripts/mysql_install_db\
-- user=mysql\
-- ldata=/var/lib/mysql\
-- basedir=/usr/local/mysql\
-- datadir=/home/mysql
Ln-s / var/lib/mysql/mysql.sock / home/mysql/mysql.sock # create soft links to sock files
7. Start two mysql servers
Service mysql start
8. Modify the master-slave server configuration file
Primary server)
Vim / etc/my.cnf
[mysqld] # add under mysqld module
Server-id = 11
Log-bin=/usr/local/mysql/data/master-bin # specify the log file location
Log-slave-updates=true # Slave server can read master server content
Service mysqld restart # restart mysql
From server)
Vim / etc/my.cnf
[mysqld] # add under mysqld module
Server-id = 22
Log-bin=/usr/local/mysql/data/slave-bin
Relay-log=realy-log-bin
Relay-log-index=slave-relay-bin.index
Service mysqld restart # restart mysql
9. Establish mysql master-slave relationship
Primary server)
Mysql > grant replication slave on *. * to 'myslave'@'192.168.88.%' identified by' 123123 rights; # Rights
Mysql > show master status; # View the master status of the master server
+-+
| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |
+-+
| | master-bin.000001 | 411 |
+-+
1 row in set (0.00 sec)
From server)
Mysql > change master to master_host='192.168.88.129',master_user='myslave',master_password=='123123'
Master_log_file='master-bin.000001',master_log_pos=411
Mysql > start slave; # start slave
Query OK, 0 rows affected (0.04 sec)
Mysql > show slave status\ G; # check the master-slave status and check the following two behaviors: yes master-slave synchronization is successful.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Third, set up PHP server
1. Install the environment package
Yum-y install gd libxml2-devel libjpeg-devel libpng-devel zlib-devel fontconfig-devel openssl-devel bzip2-devel gcc gcc-c++-y
2. Download php
Download the wget http://101.96.10.64/cn2.php.net/distributions/php-5.6.38.tar.gz # wget command
3. Compile and install
. / configure-- prefix=/usr/local/php-fpm\
-- enable-fpm-- with-zlib\
-- with-pdo-mysql\
-- enable-mbstring\
-- with-gd-- with-png-dir=/usr/lib64\
-- with-jpeg-dir=/usr/lib64\
-- with-freetype-dir=/usr/lib64
Make & & make install # installation
4. Optimization
Cp php.ini-development / usr/local/php-fpm/php.ini # copy configuration file
Ln-s / usr/local/php-fpm/bin/* / usr/local/bin/ # php command file soft link
Ln-s / usr/local/php-fpm/sbin/* / usr/local/sbin/ # php command file soft link
5. Install the accelerator for php
Tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz-C / opt/
Cd ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x
Cp ZendGuardLoader.so / usr/local/php-fpm/lib/php # copy the accelerator module to the php directory
6. Php recognition Accelerator
Vim / usr/local/php-fpm/php.ini # modify the configuration file by adding the following three lines
[Zend Guard Loader]
Zend_extension=/usr/local/php-fpm/lib/php/ZendGuardLoader.so
Zend_loader.enable=1
7. Enable php support for Nginx
Cd / usr/local/php-fpm/etc
Cp php-fpm.conf.default php-fpm.conf # copy profile template
Vi php-fpm.conf # modify the following
Pid = run/php-fpm.pid
User = php
Group = php
Pm.max_children=50
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Listen = 0.0.0.0 9000 # listens on all ports
8. Create a php user and start the service
Useradd-M-s / sbin/nologin php # create php user
/ usr/local/sbin/php-fpm # start the service
[root@localhost etc] # netstat-ntap | grep php # View port 9000
Tcp 00 0.0.0.0 mast 9000 0.0.0.0 mast * mast
9. Set up a php site
Mkdir-p / var/www/html/webphp
Cd / var/www/html/webphp
Echo "THIS IS PHP-NGINX TEST" > index.php # create site home page
10. Test and visit http://192.168.88.128/index.php
Fourth, set up SVN server
1. Install SVN
Yum install subversion-y # install SVN
[root@localhost ~] # svnserve-- version # View version information
Svnserve, version 1.7.14 (r1542130)
Compiled on Apr 11, 2018, 02, 40, Switzerland, 28
Copyright (C) 2013 Apache Software Foundation.
This software contains contributions from many people. Please check the file NOTICE for more information.
Subversion is open source software, see the http://subversion.apache.org/ site.
2. Create a SVN repository
Mkdir-p / opt/svn/ # create the svn directory first
The svnadmin create / opt/svn # svnadmin command uses this directory as a warehouse
[root@localhost ~] # ls / opt/svn/ # View svn warehouse
Conf db format hooks locks README.txt
3. SVN configuration file settings
Vim / opt/svn/conf/svnserve.conf # modify the configuration file
Anon-access = none
Auth-access = write
Password-db = / opt/svn/conf/passwd
Authz-db = / opt/svn/conf/authz
4. Configure passwd and authz files
Vim / opt/svn/conf/passwd
[users]
# harry = harryssecret
# sally = sallyssecret
Phpuser = 123123 # add user and password
The last line of vim / opt/svn/conf/authz # adds the following
[/]
Phpuser = r # has read permission in the / opt/svn directory
[/ webphp]
Phpuser = rw # has read and write access to webphp for uploading and downloading
5. Enable SVN service
[root@localhost svn] # svnserve-d-r / opt/svn # close svn use the kill command to kill the process
[root@localhost svn] # netstat-ntap | grep svn # View port
Tcp 0 0 0.0.0. 0 3690 0.0.0. 0. 0. 0.
6. Create the webphp directory and initialize the webphp directory
Cd / opt/svn # created under / opt/svn
Mkdir webphp # create a webphp directory
[root@localhost svn] # cd webphp/
[root@localhost webphp] # touch test.txt # webphp write content
[root@localhost webphp] # ls # View files
Test.txt
[root@localhost svn] # svn import webphp file:///opt/svn/repo/webphp-m "initialize" # initialize the webphp directory
Webphp/test.txt is being added
The submitted version is 1.
7. Test SVN
Yum install subversion-y # install svn first
Switch to the nginx server, under / usr/local/nginx/html
Svn cp svn://192.168.88.132/webphp
SVN test succeeded
Fifth, set up NFS server
1. Enable rpcbind and nfs services
Service rpcbind start
Service nfs start
2. Modify the configuration file
Vim / etc/exports
/ opt/php * (rw,sync) # all hosts can mount the / opt/php directory and have read and write permissions
3. Create directories and publish shares
Mkdir / opt/php
Exportfs-rv # release sharing
4. Client view
[root@localhost html] # showmount-e 192.168.88.133
Export list for 192.168.88.133:
/ opt/php *
5. Mounting
Mount.nfs 192.168.88.133:/opt/php / var/www/html/webphp/ # Mount nfs for local use
For mounting using MFS distributed storage, please read: https://blog.51cto.com/13760226/2286907
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.