In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "LNMP architecture construction and application deployment method". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Preparations:
Centos 7 Server, CD
MySQL deployment can refer to the blog post: blog.51cto.com/14227204/2425596
For Nginx deployment, please refer to the blog post: blog.51cto.com/14227204/2435579
Prepare PHP source package: pan.baidu.com/s/1WARKfQ5ndcL5t5MqXq13zg
Extraction code: 4zjx
Second, install PHP parsing environment:
Newer versions of PHP already come with FPM modules to manage PHP parsing instances and optimize parsing efficiency. So you need to add "--enable-fpm" at compile time to start this module.
[root@mysql /]# yum -y install gd libxml2-devel libjpeg-devel libpng-devel[root@mysql /]# tar zxf php-5.5.38.tar.gz -C /usr/src/[root@mysql php-5.5.38]# ./ configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm--with-jpeg-dir=/usr/lib && make && make install #Configuration and compilation installation (long process)
Adjustment after installation:
[root@mysql php-5.5.38]# cp php.ini-development /usr/local/php5/php.ini[root@mysql /]# ln -s /usr/local/php5/bin/* /usr/local/bin/[root@mysql /]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/ #Create link files for easy command use
Install ZendGuardLoader: (Speed up Nginx processing speed, can be omitted)
[root@mysql /]# tar zxf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src/[root@mysql /]# cd /usr/src/zend-loader-php5.5-linux-x86_64/[root@mysql zend-loader-php5.5-linux-x86_64]# cp ZendGuardLoader.so /usr/local/php5/lib/php/ #Copy zend file to PHP directory [root@mysql /]#vim/usr/local/php5/php.ini #Write the following two lines... zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.sozend_loader.enable=1
Configure Nginx to support PHP environments:
To enable Nginx to parse PHP web pages, there are two options: one is to act as an intermediary, forwarding web requests to PHP pages to other servers (LAMP) for processing; the other is to invoke the native PHP environment by using PHP's FPM module.
1. Enable php-pfm process (this process listens on port 9000 by default):
[root@mysql ~]# cd /usr/local/php5/etc/[root@mysql etc]# cp php-fpm.conf.default php-fpm.conf [root@mysql etc]# useradd -M -s /sbin/nologin php #Create PHP user [root@mysql etc]# vim php-fpm.conf.................................................................. pid = run/php-fpm.pid #Confirm pid file location user = php #Run user group = php #Run group pm.start_servers = 20 #Number of processes open at startup pm.min_spare_servers = 5 #Minimum number of idle processes pm.max_spare_servers = 35 #Maximum number of idle processes pm.max_children = 50 #Maximum number of child processes [root@mysql /]# /usr/local/sbin/php-fpm #Start fpm service [root@mysql /]# killall php-fpm Stop serving
In the php-fpm.conf configuration file, the PID information storage location indicated by the pid configuration item corresponds to the actual path: /usr/local/php5/var/run/php-fpm.pid. According to the above configuration, you can modify the Nginx service script to automatically start/stop the php-fpm process when starting/stopping the Nginx server.
[root@mysql /]# vim /etc/init.d/nginx #!/ bin/bash# chkconfig: - 99 20PROG="/usr/local/nginx/sbin/nginx"PIDF="/usr/local/nginx/logs/nginx.pid"PROG_FPM="/usr/local/sbin/php-fpm"PIDF_FPM="/usr/local/php5/var/run/php-fpm.pid"case "$1" in start) $PROG $PROG_FPM ;; stop) kill -s QUIT $(cat $PIDF) kill -s QUIT $(cat $PIDF_FPM) ;; restart) $0 stop $0 start ;; reload) kill -s HUP $(cat $PIDF) kill -s HUP $(cat $PIDF_FPM) ;; *) echo "USAGE:$0 {start | stop | restart | reload}" exit 1esacexit 0[root@mysql /]# systemctl daemon-reload #Reload the daemon, otherwise you will be prompted [root@mysql /]# systemctl restart nginx #Restart service to confirm script [root@mysql /]# netstat -anpt| grep 9000tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 64964/php-fpm: mast [root@mysql /]# netstat -anpt | grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 64961/nginx: master
After the above configuration, Nginx and fpm are tied together. Once the Nginx service is started or closed, the php-fpm program will also be started or closed. There is no need to start or close php-fpm additionally.
Configuration Nginx support PHP parsing:
Whether you are handing PHP pages to LAMP servers for parsing or calling native php-fpm processes, you need to add the location setting to the "server { }" configuration section to specify which action to take when accessing php pages.
The configuration items for both methods can be found in the corresponding templates at the end of the configuration file. Copy it to the appropriate location and modify it slightly to use it.
For the first method, you can skip the php-fpm configuration above (hand it off to other web servers for processing, using the following configuration statement):
[root@localhost etc]# vim /usr/local/nginx/conf/nginx.conf ...................# Omit some content server { ................... location ~ \.php$ { #Visit the configuration section of the.php page proxy_pass http://192.168.1.20:80; # Apache Server listening address } ................... //omitting some content}
Here I use the second method (calling the native php-fpm process) configured as follows:
server {..................... location ~ \.php$ { root /var/www/test1; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi.conf }[root@mysql /]# vim /var/www/test1/test.php #Writing test pages
LNMP Platform Deploys Web Applications:
Here I use Discuz!, A community forum. It can be downloaded officially at http://www.discuz.net
Deployment program code:
[root@mysql /]# unzip Discuz_X3.3_SC_UTF8.zip [root@mysql /]# mv upload/ /var/www/test1/bbs The requested URL/wp-content/upload/index.php was not found on this server. #Modify the parent group
Creating a database:
[root@mysql /]# mysql -u root -p Enter password: //Enter password mysql> create database bss; //create a dedicated database mysql> grant all on BBS.* to runbbs@localhost identified by 'pwd123'; //Set permissions and administrator user
Install Discuz:
Visit www.test1.com/bbs/admin.php Log in to the background to see:
The content of "LNMP architecture construction and application deployment method" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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: 221
*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.