In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Deploy split LAMP+xcache (php-fpm mode) through compilation and installation
Request:
(1) use source code to compile and deploy separate LAMP, where php is based on php-fpm mode
(2) based on LAMP platform, one virtual host provides WordPress, and the other virtual host provides phpMyadmin.
(3) use xcache to provide cache for php to accelerate page access speed.
(4) do stress tests on one of the sites respectively, and compare the data before and after cache acceleration.
Environment:
192.168.1.103-> provide httpd services
192.168.1.104-> provide mariadb services
192.168.1.110-> provide PHP xcache services
Software package:
Httpd-2.4.6.tar apr-1.5.0.tar apr-util-1.5.2.tar # httpd2.4 version requires support of apr and apr-util packages above version 1.4
Mariadb-5.5.46-linux-x86_64.tar (binary package)
Php-5.4.26.tar
Xcache-3.1.0.tar
Wordpress-4.3.1-zh_CN
PhpMyAdmin-4.4.14.1-all-languages
-Segmentation line-
Compile and install service:
Compile and install the httpd service (192.168.1.103)
1. First of all, confirm whether the system has installed the httpd service. If so, we need to uninstall it in order to avoid conflicts with later.
2. Install the development package group
[root@pxe132 ~] # yum-y groupinstall Desktop Platform Development Development Tools
3. Compile and install apr and apr-util
Apr and apr-util are installed in the rpm package in centos7. Version 1.4 supports httpd. Here I will use the compilation method to do so.
# compile and install apr: [root @ pxe132 ~] # tar xf apr-1.5.0.tar.bz2 [root@pxe132 ~] # cd apr-1.5.0/ [root@pxe132 apr-1.5.0] #. / configure-- prefix=/usr/local/apr [root@pxe132 apr-1.5.0] # make-j 4 & & make install### compile and install apr-util: [root@pxe132 ~] # tar xf apr-util-1.5. 2.tar.bz2 [root@pxe132 ~] # cd apr-util-1.5.2/ [root@pxe132 apr-util-1.5.2] #. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr [root@pxe132 apr-util-1.5.2] # make-j 4 & & make install # View the result after compilation and installation: [root@pxe132 ~] # rpm-Q aprapr-1.4.8-3.el7.x86_64 [root@pxe132 ~] # rpm-Q apr-utilapr-util-1.5.2-6.el7.x86_64
4. Compile and install httpd
[root@pxe132 ~] # yum-y install pcre-devel openssl-devel libevent-devel [root@pxe132 ~] # tar xf httpd-2.4.6.tar.bz2 [root@pxe132 ~] # cd httpd-2.4.6/ [root@pxe132 httpd-2.4.6] #. / configure-- prefix=/usr/local/apache # # installation path-- sysconfdir=/etc/httpd24 # # configuration file path-- enable-so # # supports dynamic loading and unloading DSO mechanism DSO is a dynamic shared object, which can make the module take effect dynamically-- enable-ssl # # supports SSL/TLS to realize https function Openssl-devel development tools need to be installed-enable-cgi # # supports CGI scripts to open non-threaded MPM modules by default-enable-rewrite # # supports URL rewriting-enable-defalte # # supports compression-enable-modules=most # # supports dynamically enabled modules {all | most}-- enable-mpms-shared=all # # supports dynamically loaded MPM blocks {most | all}-- with-mpm=prefork # # set the default enabled mpm mode {prefork | worker | event}-- with-pcre # # use the specified pcre library You need to install the pcre-devel tool-- with-zlib # # use the specified zlib library-- with-apr=/usr/local/apr # # specify the apr installation path-- with-apr-util=/usr/local/apr-util # # specify the apr-util installation path, and then we can start the service: [root@pxe132 ~] # / usr/local/apache/bin/apachectl start, but this is not very convenient, so we need to do some more later:
5. Add PATH environment variables
[root@pxe132 ~] # vim / etc/profile.d/httpd24.sh export PATH=/usr/local/apache/bin:$PATH [root@pxe132 ~] # source / etc/profile.d/httpd24.sh # reread the file path to make it take effect immediately [root@pxe132 ~] # echo $PATH/usr/local/apache/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
6. Export the header file:
[root@pxe132 ~] # ln-sv / usr/local/apache/include/ / usr/include/httpd24
7. Start the service
[root@pxe132 ~] # apachectl start [root@pxe132 ~] # ss-tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *: 22 *: * LISTEN 0 128 127.0.0.1 LISTEN 631 *: * LISTEN 0128 127.0.0 .1 6012 *: * LISTEN 0 128: 80:: *
9. Test whether the httpd service is normal:
[root@pxe132 ~] # curl 192.168.1.103It works!
II. Compile and install the mariadb service (192.168.1.104)
1. For security, we, mysql, set up special users and groups to run as ordinary users.
[root@bogon ~] # groupadd-r mysql [root@bogon ~] # useradd-r mysql-g mysql [root@bogon ~] # id mysqluid=988 (mysql) gid=983 (mysql) groups=983 (mysql)
2. Set up a directory where data can be stored. You need to pay attention to the problem of permissions here.
[root@bogon ~] # mkdir-p / data/mydata [root@bogon ~] # chown-R mysql:mysql / data/mydata/ # this file will be used later when we install the package
3. Unpack the mariadb installation package to the / usr/local directory
[root@bogon] # tar xf mariadb-5.5.46-linux-x86_64.tar.gz-C / usr/local
4. Create a soft link for easy use
[root@bogon ~] # ln-sv / usr/local/mariadb-5.5.46-linux-x86_64/ mysql' mysql'->'/ usr/local/mariadb-5.5.46-linux-x86_64/'
5. At this point, we can go to the mysql directory and find that the owners of the genera and assemblages in it are all root, and all of them need to change their permissions.
[root@bogon] # cd / usr/local/mysql/ [root@bogon mysql] # lltotal 204drwxr-xr-x. 2 root root 4096 Jul 21 14:39 bin-rw-r--r--. 1 500 500 17987 Oct 10 2015 COPYING-rw-r--r--. 1 500 500 26545 Oct 10 2015 COPYING.LESSERdrwxr-xr-x. 3 root root 17 Jul 21 14:39 data-rw-r--r--. 1 500 500 8245 Oct 10 2015 EXCEPTIONS-CLIENTdrwxr-xr-x. 3 root root 18 Jul 21 14:39 include-rw-r--r--. 1 500 500 8694 Oct 10 2015 INSTALL-BINARYdrwxr-xr-x. 3 root root 4096 Jul 21 14:39 libdrwxr-xr-x. 4 root root 28 Jul 21 14:39 manlrwxrwxrwx. 1 root root 39 Jul 21 14:42 mariadb-5.5.46-linux-x86_64-> / usr/local/mariadb-5.5.46-linux-x86_64/drwxr-xr-x. 11 root root 4096 Jul 21 14:39 mysql-test-rw-r--r--. 1 500 500 108813 Oct 10 2015 README [root@bogon mysql] # chown-R root.mysql. / * # change the permissions of the file
6. Use the scripts script file mysql_install_db file provided by mysql to install the database, which indicates the user and data storage directory (that is, the user and data storage path we created at the beginning of the above).
[root@bogon mysql] # scripts/mysql_install_db-- user=mysql-- datadir=/data/mydata # note that it must be done under the mysql directory, but not if you switch to it.
7. Provide configuration files for mariadb, and there are templates (my-large.conf) in support-files.
[root@bogon mysql] # cp support-files/my-large.cnf / etc/my.cnf
8. Edit the configuration file to add directory information stored in the database
Datadir=/data/mydata # indicates that the data storage path of mysql innodb_file_per_table = ON # # becomes a separate tablespace skip_name_resolve = ON # # skip name resolution
9. Provide mysql service startup script, which has a template (mysql.server) in our support-file
[root@bogon support-files] # cp mysql.server / etc/rc.d/init.d/mysqld [root@bogon support-files] # chkconfig-- add mysqld # add to service startup
10. Add environment variables
[root@bogon ~] # vim / etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH [root@bogon ~] # source / etc/profile.d/mysql.sh
11. Export header file
[root@bogon local] # lsbin etc games include lib lib64 libexec mariadb-5.5.46-linux-x86_64 mysql sbin share src [root@bogon local] # [root@bogon local] # ln-sv include/ / usr/include/mysql'/usr/include/mysql'-> 'include/'
12. Export library files
[root@bogon local] # vim / etc/ld.so.conf.d/mysql.conf add: / usr/local/mysql/lib
13. Start the service and test whether it is normal
[root@bogon local] # systemctl start mysqld [root@bogon local] # ss-tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *: 3306 *: * [root@bogon local] # mysql Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 2Server version: 5.5.46-MariaDB-log MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] >
3. Compile and install php (192.168.1.110)
1. Install packages for development package groups and dependencies
[root@pxe130 ~] # yum groupinstall Development tools Server Platform Development [root@pxe130 ~] # yum-y install bzip2-devel libmcrypt-devel libxml2-devel openssl-devel
2. Compile and install php
[root@pxe130] # tar xf php-5.4.26.tar.bz2 [root@pxe130] # cd php-5.4.26/./configure-- prefix=/usr/local/php-- with-openssl-- with-mysql=mysqlnd-- with-pdo-mysql=mysqlnd-- with-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-mcrypt--with-config-file-path=/etc-- with-config-file-scan-dir=/etc/php.d-- with-bz2 [root@pxe130 php-5.4.26] # make-j 4 & & make install
Note: to support fpm, it is necessary to remove-- with-apxs and add-- enable-fpm. These two items cannot be used at the same time.
3. Provide php to provide configuration files
[root@pxe130 php-5.4.26] # cp php.ini-production / etc/php.ini
4. Provide php-fpm script and add it to the service startup list
[root@pxe130 php-5.4.26] # cp sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm [root@pxe130 php-5.4.26] # chmod + x / etc/rc.d/init.d/php-fpm [root@pxe130 php-5.4.26] # chkconfig-- add php-fpm
5. Provide php-fpm configuration file
[root@pxe130 php] # cd / usr/local/php [root@pxe130 php] # cp etc/php-fpm.conf.default etc/php-fpm.conf
6. Start the service
[root@pxe130 php] # systemctl start php-fpm [root@pxe130 php] # ss-tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.1 root@pxe130 php 9000 *: *
By this time, all our httpd mariadb php services have been compiled and installed, so we need to deploy the LAMP environment!
-Segmentation line-
Deploy the LAMP environment configuration:
1. Configure httpd: (192.168.1.103)
1. Enable modules that support fastFCGI
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
2. Enable virtual host
Include / etc/httpd24/extra/httpd-vhosts.conf
3. Add two exercises to support php
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
4. Configure virtual host
[root@pxe132 ~] # vim / etc/httpd24/extra/httpd-vhosts.confDirectory Index index.php DocumentRoot "/ data/vhost1/www1" ServerName wp.magedu.com ProxyRequests off ProxyPassMatch ^ / (. *\ .php) $fcgi://192.168.1.110:9000/data/vhost1/www1/$1 Options None AllowOverride None Require all granted DocumentRoot "/ data/vhost2/www2" ServerName pam.magedu.com ProxyRequests off ProxyPassMatch ^ / (. *\ .php) $fcgi://192.168.1.110:9000/data/vhost2/www2/$1 Options None AllowOverride None Require all granted
5. Create a web page path
[root@pxe132 ~] # mkdir-p / data/vhost1/www1 [root@pxe132 ~] # mkdir-p / data/vhost2/www2 [root@pxe132 ~] # echo "vhost1" > / data/vhost1/www1/index.html [root@pxe132 ~] # echo "vhost2" > / data/vhost2/www2/index.html
6. Whether the test of restarting the service is normal
[root@pxe132 ~] # apachectl-t Syntax OK [root@pxe132 ~] # apachectl restart [root@pxe132 ~] # curl http://wp.magedu.comvhost1[root@pxe132 ~] # curl http://pam.magedu.comvhost2 # ok our httpd service is no problem
2. Configure php-fpm (192.168.1.110)
1. Configure php listening address information
[root@pxe130 ~] # vim / usr/local/php/etc/php-fpm.confpid = run/php-fpm.pid # enable listen.allowed_clients = 192.168.1.103 # # listening allows IP address of htpd listen = 192.168.1.110 IP address [root@pxe130] # systemctl restart php-fpm.service [root@pxe130 ~] # ss-tnl State Recv-Q Send-Q Local where php can communicate with the outside Address:Port Peer Address:Port LISTEN 0 128 192.168.1.110 9000 *: *
2. Create the same path as the http page. Then test whether the relationship between php and http is normal
[root@pxe130 ~] # mkdir-p / data/vhost1/www1 [root@pxe130 ~] # mkdir-p / data/vhost2/www2 [root@pxe130 ~] # vim / data/vhost1/www1/index.php [root@pxe130 ~] # vim / data/vhost2/www2/index.php
3. Test:
Ok indicates that our php and httpd connections are normal.
3. Configure mariadb (192.168.1.104)
1. Create tables and authorize user permissions
MariaDB [(none)] > create database wpdb;### for WordPress preparation Query OK, 1 row affected (0.00 sec) MariaDB [(none)] > grant all on wpdb.* to 'wpuser'@'192.168.%.%' identified by' wppass';Query OK, 0 rows affected (0.03 sec) MariaDB [(none)] > create database pma # for phpmyadmin preparation Query OK, 1 row affected (0.01 sec) MariaDB [(none)] > grant all on pma.* to 'pmauser'@'192.168.%.%' identified by' pmapass';Query OK, 0 rows affected (0.00 sec)
2. Write a test page in the php service to test whether php and mariadb are connected properly.
[root@pxe130 ~] # vim / data/vhost1/www1/index.php [root@pxe130 ~] # vim / data/vhost2/www2/index.php
3. Testing
Ok to now our LAMP platform environment is well done!
-Segmentation line-
Deploy applications WordPress and phpmyadmin based on LAMP
The following operations are done here in the php server:
First, deploy WordPress
1. Decompress and configure connection password and user and database address
[root@pxe130 ~] # unzip wordpress-4.3.1-zh_CN.zip [root@pxe130 ~] # mv wordpress/ data/vhost1/www1/ [root@pxe130 ~] # cd / data/vhost1/www1/wordpress/ [root@pxe130 wordpress] # mv wp-config-sample.php wp-config.php [root@pxe130 wordpress] # vim wp-config.php / * * WordPress database name * / define ('DB_NAME',' wpdb') / * * MySQL database user name * / define ('DB_USER',' wpuser'); / * * MySQL database password * / define ('DB_PASSWORD',' wppass'); / * MySQL host * / define ('DB_HOST',' 192.168.1.104')
2. At this point, we need to upload the directory WordPress to the path to the home page of the http server.
Root@pxe130 www1] # scp-r wordpress/ root@192.168.1.103:/data/vhost1/www1/
II. Deploy phpmyadmin
1. Decompression, configuration
[root@pxe130 ~] # unzip phpMyAdmin-4.4.14.1-all-languages.zip [root@pxe130 ~] # mv phpMyAdmin-4.4.14.1-all-languages/ data/vhost2/www2/ [root@pxe130 www2] # ln-sv phpMyAdmin-4.4.14.1-all-languages/ phpmyadmin [root@pxe130 www2] # vim phpmyadmin/libraries/config.default.php$cfg ['blowfish_secret'] =' tSQRO02T+grA6rvJHCXr';$cfg ['Servers'] [$] [' host'] = '192.168.1.104' # Database service address $cfg ['Servers'] [$I] [' user'] = 'pmauser';$cfg [' Servers'] [$I] ['password'] =' pmapass'
2. Send a copy of the phpmyadmin to the http server under the corresponding path
[root@pxe130 www2] # scp-r phpmyadmin/ root@192.168.1.103:/data/vhost2/www2/
Test:
4. Stress test:
Server Software: Apache/2.4.6Server Hostname: wp.magedu.comServer Port: 80Document Path: / wordpressDocument Length: 239 bytesConcurrency Level: 1000Time taken for tests: 3.096 secondsComplete requests: 10000Failed requests: 0Write errors: 0Non-2xx responses: 10006Total transferred: 4672802 bytesHTML transferred: 2391434 bytesRequests per second: 3229.61 [# / Sec] (mean) Time per request: 309.635 [ms] (mean) Time per request: 0.310 [ms] (mean Across all concurrent requests) Transfer rate: 1473.76 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 1 64 319.1 3 3030Processing: 1 55 186.0 21 1454Waiting: 1 54 185.9 20 1454Total: 12 120 426.7 24 3042Percentage of the requests served within a certain time (ms) 50% 24 66% 25 75% 26 80% 27 90% 30 95% 691 98% 1649 99% 2462 100% 3042 (longest request)
Compile and install xcache cache acceleration
1. Unpack and generate configuration
[root@pxe130 /] # tar xf xcache-3.2.0.tar.bz2 [root@pxe130 /] # cd xcache-3.2.0/ [root@pxe130 xcache-3.2.0] # / usr/local/php/bin/phpize Configuring for:PHP Api Version: 20100412Zend Module Api No: 220100525 [root@pxe130 xcache-3.2.0] #. / configure-- enable-xcache-- with-php-config=/usr/local/ Php/bin/php-config [root@pxe130 xcache-3.2.0] # make & & make install
2. Configure xcache
[root@pxe130 ~] # cp / xcache-3.2.0/xcache.ini / etc/php.d/ [root@pxe130 ~] # vim / etc/php.d/xcache.ini add: [xcache-common] extension = / usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so modified cache size: xcache.size = 200m
3. Restart the php-fpm service, and there should be xcache support on the index.php page.
[root@pxe130 ~] # systemctl restart php-fpm.service
Stress tests are being carried out:
[root@bogon ~] # ab-n 10000-c1000 http://wp.magedu.com/wordpressServer Software: Apache/2.4.6Server Hostname: wp.magedu.comServer Port: 80Document Path: / wordpressDocument Length: 239 bytesConcurrency Level: 1000Time taken for tests: 2.128 secondsComplete requests: 10000Failed requests: 0Write errors: 0Non-2xx responses: 10000Total transferred: 4670000 bytesHTML transferred: 2390000 bytesRequests per second: 4700.07 [# / sec] (mean) Time per request: 212.763 [ms] (mean) Time per request: 0.213 [ms] (mean) Across all concurrent requests) Transfer rate: 2143.49 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 1 37 116.1 23 1028Processing: 1 46 129.4 26 1480Waiting: 1 40 129.8 20 1474Total: 24 83 189.7 49 1646Percentage of the requests served within a certain time (ms) 50% 49 66% 52 75% 53 80% 55 90% 59 95% 78 98% 726 99% 1458 100% 1646 (longest request)
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.