CentOS 7, amp + xcache, rpm package, php-fpm

Source: Internet
Author: User
Tags config php mysql host php database wordpress database
<span id="Label3"></p><p>1. Experimental requirements:<br>1) CentOS 7, amp + xcache, rpm package, php-fpm;<br>A) depth: httpd, php, mariadb respectively deployed on a separate host, and both on the same host;<br>B) a virtual host to provide phpmyadmin, another virtual host to provide wordpress;<br>C) providing HTTPS services to phpmyadmim;<br><br>2. Experimental environment:<br>1) Server Environment<br>Linux Server OS version: CentOS release 6.7 (Final)<br>Http) ip:172.16.66.60<br>Php-fpm) ip:172.16.66.70<br>Mariadb) ip:172.16.66.70<br><br>2) test Environment<br>WIN7 system client): ip:172.16.66.100<br><br>3, the experimental premise:<br>1) Turn off firewall and SELinux<br># Service Iptables Stop<br># sed-i S/selinux=enforcing/selinux=disabled/g/etc/selinux/config<br># Systemctl Stop Firewalld<br># SYSTEMCTL Status Firewalld</p><p>2) Development Package Group<br># yum Groupinstall Development Tools Server Platform development-y<br><br>4, the experimental process:<br><br><br><br>The first part:<br>Deploying Hosts ip:172.16.66.60<br><br>1 Basic settings<br><br>1.1 Set HTTPD host name HOSTNAME<br>Echo "hostname=www1" >>/etc/sysconfig/network<br><br>1.2 Updating the HOSTS configuration file/etc/hosts<br># echo "172.16.66.60 www1 www2" >>/etc/hosts<br><br>1.3 Modifying DNS resolution settings<br>Vim/etc/resolv.conf<br><br>2 Installing httpd-2.4.6<br><br>2.0 Installing a dependent library package<br># yum Install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel<br><br>2.1 Compiling and configuring the HTTPD network server<br>tools]# Tar XF httpd-2.4.6.tar.bz2<br><br>2.2 Compiling related parameters<br>#./configure--prefix=/usr/local/apache24--sysconfdir=/etc/httpd24--enable-so--enable-ssl-- Enable-cgi--enable-rewrite \<br>--enable-modules=most--enable-mpms-shared=all--with-mpm=prefork--with-pcre--with-zlib--with-apr=/usr-- With-apr-util=/usr<br><br>2.3 Compiling<br># Make-j 4<br><br>2.4 Start Installation (install is copy Command)<br># make Install<br><br>2.5 Check the system library file for the corresponding path<br># ldconfig-v<br><br>2.6 Loaded Library file path<br># ldconfig-v<br><br>2.7 in The/etc/profile.d/directory vim apache.sh add the following to add environment variables for HTTPD.<br># Export Path=/usr/local/apache24/bin: $PATH<br><br>2.8 Making its environment variables effective<br># source/etc/profile.d/apache.sh<br><br>2.9 Importing Apache header files into the USR header file<br># LN-SV/USR/LOCAL/APACHE24/INCLUDE/USR/INCLUDE/HTTPD<br><br>2.10 If you do not want to configure the man file, you can use the full path, man help<br># Man/usr/local/apache24 HTTPD<br><br>2.11 Start Apachectl<br># Apachectl Start<br><br>2.12 Creating a backup directory for the configuration file<br># mkdir ~/confbak<br><br>2.13 Backup Profile ~: indicates the current logged on user folder-r: recursively all subdirectories<br># cp-r/etc/httpd24/~/confbak/<br><br>3. Create and configure a virtual host<br><br># cd/etc/httpd24/extra/<br><br>3.1 Configuring the virtual host (/etc/httpd24/extra/www1.conf)<br>Vim/etc/httpd/conf.d/www1.conf<br><br>Host WWW1<br>[email protected] conf.d]# Cat www1.conf<br><virtualhost *:80><br>ServerName WWW1<br># Serveralias www<br>DOCUMENTROOT/DATA/VHOSTS/WWW1 #注意这行末尾不要带/<br>Proxyrequests OFF<br>DirectoryIndex index.php<br>Proxypassmatch ^/(. *\.php) $ fcgi://172.16.66.70:9000/data/vhosts/www1/$1<br><directory "/data/vhosts/www1" ><br>Options None<br>AllowOverride None<br>Require all granted<br></Directory><br>Errorlog Logs/www1-error_log<br>Customlog Logs/www1-access_log Combien<br>#ServerSignature OFF<br></VirtualHost><br><br>3.2 Configuring the virtual host (/etc/httpd24/extra/www2.conf)<br>Vim/etc/httpd/conf.d/www2.conf<br><br>Host WWW2<br>[email protected] conf.d]# Cat www2.conf<br><virtualhost *:80><br>ServerName WWW2<br>Documentroot/data/vhosts/www2<br>Proxyrequests OFF<br>DirectoryIndex index.php<br>Proxypassmatch ^/(. *\.php) $ fcgi://172.16.66.70:9000/data/vhosts/www2/$1<br><directory "/data/vhosts/www2" ><br>Options None<br>AllowOverride None<br>Require all granted<br></Directory><br>Errorlog Logs/www2-error_log<br>Customlog Logs/www2-access_log Combien<br>#ServerSignature OFF<br></VirtualHost><br><br>3.3 Checking for syntax errors<br># httpd-t<br><br>3.4 Heavy Duty Apachectl Service<br># Apachectl Graceful<br><br>3.5 Creating a Site directory for a virtual host www{1,2}<br># mkdir/data/vhosts/www{1,2}-p<br><br>3.6 Testing www1/index.html static Web page<br># Curl Www1-i<br><br>4. Configure HTTPD24<br>4.1 Start the relevant module of httpd/etc/httpd24/httpd.conf<br>LoadModule Proxy_module modules/mod_proxy.so<br>LoadModule Proxy_fcgi_module modules/mod_proxy_fcgi.so<br>Include/etc/httpd24/extra/www2.conf<br>Include/etc/httpd24/extra/www1.conf<br><br>4.2 Delete original/usr/local/apache24/htdocs/<br># RM index.html<br><br>4.3 Enable Apache to recognize pages in PHP format<br>AddType application/x-httpd-php. PHP<br>AddType application/x-httpd-php-source. Phps<br><br><br>Part Ii:<br>Deploying the MARIADB host ip:172.16.66.80<br><br>1 Installing and configuring the MARIADB database service<br>1.1 Creating a directory for the Tools tool<br># Mkdir/tools<br><br>1.2 Extracting MARIADB to the specified directory<br># Tar XF mariadb-5.5.46-linux-x86_64.tar.gz-c/usr/local/<br><br>1.3 Creating MySQL Data Catalog<br># Mkdir-pv/data/mydata<br><br>1.4 Creating a MySQL system group<br># groupadd-r-g 306 MySQL<br><br>1.5 Creating a MySQL system user<br># useradd-r-g 306-u 306 MySQL<br><br>1.6 Authorization belongs to the main genus Group/data/mydata<br># Chown-r Mysql.mysql/data/mydata<br><br>1.7 Creating a soft connection<br># LN-SV mariadb-5.5.46-linux-x86_64 MySQL<br><br>1.8 Licensing MySQL installation package directory<br># Chown-r Root.mysql./<br><br>1.9 Compiling MARIADB<br># Scripts/mysql_install_db--user=mysql--datadir=/data/mydata<br><br>1.10 Creating a MySQL profile directory<br># Mkdir/etc/mysql<br><br>1.11 Copy the configuration file to the specified directory<br># CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MYSQL/MY.CNF<br><br>1.12 Modify the configuration file/ect/mysql/my.cnf add the following three lines to the server<br>DataDir =/data/mydata<br>Innodb_file_per_table = On<br>Skip_name_resolve = On<br><br>1.13 Adding mysqld service to boot<br># CP Support-files/mysql.server/etc/rc.d/init.d/mysqld<br><br>1.14 Execute permissions for mysqld<br># chmod +x/etc/rc.d/init.d/mysqld<br><br>1.14 Adding to the list of services<br># Chkconfig--add Mysqld<br><br>1.14 Add to boot auto start<br># chkconfig on<br><br>1.15 renaming/etc/my.cnf to My.cnf.bak<br># MV My.cnf My.cnf.bak<br><br>1.16 Add MySQL Environment variable/etc/profile.d/myslqd.sh<br>Export Path=/usr/local/mysql/bin:/usr/local/mysql/support-files: $PATH<br><br>1.17 making its MYSQLD environment variable effective<br># source/etc/profile.d/mysqld.sh<br><br>1.18 Importing the MYSQLD header file into the USR header file<br># Ln-sv/usr/local/mysql/include/usr/include/mysqld<br><br>1.19 Starting the Mysqld service<br># Mysql.server Start<br><br>1.20 to view memory usage<br># top-u MySQL<br><br>2. Configure using the MariaDB built-in Security configuration script<br><br>2.1 Performing a Security Configuration script configuration<br><br># mysql_secure_installation<br><br>2.2 Enter the password and return, here is the sample output, you can see the command prompt changes to MariaDB [(none)]><br># mysql-u Root-p<br><br>2.3 Create a new database for WordPress (this name is wordpress, You can also use other names)<br>MariaDB [(none)]> CREATE Database wordpress;<br><br>2.4 Create a new user and assign the database permissions to him (here is just an example, username admin, password is admin)<br>MariaDB [(none)]> Grant all on wordpress.* to ' admin ' @ ' 172.16.%.% ' identified by ' admin ';<br><br>2.5 Update Permissions<br>MariaDB [(none)]> Flush privileges;<br><br>2.6 Exiting the database<br>MariaDB [(none)]> quit<br><br>2.7 Creating a configuration file backup directory<br># mkdir ~/confbak<br><br>2.7 Backing up configuration files<br>#cp/etc/my.cnf ~/confbak/my.cnf.bak<br><br>Part Iii:<br>Deploying the php5.4.40 host ip:172.16.66.70<br><br>1 Installing and Configuring the PHP database service<br>1.1 Creating a directory for the Tools tool<br># Mkdir/tools<br><br>1.2 Creating a configuration file backup directory<br># mkdir ~/confbak/<br><br>1.3 Installing dependent libraries<br># yum Install libxm12-devel gd-devel freetype-devel libmcrypt-devel-y<br><br>1.3 Extracting PHP to the specified directory<br># Tar XF php-5.4.40.tar.bz<br><br>1.4 Compiling and installing PHP<br>#./configure--prefix=/usr/local/php54--with-mysql--with-mysqli--with-openssl--enable-mbstring--enable-xml-- Enable-sockets \<br>--enable-fpm--with-freetype-dir--with-gd--with-libxml-dir=/usr--with-zlib--with-bz2--with-png-dir--with-mcrypt \<br>--with-config-file-path=/etc/php54.ini--with-config-file-scan-dir=/etc/php54.d<br><br>1.5 Executing the Compile command<br># make<br><br>1.6 Executing the installation command<br># make Install<br><br>1.7 Copy the configuration file to The/etc/directory<br># Cp/tools/php-5.4.40/php.ini-production/etc/php54.ini<br><br>1.8 Soft Connector Header file to/usr/include/<br># ln-sv/usr/local/php54/include/usr/include/<br><br><br>2. Configure PHP-FPM<br><br>2.1 init script available for PHP-FPM<br># CP SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM<br><br>2.2 Execute permissions for PHP-FPM<br># chmod +X/ETC/RC.D/INIT.D/PHP-FPM<br><br>2.3 Adding to the list of services<br>~]# Chkconfig--add PHP-FPM<br><br>2.4 Set up auto run on boot<br># Chkconfig PHP-FPM on<br><br>2.5 Providing configuration files for PHP-FPM<br># cp/usr/local/php54/etc/php-fpm.conf.default/usr/local/etc/php-fpm.conf<br><br>2.6 Backing up the configuration file to the specified directory<br># cp-r/usr/local/php54/etc/~/confbak/<br><br>2.7 Edit Config PHP-FPM configuration file/usr/local/php54/etc/php-fpm.conf Modify the following 5 lines<br>Pm.max_children = 50<br>Pm.start_servers = 2<br>Pm.min_spare_servers = 2<br>Pm.max_spare_servers = 8<br>PID =/usr/local/php54/var/run/php-fpm.pid<br>Listen = 172.16.66.70:9000 Native Listener IP<br>listen.allowed_clients = 172.16.66.60 Allowed IP<br><br>2.8 Starting the PHP-FPM service<br># service PHP-FPM Start<br><br>2.9 See if the PHP-FPM service started successfully<br># PS aux | grep php-fpm<br><br>2.10 Viewing a listening socket<br># NETSTAT-TNLP | grep php-fpm<br><br>Part Iv: installation and configuration Wordpress,phpmyadmin<br>ip:172.16.66.70 in the PHP-FPM host environment<br><br>1. Install and configure WordPress<br><br>1.1 Unpacking the WordPress package<br>tools]# Unzip Wordpress-4.3.1-zh_cn.zip<br><br>1.2 Copy to Site Directory WWW1<br><br>CP WORDPRESS/DATA/VHOSTS/WWW1<br><br>1.3 Renaming the WordPress config file for wp-config.php<br>]# CP wp-config-sample.php wp-config.php<br><br>1.4 Modifying the wp-config.php File connection database<br>~]# sed-n ' 22,38p '/data/vhosts/www1/wordpress/wp-config.php<br>/** Name of WordPress database */<br>Define (' db_name ', ' WordPress ');<br><br>/** MySQL database user name */<br>Define (' db_user ', ' admin ');<br><br>/** MySQL Database password */<br>Define (' db_password ', ' admin ');<br><br>/** MySQL host */<br>Define (' db_host ', ' 172.16.66.80 ');<br><br>/** The default text encoding when creating data tables */<br>Define (' db_charset ', ' UTF8 ');<br><br>/** the database collation Type. If you are unsure do not change */<br>Define (' db_collate ', ');<br><br>2. Installing and configuring phpMyAdmin<br><br>2.1 Unpacking the phpMyAdmin package<br>tools]# Unzip Phpmyadmin-4.4.14.1-all-languages.zip<br><br>2.2 Copy to Site Directory WWW2<br>~]# Cp-r PHPMYADMIN-4.4.14.1-ALL-LANGUAGES/DATA/VHOSTS/WWW2<br><br>2.3 Configuring phpMyAdmin Software<br># LN-SV PHPMYADMIN-4.4.14.1-ALL-LANGUAGES/PMA<br><br>2.4 Renaming the profile name<br>~]# CP config.sample.inc.php config.inc.php<br><br>2.5 Generating Random numbers<br>~]# OpenSSL Rand-hex 8 #--> (640b56f72820ace8)<br><br>2.6 Modifying the configuration file connection database config.inc.php<br>~]# Vim config.inc.php<br>$cfg [' Blowfish_secret '] = ' 640b56f72820ace8 '<br>$cfg [' Servers '] [$i] [' Host '] = ' 172.16.66.80 ';<br>$cfg [' Servers '] [$i] [' User '] = ' admin ';<br>$cfg [' Servers '] [$i] [' Password '] = ' admin ';<br>$cfg [' Servers '] [$i] [' connect_type '] = ' TCP ';<br><br>3. Test PHP and Mariad connectivity<br><br>3.1 httpd-->php Whether you can access<br>www1]# Cat admin.php<br><?php<br>Phpinfo ();<br>?><br><br>3.2 httpd-->php--mariadb Whether you can access<br>www1] #cat index.php<br><?php<br>$conn = mysql_connect (' 172.16.100.71 ', ' admin ', ' admin ');<br>If ($conn)<br>Cho "ok";<br>Else<br>Echo "Failure";<br>?><br><br>4. Test WordPress and phpMyAdmin<br><br>4.1 Test in PC browser, whether WordPress can be normal way<br>http://www1/wordpress/index.php Access via 80 ports<br><br>4.2 Test in PC browser, according to the prompt to enter the database name and password (host account and password is authorized WordPress Users)<br>http://www2/pma/index.php<br><br><br>5. Install XCache Accelerator for PHP-FPM and configure<br><br>5.1 Unpacking the xcache3.3 package<br># Tar XF xcache-3.2.0.tar.bz2<br><br>5.2 Performing Mount interfaces in the/tools/xcache-3.2.0 directory<br>#/usr/local/php54/bin/phpize<br> <br>5.3 Compiling the installation<br>#./configure--enable-xcache--with-php-config=/usr/local/php54/bin/php-config<br><br># Make && make install</p><p><p><br></p></p><p>5.4 Editing php.ini, integrating PHP and XCache<br><br># CP/TOOLS/XCACHE-3.2.0/XCACHE.INI/ETC/PHP54.D<br><br><br>Part V: Providing HTTPS services for Phpmyadmim<br>ip:172.16.66.60 in the HTTPD host environment<br><br>Working directory:/etc/pki/ca/<br><br>1. Establish a private CA<br><br>1.1 Generating the private key<br>ca]# (umask 077; OpenSSL genrsa-out Private/cakey.pem 2048)<br><br>1.2 Generating self-signed certificates<br>ca]# OpenSSL Req-new-x509-key private/cakey.pem-out Cacert.pem<br>Country Name (2 Letter Code) [XX]:CN<br>State or province name (full Name) []:beijing<br>Common name (eg, your name or your server ' s Hostname) []:www2<br><br>1.3 Providing auxiliary files<br>ca]# Touch Index.txt<br>ca]# echo > Serial serial number<br>ca]# Tree<br>.<br>├──cacert.pem<br>├──certs<br>├──crl<br>├──index.txt<br>├──newcerts<br>├──private<br>│└──cakey.pem<br>└──serial<br><br>2. Node Request certificate<br><br>2.1 Generating the private key<br>~]# Mkdir-pv/etc/httpd/ssl<br>ssl]# (umask 077; OpenSSL genrsa-out httpd.key 1024)<br><br>2.2 Generate certificate Signing Request:<br>ssl]# OpenSSL Req-new-key httpd.key-out HTTPD.CSR<br>Country Name (2 Letter Code) [XX]:CN<br>State or province name (full Name) []:beijing<br>Common name (eg, your name or your server ' s Hostname) []:www2<br><br>2.3 Send request to CA<br>ssl]# CP httpd.csr/tmp/<br><br><br>3.CA issuing certificate<br><br>3.1 Signing certificate<br>~]# OpenSSL CA-IN/TMP/HTTPD.CSR-OUT/ETC/PKI/CA/CERTS/HTTPD.CRT<br><br>3.2 Send the signed certificate back to the Requestor.<br>~]# cp/etc/pki/ca/certs/httpd.crt/etc/httpd/ssl/<br><br>Note: This private build CA and node request certificates are completed on the same machine.<br><br>4. Configure HTTPD to support the use of ssl, and the use of certificates<br><br>4.1 Enabling the Mod_ssl module in httpd.conf<br>LoadModule Ssl_module modules/mod_ssl.so<br>Include/etc/httpd24/extra/httpd-ssl.conf<br><br>4.2 Modifying the configuration file ssl.conf<br>~]# cat/etc/httpd/conf.d/ssl.conf<br><VirtualHost><br>DocumentRoot "/data/vhosts/www2"<br>ServerName www2:443<br>Proxyrequests OFF<br>DirectoryIndex index.php<br>Proxypassmatch ^/(. *\.php) $ fcgi://172.16.66.70:9000/data/vhosts/www2/$1<br>Sslcertificatefile/etc/httpd24/ssl/httpd.crt<br>Sslcertificatekeyfile/etc/httpd24/ssl/httpd.key<br><directory "/data/vhosts/www2" ><br>Ssloptions +stdenvvars<br>AllowOverride None<br>Require all granted<br></Directory><br></VirtualHost><br><br><br>Part Vi: Stress test Report</p><p><p>This article is from the "8752057" blog, please be sure to keep this source http://yang90.blog.51cto.com/8752057/1828692</p></p><p><p>CentOS 7, amp + xcache, rpm package, php-fpm</p></p></span>

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.