Deployment of WordPress and DISCUZX based on fastcgi separation and lamp virtual host

Source: Internet
Author: User
Tags php and mysql php source code install wordpress

Background Virtual Host

Today's server configuration is significantly improved, the deployment of a single Web site on a single host will cause a lot of performance loss to the host, so the Web Services virtual host technology came into being. The so-called virtual host refers to the practice of running multiple websites (such as company1.example.com and company2.example.com) on a single machine. A virtual host can be "IP-based", which means that each site has a different IP address, or "Based on name," which means that there are multiple names on each IP address, or "Port-based", which means that different sites are available on different ports on the same IP. The fact that these methods make them run on the same physical server is not obvious to the end user.
Apache is one of the first servers to support IP-based virtual hosts. Version 1.1 and later versions of Apache support IP-based and name-based virtual hosts (virtual hosts). The latter variant of a virtual host is sometimes referred to as a host-based or non-IP virtual host.
  

FastCGI

FastCGI is like a resident (long-live) CGI, which can be executed all the time, so long as it is activated, it will not take a moment to fork once (this is the most notorious fork-and-execute mode of CGI). It also supports distributed operations where the FastCGI program can execute and accept requests from other Web servers on hosts other than the Web server.
FastCGI is a language-independent, extensible architecture for CGI open extensions whose main behavior is to keep the CGI interpreter process in memory and thus achieve high performance. As we all know, the repeated loading of CGI interpreter is the main reason of poor CGI performance, if the CGI interpreter remains in memory and accepts the FASTCGI process manager scheduling, it can provide good performance, scalability, fail-over characteristics and so on.
  
  

Deployment process

  

Deployment architecture

  

Environment

  
3 hosts for separate deployment of httpd,php and MySQL for separation
Software version

system httpd PHP mariadb
CentOS7 2.4.33 7.18 10.2.15-mariadb

  

Architecture diagram


  
  

Compiling software

  
Here we need to compile the software for httpd and Php,mysql can consider using binary package or direct official Yum installation
  

Install the development environment and the necessary packages

1. Installing the CentOS Development Kit

yum groupinstall "development tools" -y

2. Install the required packages for compiling httpd and PHP

#部分包需要epel源 #yum install epel-release -yyum install pcre-devel openssl-devel expat-devel libxml2-devel bzip2-devel libmcrypt-devel -y

  

Compiling httpd

This is compiled on the 192.168.99.130 machine httpd2.4

1. Create Apache Users

useradd -r apache -s /sbin/nologin

2. Extract the Httpd,apr,apr-util source package, the package you need here can be httpd the official website to

tar xvf httpd-2.4.33.tar.bz2tar xvf apr-1.6.2.tar.gztar xvf apr-util-1.6.1.tar.gz

3. Compiling httpd

 #移动解压的apr和apr-util到指定的httpd源码目录可以省去分别编译3个程序 mv apr-1.6.2 httpd-2.4.33/srclib/apr mv apr-util-1.6.1 httpd-2.4.33/srclib/apr-util#编译参数,具体含义可以参考./configure的帮助文档或者官方文档./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=preforkmake && make install

4. Configure Environment variables

vim /etc/profile.d/httpd.shPATH=/app/httpd24/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/binsource /etc/profile.d/httpd.sh

  

Compiling PHP

Since this is done for multi-machine separation, it is compiled on the 192.168.99.131 host
1. Extracting PHP Source code

tar xvf php-7.1.18.tar.bz2

2. Enter the catalogue

#编译参数./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfomake && make install

3. configuration File Settings

cd php-7.1.18/cp php.ini-production /etc/php.inicp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm#给予执行权限chmod +x /etc/init.d/php-fpm#添加到服务中chkconfig --add php-fpm#设置开机启动chkconfig php-fpm oncd /app/php/etccp php-fpm.conf.default php-fpm.confcp php-fpm.d/www.conf.default php-fpm.d/www.confservice php-fpm start

  

Installing MARIADB

  
There is no more talk about MARAIDB installation, the previous blog has detailed MARIADB deployment details. It is recommended that the direct Yum installation is good.
  
  

Configuration file Modification

  

Modifying the HTTPD Host

  

1. Support Agent Module

vim /app/httpd24/conf/httpd.conf#取消下面两行的注释LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so#修改下面行<IfModule dir_module>DirectoryIndex index.php index.html

2. Edit the virtual host configuration

<VirtualHost *:80>  DocumentRoot "/data/web1/wp"  ServerName www.douma.com  ErrorLog "logs/a.com.error_log"  TransferLog "logs/a.com-access_log"  AddType application/x-httpd-php .php  AddType application/x-httpd-php-source .phps  ProxyRequests Off  ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.99.131:9000/app/web1/wp/$1<directory "/data/web1/wp">require all granted</directory></VirtualHost><VirtualHost *:80>  DocumentRoot "/data/web2/dz"  ServerName www.fansity.com  ErrorLog "logs/b.com.error_log"  TransferLog "logs/b.com-access_log"<directory "/data/web2/dz">require all granted</directory>  AddType application/x-httpd-php .php  AddType application/x-httpd-php-source .phps  ProxyRequests Off  ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.99.131:9000/app/web2/dz/$1</VirtualHost>

3. Create a Site Directory

# httpd主机 mkdir -pv /data/web{1,2}#wordpress tar xvf wordpress-4.9.4-zh_CN.tar.gz mv wordpress web1/ cd web1 ln -sv wordpress wp #修改配置文件 vim web1/wp/wp-config-sample.php mv wp-config-sample.php wp-config.php


WordPress Basic configuration is completed, and then copied to the corresponding directory of the fast-cgi machine (to create a good directory on the corresponding host)

 scp -pr wordpress 192.168.99.131:/app/web1/

Installing DISCUZX

cd /data/web2/git clone https://gitee.com/ComsenzDiscuz/DiscuzX.gitcp -a DiscuzX/upload web2/ln -sv upload dz

Copy files to fast-cgi host (to create a corresponding directory on another host)

 scp -pr upload 192.168.99.131:/app/web2/

4. Start the HTTPD service

apachectl start

  

Modifying the FAST-CGI Host

  
1. Site Directory Modification

#创建对应目录,要在httpd主机复制文件到fast-cgi之前mkdir -pv /app/web{1,2}#创建软连接cd /app/web1ln -sv wordpress wp#复制配置文件并且修改mv wordpress/wp-config-simple.php  wordpress/wp-config.php vim  wordpress/wp-config.php cd /app/web2ln -sv upload dz


2.php Modify and add Apache user

useradd -r apache -s /sbin/nologinvim /app/php/etc/php-fpm.d/www.conf#修改运行用户为apache#修改监听ip#注释掉仅仅允许本机访问#重新启动php-fpmservice php-fpm restart#由于论坛安装时候会修改文件所以要给upload目录添加apache的权限setfacl -R -m u:apache:rwx /app/web2/upload/



  

Configure MySQL

  
1. Create an Account

MariaDB [(none)]> grant all on *.* to admin identified by ‘admin‘;#刷新权限MariaDB [(none)]> flush privileges;

2. Create WP database, the forum will be automatically created at the time of installation

MariaDB [(none)]> create database wp;

  

Hosts file modification of the host

  
Because it is based on the domain name of the virtual host, so in the absence of DNS, to normal access, it is necessary to repair the Hosts file on the host

#winC:\Windows\System32\drivers\etc\hosts#linux/etc/hosts#添加如下信息192.168.99.130  www.douma.com192.168.99.130  www.fansity.com

  

Install WordPress and DISCUZX

  
1. Install WordPress
Open www.douma.com on the host browser
will automatically jump to the installation page
Configure the corresponding information click Install wordpress


2. Installing DISCUZX
Open www.fansity.com on the host browser
Automatically jump to the installation page

Click Agree

Click Next

Continue to the next

Click Next to install automatically after completing

Installation Complete

Click Jump to Forum in the bottom right corner

Normal access, here the basic configuration of the forum is completed.

Deployment of WordPress and DISCUZX based on fastcgi separation and lamp virtual host

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.