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

Distributed deployment LAMP

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Deploy lamp on different hosts

Httpd host: 192.168.152.140

Php-fpm host: 192.168.152.141

Mariadb host: 192.168.152.142

Httpd

Yum-y install httpd

Vim / etc/httpd/conf.d/vhosts.conf

AddType application/x-httpd-php .phpDirectoryIndex index.php index.html ServerName www.test.com. DocumentRoot / http/vhosts/test.com ProxyPassMatch ^ / (. *\ .php) $fcgi://192.168.152.141:9000/var/www/test.com/$1 # 192.168.152.141 is the php-fpm host address Options none AllowOverride none Require all granted ServerName www.test1.com DocumentRoot / http/vhosts/test1.com ProxyPassMatch ^ / (. *\ .php) $fcgi: / / 192.168.152.141:9000/var/www/test1.com/$1 Options FollowSymLinks AllowOverride none Require all granted

Comment out the DocumentRoot in / etc/httpd/conf/httpd.conf

Mkdir-pv / http/vhosts/test.com

Php

Yum-y install php php-fpm php-mysql

Vim / etc/php-fpm.d/www.conf

Listen = 192.168.152.141listen.allowed_clients 9000 # this ip is the port 9000 listening on php-fpm native machine. If only the port number is reserved, port 9000 listen.allowed_clients = 192.168.152.140 # this ip is the host that allows access to php-fpm, that is, httpd host. Comment out means that any host is allowed to access.

Mkdir-pv / var/www/test.com

Vim / var/www/test.com/index.php

The php information page appears when visiting the 140host, indicating that httpd and php are deployed successfully.

Mariadb

Yum-y install mariadb-server

Vim / etc/my.cnf

[mysqld] innodb_file_per_table = ONskip_name_resolve = ON

Mysql

GRANT ALL PRIVILEGES ON *. * TO 'root'@'192.168.152.141' IDENTIFIED BY PASSWORD' passwd' # ip is the host address of the php-fpm that needs to access mysql, that is, the authorized php-fpm host can access mariadb

Edit 141host to test php-mysql connectivity

Vim / var/www/test.com/index.php

Success appears on the page as a success.

Xcache

Yum-y groupinstall "Development Tools"Server Platform Development"

Yum install php-devel

Wget xcache-3.2

Tar xf xcache-3.2.tar.bz2

Cd xcache-3.2.0

Phpize # generate configure script to php environment

. / configure-enable-xcache-with-php-config=/usr/bin/php-config

Make & & make install

Cp xcache.ini / etc/php.d/

Vim / etc/php.d/xcache.ini # makesure xcache.admin.enable_auth = ON;xcache.size = 60m

Systemctl restart httpd.service

Wordpress

192.168.152.140

Cd / http/vhosts/test.com

Wget https://cn.wordpress.org/wordpress-4.5-zh_CN.tar.gz

Tar xf wordpress-4.5-zh_CN.tar.gz

Cd wordpress/

Cp wp-config-sample.php wp-config.php

Vim wp-config.php

/ * * name of WordPress database * / define ('DB_NAME',' wordpressdb'); / * * MySQL database user name * / define ('DB_USER',' wpuser'); / * * MySQL database password * / define ('DB_PASSWORD',' 12345678'); / * MySQL host * / define ('DB_HOST',' 127.0.0.1')

192.168.152.141

Cd / var/www/test.com

Wget https://cn.wordpress.org/wordpress-4.5-zh_CN.tar.gz

Tar xf wordpress-4.5-zh_CN.tar.gz

Cd wordpress/

Cp wp-config-sample.php wp-config.php

Vim wp-config.php

/ * * name of WordPress database * / define ('DB_NAME',' wordpressdb'); / * * MySQL database user name * / define ('DB_USER',' wpuser'); / * * MySQL database password * / define ('DB_PASSWORD',' 12345678'); / * MySQL host * / define ('DB_HOST',' 127.0.0.1'); phpmyadmin

192.168.152.141

Yum-y install php-mbstring

Cd / var/www/test1.com

Wget https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-all-languages.tar.bz2

Tar xf phpMyAdmin-4.4.15.5-all-languages.tar.bz2

Ln-sv phpMyAdmin-4.4.15.5-all-languages pma

Cd phpMyAdmin-4.4.15.5-all-languages/

Cp config.sample.inc.php config.inc.php

Yum-y install php-mbstring

Openssl rand-base64 20

Vim config.inc.php

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

192.168.152.140

Cd / http/vhosts/test.com

Wget https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-all-languages.tar.bz2

Tar xf phpMyAdmin-4.4.15.5-all-languages.tar.bz2

Ln-sv phpMyAdmin-4.4.15.5-all-languages pma

Cd phpMyAdmin-4.4.15.5-all-languages/

Cp config.sample.inc.php config.inc.php

Yum-y install php-mbstring

Openssl rand-base64 20

Vim config.inc.php

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

Add https access for phpmyadmin

192.168.152.141 as CA

192.168.152.140 as SERVER

CA

Cd / etc/pki/CA

(umask 07710 OpenSSL genrsa-out private/cakey.pem 2048)

Openssl req-new-x509-key private/cakey.pem-out cacert.pem-days 3655

Country namestate or province namelocality nameorganization nameorganization unit namecommon nameemail address

Touch serial index.txt

Echo 01 > serial

SERVER

Cd / etc/httpd/

Mkdir ssl

(umask 07710 OpenSSL genrsa-out httpd.key 1024)

Openssl req-new-key httpd.key-out httpd.csr

Country namestate or province namelocality nameorganization nameorganization unit namecommon nameemail address

Send the generated certificate signing request httpd.csr to the CA for signature

The CA side signs the certificate

Openssl ca-in / any directory / httpd.csr-out / etc/pki/CA/certs/httpd.crt

Return the signed certificate to SERVER

On the server side

Yum-y install mod_ssl # installs modules that support ssl

Vim / etc/httpd/conf.d/ssl.conf # make a backup before editing the ssl configuration file

ServerName www.test1.com DocumentRoot / http/vhosts/test1.com ProxyPassMatch ^ / (. *\ .php) $fcgi://192.168.152.141:9000/var/www/test1.com/$1 Options FollowSymLinks AllowOverride none Require all granted SSLEngine on SSLCertificateFile / etc/httpd/ssl/httpd.crt SSLCertificateKeyFile / etc/httpd/ssl/httpd.key

Comment out the second VirtualHost in the / etc/httpd/conf.d/vhosts.conf configuration file to avoid conflicts

Httpd-t # checks for syntax errors

Systemctl restart httpd.service # restart the httpd service to make the configuration effective

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

Wechat

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

12
Report