LAMP/LNMP pure original development schedule to install a key Shell (2)
LNMP yesterday began developing one-click installation progressed very quickly, almost nearing completion under Ubuntu 16 of LNMP + comes with PHP, LNMP + PPA + PHP 7.X. The reason why progress so quickly, because there are a lot of statements can be shared with the original LAMP statement. A key installation development environment LNMP more complicated than a lot of LAMP, the main one is a different system Nginx configuration file path varies; the second is the file path www.conf different; the third is different php-fpm restart process name. The solution is, www.conf find method to find; Nginx's PHP server process name with service --status-all | grep 'php' Find fpm process method.
For LNMP different systems Nginx configuration file path varies, the only solution is Ubuntu, Debian, CentOS three each introduced a new major version, you must re-commissioning again, if there are different, add a key command in the Shell The new rule.
In particular Nginx PHP service of process under Ubuntu 14 is php5-fpm, restart the process fpm command is service php5-fpm restart, next CentOS 6 is php-fpm, restart the process fpm command is service php-fpm restart.
16 to the process, the software that comes with PHP source Ubuntu is php7.0-fpm, restart the process fpm command is service php7.0-fpm restart.
PPA + PHP restart fpm command process, the same process name for services plus the version number, for example:
service php7.4-fpm restart
service php7.3-fpm restart
service php5.6-fpm restart
and many more.
LNMP and LAMP is a little different is that when you modify the Apache configuration file or php.ini, simply restart Apache. The LNMP the need to restart the Nginx, restart fpm process.
As a key generic version of PHP to determine the name of the service process it is very difficult, but fortunately there are service --status-all command to display all services, and screened out keyword "php" or "fpm", the command for the service --status-all | grep 'php', to display a PHP service process, and the result is displayed:
[+] Php7.4-fpm
In this case, it is necessary [+] and a space before php7.4-fpm all removed. Replace this statement with Shell:
The $ {a1} 123 is replaced in all 321:
b1 = $ {a1 // 123/321};
So [+] and remove all the Shell space program is:
a1 = `service --status-all | grep 'php'`;
a1 = $ {a1 // /};
a1 = $ {a1 // [/};
a1 = $ {a1 // +] /};
a1 = $ {a1 // -] /};
So, fpm command to restart the process under general LNMP is:
a1 = `service --status-all | grep 'php'`; a1 = $ {a1 // /}; a1 = $ {a1 // [/}; a1 = $ {a1 // +] /}; a1 = $ {a1 // -] /}; if [ "$ a1" x = '' x]; then service $ a1 restart; fi;!
Restart Nginx under LNMP, fpm command process is integrated in a key :( Shell command)
service nginx restart; a1 = `service --status-all | grep 'php'`; a1 = $ {a1 // /}; a1 = $ {a1 // [/}; a1 = $ {a1 // +] /}; a1 = $ {a1 // -] /}; if [ "$ a1" x = '' x]; then service $ a1 restart; fi;!
2019-09-18 09:08 UPDATE:
service --status-all | grep 'php' This command Ubnutu 16 perfect run, but only one fpm service process. But in Ubuntu under 12 will show a lot of other service process, so this command is not used, needs to be improved.
(End update)
Development LNMP installation there is a problem, because I was a main author of the production environment LAMP, and LNMP not a production environment deployment, it is more familiar with the LAMP environment. Apache functions a lot more than Nginx, and the performance is not worse than Nginx. At this stage I do not use Nginx, will only install, configure, test development. But at this stage domestic use Apache users less and less, and most people use Nginx, so I need to force myself to Nginx to use.
www.conf the generic version, the method find to find:
a1 = `find/etc -name 'www.conf'`;
a1 is this www.conf file, its role is mainly used to modify listen, must be changed to listen = 127.0.0.1: 9000, or after many Nginx + PHP installation, has been a 502 error, which is the key to the success of the installation LNMP.
In the last year writing the Ubuntu 14 + Nginx + PHP
The debugging found, Ubuntu 16 and 14 under Ubuntu is a little different.
This link above, has a fully automatic configuration in this new key Shell commands written in, and also configure the link above to write exactly the same.
LNMP a development of this key installation command, you need to modify the configuration file Nginx this:
#location ~ .php $ {
# Fastcgi_split_path_info ^ (/.+) $ (+ php..);
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# Fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# Fastcgi_pass unix: /var/run/php5-fpm.sock;
# Fastcgi_index index.php;
# Include fastcgi_params;
#}
Let a key installation program automatically modify the program, I let the program back up this file, and then using sed command, just replace the #location ~ .php $ exercising their right code is written as follows:
location ~ .php $ {
root/usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
include fastcgi_params;
}
Then PHP to run. After PHP can run PHP program and then delete the line with #. PHP program features much more than the Shell program, then Shell command to replace the configured file after modification.
Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/netweb/LAMP-LNMP-pure-original-development-schedule-to-install-a-key-Shell-2.htm