In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Construction of LAMP:
Preparation prerequisites:
Virtual machine: Centos7 172.18.250.77 installs httpd, interacts with php through the Fcgi module, and only deals with static web pages.
Virtual machine: Centos7 172.18.250.78 installs the php-fpm program. The version of php-5.3.3 already includes php-fpm and does not need to be patched, but there is no php-fpm package for the official source on CentOS6, so experiment with CentOS 7.
Virtual machine: CentOS6 172.18.250.76 installs mysql to realize the interaction between php and mysql.
Httpd provides two virtual hosts to install wordpress blog and discuz forum.
1. Yum installs httpd
[root@localhost local] # yum-y install httpd
1. Edit the main configuration file and comment on DocumentRoot
[root@localhost httpd] # vim conf/httpd.conf#DocumentRoot "/ var/www/html"
2. Create a virtual host file
[root@localhost httpd] # cd / etc/httpd/conf.d/ [root@localhost conf.d] # vim vhost.conf ServerName www.a.com DocumentRoot "/ www/blog" Options None Allowoverride None Require all granted ProxyRequests Off ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.250.78:9000/www/blog/$1 ServerName www.b.net DocumentRoot "/ www/php" Options None Allowoverride None Require all granted ProxyRequests Off ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.250.78:9000/www/php/$1
3. Create the directory required for the virtual host
[root@localhost conf.d] # mkdir-p / www/blog [root@localhost conf.d] # mkdir-p / www/php
4. Start the httpd service and view the listening port
[root@localhost conf.d] # systemctl start httpd.service [root@localhost conf.d] # ss-tanLISTEN 0 128: 80:: *
5. Create a test page in the virtual host directory to see if httpd is normal.
[root@localhost conf.d] # echo "www.a.com" > / www/blog/index.html [root@localhost conf.d] # echo "www.b.net" > / www/php/index.html
OK, virtual host is normal
II. Install PHP for yum
[root@localhost ~] # yum-y install php-fpm
PHP-FPM is a PHPFastCGI manager, which is only used for PHP. Httpd transfers php files to php-fpm for processing through the Fcgi module.
1. Edit the php-fpm file
[root@localhost ~] # vim / etc/php-fpm.d/www.conflisten = 172.18.250.78 etc/php-fpm.d/www.conflisten 9000 / / Native IPlisten.allowed_clients = 172.18.250.77 / / httpd IP
2. Restart the php-fpm program to view the listening port
[root@localhost ~] # systemctl start php-fpm.service [root@localhost ~] # ss-tanLISTEN 0 128 172.18.250.78 root@localhost 9000 *: *
3. Create the same directory on php as on httpd
[root@localhost] # mkdir-p / www/blog [root@localhost ~] # mkdir-p / www/php
4. Create a test page and verify whether httpd can forward it.
[root@localhost ~] # mkdir-p / www/blog [root@localhost ~] # mkdir-p / www/php [root@localhost ~] # vim / www/blog/index.php [root@localhost ~] # vim / www/php/index.php
OK,httpd can read the file at the end of .php and forward it to php for processing
3. Yum installs mysql
[root@localhost ~] # yum-y install mysql-server
1. Start mysql and secure the database
[root@localhost ~] # service mysqld start [root@localhost ~] # mysql_secure_installationEnter current password for root (enter for none): / / default database password is empty Set root password? [Yzone] y / / set new password Remove anonymous users? [YBO] y / / remove anonymous user Disallow root login remotely? Do you want to prohibit users from logging in to Remove test database and access to it remotely? [YPop] y / / do you want to remove test database Reload privilege tables now? [YBO] y / / whether to restart the list of loading permissions
2. Create users and databases, and authorize php to log in remotely.
Mysql > grant all on *. * to 'admin'@'172.18.250.78' identified by "admin"; Query OK, 0 rows affected (0.00 sec) mysql > flush privileges;Query OK, 0 rows affected (0.00 sec) mysql > create database mytest;Query OK, 1 row affected (0.00 sec) mysql > create database bbs;Query OK, 1 row affected (0.01 sec)
3. Test whether php can log in to the database
[root@localhost ~] # yum-y install php-mysql / / install mysql driver [root@localhost ~] # vim / www/blog/index.php [root@localhost ~] # vim / www/php/index.php [root@localhost ~] # systemctl restart php-fpm.service
OK, the test is normal, you can install wordpress and Discuz forums
1. Extract the wordpress package on the php server and httpd, respectively.
[root@localhost blog] # unzip wordpress-4.3.1-zh_ unzip wordpress-4.3.1-zh_CN.zip [root @ localhost blog] # unzip wordpress-4.3.1-zh_CN.zip [root@localhost blog] # cd wordpress / / just change the name of [root@localhost wordpress] # cp wp-config-sample.php wp-config.php / * * WordPress database * / define ('DB_NAME',' mytest') on php / * * MySQL database user name * / define ('DB_USER',' admin'); / * * MySQL database password * / define ('DB_PASSWORD',' admin'); / * MySQL host * / define ('DB_HOST',' 172.18.250.76')
If this page appears, you only need to modify the httpd main configuration file so that httpd can recognize the file code of php.
[root@localhost blog] # vim / etc/httpd/conf/httpd.confAddType application/x-httpd-php .php / / add the following statement to AddType aaplication/x-httpd-source .phps DirectoryIndex index.php index.html
Restart the httpd service and test it again
Log in to the wordPress blog:
OK,WordPress blog can load normally.
1. Extract the Discuz package on the php server and httpd, respectively.
[root@localhost php] # unzip Discuz_X3.2_SC_UTF8.zip [root@localhost php] # unzip Discuz_X3.2_SC_ UTF8.zip [root @ localhost php] # cd upload / / on the php server
You can modify the permissions of the directory:
[root@localhost upload] # chown-R apache config/ [root@localhost upload] # chown-R apache uc_client/ httpd and php need to be changed to [root@localhost upload] # chown-R apache data [root@localhost upload] # chown-R apache template/ [root@localhost upload] # chown-R apache uc_server/
Just follow the steps step by step:
Log in to the forum after registration:
. Found that the forum only text, this is because php installed Discuz after the modification of the program files, when the static program files on httpd and php dynamic program files are not consistent, so just need to synchronize under the line.
[root@localhost php] # scp-r upload/* root@172.18.250.77:/www/php/upload/
Refresh again: OK
If you want to achieve automatic synchronization, you can use initory+rsync, sersync and other tools.
Four: install Xcahe to accelerate php
[root@localhost src] # tar-xf xcache-3.2.0.tar.bz2 / / just install the php developer kit [root@localhost xcache-3.2.0] # phpize / on the PHP server [root@localhost src] # lsxcache-3.2.0 xcache-3.2.0.tar.bz2 [root@localhost src] # cd xcache-3.2.0 [root@localhost xcache-3.2.0] # yum-y install php-devel / / check the version of php and the api interface Configuring for:PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525 [root@localhost xcache-3.2.0] #. / configure-- enable-xcache-- with-php-config=/usr/bin/php-config [root@localhost xcache-3.2.0] # make & & make install [root@localhost xcache-3.2.0] # cp xcache.ini / etc/php.d/ [root@localhost Upload] # ab-N100-c10 http://172.18.250.77/wordpress/index.phpBenchmarking 172.18.250.77 (be patient). DoneServer Software: Apache/2.4.6Server Hostname: 172.18.250.77Server Port: 80Document Path: / wordpress/index.phpDocument Length: 0 bytesConcurrency Level: 10Time taken for tests: 3.908 secondsComplete requests: 100Failed requests 0Write errors: 0Non-2xx responses: 100Total transferred: 34900 bytesHTML transferred: 0 bytesRequests per second: 25.59 [# / sec] (mean) / / ab stress test requests per second Time per request: 390.849 [ms] (mean) Time per request: 39.085 [ms] (mean Across all concurrent requests) Transfer rate: 8.72 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 0 0.30 1Processing: 104 369 95.7 368 589Waiting: 104 367 94.8 367 589Total: 105 369 95.7 368 589Percentage of the requests served within a certain time (ms) 50% 368 66% 410 75% 443 80% 455% 502 95% 536 98% 589 99% 589 100% 589 (longest request)
Restart the php-fpm service to see if xcache is loaded:
[root@localhost blog] # php-m [Zend Modules] / / indicates that xcache has enabled XCacheXCache Cacher
Do the ab stress test again:
[root@localhost upload] # ab-N100-c10 http://172.18.250.77/wordpress/index.phpBenchmarking 172.18.250.77 (be patient). DoneServer Software: Apache/2.4.6Server Hostname: 172.18.250.77Server Port: 80Document Path: / wordpress/index.phpDocument Length: 0 bytesConcurrency Level: 10Time taken for tests: 1.489 secondsComplete requests: 100Failed requests: 0Write errors: 0Non-2xx responses: 100Total transferred: 34900 bytesHTML transferred: 0 bytesRequests per second: 67.18 [# / sec] (mean) / / improved after loading xcache Time per request: 148.853 [ms] (mean) Time per request: 14.885 [ms] (mean Across all concurrent requests) Transfer rate: 22.90 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 0 0.20 1Processing: 38 141 31.0 139 240Waiting: 37 141 31.0 138 240Total: 38 141 31.0 139 240Percentage of the requests served within a certain time (ms) 50% 139 66% 152 75% 160 80% 168 90 179 95% 194 98% 216 99% 240 100% 240 (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.