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

CentOS 7 fastcgi-based lamp

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

Share

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

Experimental environment CentOS 7, lamp (php-fpm)

Requirements: (1) the three are separated from three hosts

(2) one virtual host is used to provide phpMyAdmin; and the other virtual host is used to provide wordpress

(3) xcache

Plan to run the http server on 172.18.105.110

172.18.250.157 running database

172.18.253.26 run the php-fpm program

I finished the DNS ahead of time. The two A records of 172.18.105.110 correspond to www1.stu05.com www2.stu05.com.

Also made a CA server ahead of time.

Centos7 build http is 2.4 by default.

1. On 172.18.105.110, yum install httpd-y Note: at this time, php runs as a separate program.

Install the database on 172.18.250.157 yum install mariadb.server-y

At 172.18.253.26 yum install php-fpm php-mysql php-mbstring-y

Systemctl start httpd

Extension: 2.4http supports fastcgi, if you want to use to replace php with php-fpm

two。 Turn off the vim / etc/httpd/conf/httpd.conf # DocumentRoot "/ var/www/html" of the central host on 172.18.105.110

3. Configure the http-side virtual host site directory and the back-end php dynamic data site directory on 172.18.105.110 and 172.18.253.26 to forward requests

Mkdir-pv / web/vhosts/www1

Mkdir-pv / web/vhosts/www2

4. Configure FQDN-based virtual host vim / etc/httpd/conf.d/vhosts on 172.18.105.110

DirectoryIndex index.php- defines the default main page on which php runs

Http2.4 FQND-based virtual host saves the NameVirtualHost command

ServerName www1.stu05.com

DocumentRoot "/ web/vhosts/www1"

ProxyRequests Off turns off the forward agent

ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.253.26:9000/web/vhosts/www1/$1 Note: the http server forwards the cgi request to the PHP program of 172.18.253.26 through the proxy

Http2.4 needs access control to the root directory.

AllowOverride None

Options None

Require all granted

ServerName www2.stu05.com

DocumentRoot "/ web/vhosts/www2"-because the wordpress program automatically finds index.php from www2

ProxyRequests Off

ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.105.110:9000/web/vhosts/www2/wordpress/$1

Note: the absolute access path is used when forwarding to PHP.

AllowOverride None

Options None

5. Vim / etc/php-fpm.d/www.conf on 172.18.253.26

Listen = 172.18.253.26 the sokcet 9000 php service program needs to listen on the sokcet that can be accessed externally

Listen.allowed_clients = 172.18.105.110 which front-end http access is allowed

6. Create the session directory on 172.18.253.26 and make sure that the user running the php-fpm process has read and write access to this directory

# mkdir / var/lib/php/session

# chown apache.apache / var/lib/php/session

7. Test whether php is normal vim / web/vhosts/www1 and / web/vhosts/www1

Vim index.php

Php test code

Browser http://www1.stu05.com http://www2.stu05.com

7. Test whether the connection between php and mysql-server is normal

Log in to mysql as an administrator on 172.18.250.157 and authorize remote login users

CREATE DATABASE wpdb; creates a database

(1) GRANT ALL ON testdb.* TO testuser@'172.18.%.%' IDENTIFIED BY 'testpass'

Note: GRANT authorizes hosts on network segment 172.16.0.0 to remotely access all tables of testdb through testuser.

(2) FLUSH PRIVILEGES refresh takes effect immediately

Viewable user: SELECT USER ()

(3) reverse the user name when logging in with mysql off.

Add skip_name_resolve = ON after [mysqld] in the vim / etc/my.cnf configuration file

Then reload service mysqld reload

Vim / web/vhosts/www1 and / web/vhosts/www1 in 172.18.105.110

After you put it in index.php, run http://172.18.105.110

The lamp environment is successful.

Summary:

Any open source program needs to connect to the database, in the case of testing the lamp connection database ok, if it is a remote connection, you need to create an authorized remote connection user, while workdpress not only needs to create a database, but also needs an authorized remote connection user.

Remote host login database define ('DB_HOST',' 172.18.250.157'); local host login database define ('DB_HOST',' 127.0.0.1')

Local database root login if there is a password mysql-uroot-pxwj4611

If the local database root does not have a password mysql

8. The first virtual host runs wordpress

Cp wordpress-4.3.1-zh_CN.zip / web/vhosts/www1/

Unzip wordpress-4.3.1-zh_CN.zip

Ln-sv wordpress-4.3.1-zh_CN wordpress and then cd / wordpress

1 、 cp wp-config-sample.php wp-config.php

2. Execute mysql or if the local root has set the password mysql-uroot-pxwj4611-CREATE DATABASE wpdb; to create the database, most open source programs will create the database automatically.

3. GRANT ALL ON wpdb.* TO wpuser@'172.18.%.%' IDENTIFIED BY 'wppress'

Note: authorize this software to allow a user to connect to the database remotely, if it is a local connection 127.0.0.1

4. Vim vp-config.php edit configuration file

/ * * name of WordPress database * /

Define ('DB_NAME',' wpdb')

/ * * MySQL database user name * /

Define ('DB_USER',' wpuser')

/ * * MySQL database password * /

Define ('DB_PASSWORD',' wppasswd')

/ * * MySQL host * /

Define ('DB_HOST',' 172.18.105.110'); if it is a local connection loaclhost or 127.0.0.1

Test: www1.stu05.com/wordpress stress test ab-n 1000-c 100 http://www2.stu05.com/wordpress/index.php-c simulated concurrency-n simulated total number of requests

The local test does not take into account the bandwidth, the server may not run full bandwidth. Requests per second: 8.85 [# / sec] (mean) requests processed per second

9. The second virtual host runs phpMyAdmin

Preparatory work: cp phpMyAdmin-4.4.14.1-all-languages.zip / web/vhosts/www1/

Unzip phpMyAdmin-4.4.14.1-all-languages.zip

Ln-sv phpMyAdmin-4.4.14.1-all-languages pma Note: easy to roll back

I need to prepare an authorized remote link for the user who connects to the database in advance: can log in everywhere

(1), execute mysql or if the local root has set the password mysql-uroot-pxwj4611

(2), GRANT ALL ON wpdb.* TO myuser@'172.18.%.%' IDENTIFIED BY 'myuser'

1 、 cp config.sample.inc.php config.inc.php

2. Openssl ran-base64 15

3 、 vim config.inc.php

$cfg ['blowfish_secret'] =' 46aJFLiLxmqO0qrdGqwxupload; / * YOU MUST FILL IN THIS FOR COOKIE AUTH! * /-inside the random number

$cfg ['Servers'] [$I] [' host'] = '172.18.250.157remote connection to the host of the database

Test: www1.stu05.com/pma

Concurrency of stress test ab-n 1000-c 100 http://www1.stu05.com/pma/index.php-c simulation-total number of requests for n simulation

10. Compile and install xcache

# yum install php-devel

# cd xcache-3.2.0

# phpize

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

# make & & make install

# cp xcache.ini / etc/php.d/

Restart systemctl restart php-fpm

11. Provide https virtual host for phpMyAdmin

DirectoryIndex index.php

ServerName www1.stu05.com

DocumentRoot "/ web/vhosts/www1/myadmin"

ProxyRequests Off

ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.105.110:9000/web/vhosts/www1/myadmin/$1

SSLEngine on

SSLCertificateFile / etc/httpd/ssl/httpd.crt- points to the location of the certificate

SSLCertificateKeyFile / etc/httpd/ssl/httpd.key- points to the location of the public key

AllowOverride None

Options FollowSymLinks-- allows access to the source files of linked files

Require all granted

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