Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Three hosts deploy LAMP respectively

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Three hosts deploy LAMP respectively

Requirements: httpd, php, mariadb are deployed on a separate host, one virtual host provides phpMyAdmin, the other virtual host provides wordpress, and provides https services for phpMyAdmim

I. division of labor among three hosts

A httpd host 172.16.35.1

B php-fpm host 172.16.35.2

C mariadb host 172.16.35.3

Turn off the firewall here for the convenience of the experiment

# iptables-F

# setenforce0

Install the required rpm package:

Yum-y install httpd,B host yum-y install php-fpm on A, yum-y install mariade-server php-mysql on C

II. Httpd host settings

1. Set up vhost1.conf and vhost2.conf

[root@zq~] # vim / etc/httpd/conf.d/vhost1.conf

ServerNamewww1.test.com

DocumentRoot "/ data/vhost/www1"

ProxyRequestson

DirectoryIndexindex.php

ProxyPassMatch ^ / (. *\ .php) $fcgi://172.16.35.2:9000/data/vhost/www1/$1 dynamic Resource Agent forwards to the second host

OptionsNone

AllowOverrideNone

Requireall granted

[root@zq~] # vim / etc/httpd/conf.d/vhost2.conf

ServerNamewww2.test.com

DocumentRoot "/ data/vhost/www2"

ProxyRequestson

DirectoryIndexindex.php

ProxyPassMatch ^ / (. *\ .php) $fcgi://172.16.35.2:9000/data/vhost/www2/$1 dynamic Resource Agent forwards to the second host

OptionsNone

AllowOverrideNone

Requireall granted

two。 Modify the configuration file to specify NDS and domain name resolution

[root@zq~] # vim / etc/resolv.conf

# Generated by NetworkManager

DNS=172.16.35.1

Nameserver172.16.0.1

# Local domain name resolution

[root@zq ~] # vim / etc/hosts

127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4

:: 1localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.35.1www1.test.com www2.test.com

3. Create a static default file:

[root@zq~] # mkdir-p / data/vhost/www {1Jing 2}

[root@zq~] # vim / data/vhost/www1/index.html

Static data of the first physical machine of zq1 172.16.35.1

[root@zq~] # vim / data/vhost/www2/index.html

Static data of the first physical machine of zq2 172.16.35.1

4. Then test whether the native static data can be accessed properly.

=

3. Php-fpm host:

1. Modify the configuration file

[root@zq~] # vim / etc/php-fpm.d/www.conf

Listen = 172.16.35.2 9000 listens on the local address port

Listen.allowed_clients= 172.16.35.1 allows host A to connect

two。 Create resource mapping directories and files

Mkdir-pv/data/vhost/www {1pr 2}

[root@zq~] # vim / data/vhost/www1/index.php

The second physical machine a

[root@zq~] # vim / data/vhost/www2/index.php

The second physical machine b

3. Install Accelerator php-xcache

Yum-yinstall php-xcache

Decompress wordpress and php-myadmin in www1 and www2 respectively

4. Modify the configuration file of wordpress

[root@zq~] # cd / data/vhost/www1/wordpress/

[root@zq wordpress] # ln-s wp-config-sample.phpwp-config.php

[root@zq wordpress] # vim wp-config.php

/ / * * MySQL settings-specific information comes from the host you are using * * / /

/ * * name of WordPress database * /

Define ('DB_NAME','qqdb')

/ * * MySQL database user name * /

Define ('DB_USER','qquser')

/ * * MySQL database password * /

Define ('DB_PASSWORD',qqpass')

/ * * MySQL host * /

Define ('DB_HOST','172.16.35.3'); the address here is the database address that points to host C.

/ * default text encoding when creating a datasheet * /

Define ('DB_CHARSET','utf8')

/ * * Database collation type. If you are not sure, do not change * /

Define ('DB_COLLATE','')

5. Modify the configuration file of phpMyAdmin

[root@zqt ~] # ln-s/data/vhost/www2/ phpMyAdmin-4.4.14.1-all-languages/data/vhost/www2/myadmin

[root@zq] # ln-s / data/vhost/www2/myadmin/config.sample.inc.php/data/vhost/www2/myadmin/config.inc.php

[root@zq ~] # vim / data/vhost/www2/myadmin/config.inc.php

$cfg ['blowfish_secret'] =' 4pfPnDAJFPA4WMWaQxDuring; / * YOU MUST FILL IN THIS FOR COOKIE AUTH! * /

Use random code! R opensslrand-base64 15 generation for communication encryption

/ *

* Serversconfiguration

, /

$I = 0

/ *

* Firstserver

, /

$iTunes +

/ * Authentication type * /

$cfg ['Servers'] [$I] [' auth_type'] = 'cookie'

/ * Serverparameters * /

$cfg ['Servers'] [$I] [' host'] = '172.16.353 tcp'; $cfg [' Servers'] [$I] ['connect_type'] =' tcp'

$cfg ['Servers'] [$I] [' compress'] = false

$cfg ['Servers'] [$I] [' AllowNoPassword'] = false

IV. Mariadb host

1. Start the database being viewed and set it to boot

Systemctlstart mariadb.service

Systemctlstatus mariadb.service

Systemctlenabled mariadb.service

two。 Authorize the creation of users

[root@zq ~] # mysql

Mysql > GRANT ALL ON qqdb.* TO 'qquser'@'172.16.%.%' IDENTIFIED BY' qqpass'

Mysql > FLUSH PRIVILEGES

Mysql > CREATE DATABASE qqdb

=

5. Test whether php can connect to the database

Http://www1.test.com/ tests the static data of host A

The static data connection of the first host of http://www2.test.com/ succeeded.

The dynamic data access of the first virtual host of the second physical machine of http://www1.test.com/index.php succeeded.

The dynamic data access of the second virtual host of the second physical machine of http://www2.test.com/index.php was successful.

Http://www1.test.com/wordpress/index.php test forwards the second host and the first virtual host

Http://www2.test.com/myadmin/index.php test forwards the second host and the second virtual host

6. Provide https services to php-myadmin on host B. For more information, please see deployment of LAMP on a single host.

Seven. Stress test

Static data test for 1.httpd host html:

[root@zq~] # ab-c 100-n 1000 http://www1.test.com/data/vhost/www1/index.html static data

Time perrequest: 17.254 [ms] (mean) Ten test data are stable at this value.

Time perrequest: 0.172 [ms] (mean, across all concurrent requests)

Transferrate: 2495.00 [Kbytes/sec] received

Dynamic data test for 2.http host info () php:

[root@zq~] # ab-c 100-n 1000 http://www1.test.com/data/vhost/www1/index.php

ConcurrencyLevel: 100

Timetaken for tests: 0.423 seconds

Completerequests: 1000

Failedrequests: 0

Writeerrors: 0

Non-2xxresponses: 1000

Totaltransferred: 226000 bytes

HTMLtransferred: 16000 bytes

Requestsper second: 1613.49 [# / sec] (mean)

Time perrequest: 42.345 [ms] (mean) Ten test data are stable at this value.

Time perrequest: 0.493 [ms] (mean, across all concurrent requests)

Transferrate: 515.33 [Kbytes/sec] received

3. Testing wordpress dynamic data

[root@zq~] # ab-c 100-n 1000 http://www1.test.com/data/vhost/www1/wordpress/index.php

ConcurrencyLevel: 100

Timetaken for tests: 0.428 seconds

Completerequests: 1000

Failedrequests: 0

Writeerrors: 0

Non-2xxresponses: 1000

Totaltransferred: 226000 bytes

HTMLtransferred: 16000 bytes

Requestsper second: 2168.61 [# / sec] (mean)

Time perrequest: 47.690 [ms] (mean) Ten test data are stable at this value.

Time perrequest: 0.487 [ms] (mean, across all concurrent requests)

Transferrate: 46.59 [Kbytes/sec] received

4. Dynamic test myadmin data

[root@zq~] # ab-c 100-n 1000 http://www2.test.com/data/vhost/www2/myadmin/index.php

DocumentPath: / data/vhost/www2/myadmin/index.php

DocumentLength: 16 bytes

ConcurrencyLevel: 100

Timetaken for tests: 0.495 seconds

Completerequests: 1000

Failedrequests: 0

Writeerrors: 0

Non-2xxresponses: 1000

Totaltransferred: 226000 bytes

HTMLtransferred: 16000 bytes

Requestsper second: 2168.43 [# / sec] (mean)

Time perrequest: 45.840 [ms] (mean) Ten test data are stable at this value.

Time perrequest: 0.490 [ms] (mean, across all concurrent requests)

Transferrate: 486.59 [Kbytes/sec] received

Note that the data accepted by bash at a time cannot be greater than 10024, so the value should not be adjusted too high during the stress test.

5. Form:

Concurrent 100requests 1000

Concurrent 100requests 1000

Concurrent 100requests 1000

Do LAMP on a single host

122.684

119.658

118.152

Three hosts do LAMP

48.658

47.685

48.158

Therefore, the response speed of dynamic data will be greatly improved by using three hosts.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report