nginxÔõôÆô¶¯php
ÔõÑùÔÚ nginx ÖÐÆô¶¯ php£¿ÔÚ nginx ÖÐÆô¶¯ php µÄ°ì·¨£º1. ×°Öà php£»2. ×°Öà php-fpm£»3. ÉèÖà nginx ÐéÄâÖ÷»úÒÔʹÓà php-fpm¡£
ÔõÑùÆô¶¯ nginx ÖÐµÄ PHP
¼òÒª»Ø¸²£º
ÔÚ nginx ÖÐÆô¶¯ PHP µÄ°ì·¨£º
×°ÖÃ PHP
×°Öà PHP-FPM£¨FastCGI Àú³ÌÖÎÀíÆ÷£©
ÉèÖà nginx ÐéÄâÖ÷»úÒÔʹÓà PHP-FPM
Ïêϸ˵Ã÷£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
1. ×°Öà PHP£º
ʹÓÃÒÔÏÂÏÂÁî×°Öà PHP£º
sudo apt-get update sudo apt-get install php7.4-fpm
µÇ¼ºó¸´ÖÆ
2. ×°Öà PHP-FPM£º
ʹÓÃÒÔÏÂÏÂÁî×°Öà PHP-FPM£º
sudo apt-get install php7.4-fpm
µÇ¼ºó¸´ÖÆ
3. ÉèÖà nginx ÐéÄâÖ÷»ú£º
·¿ªÐéÄâÖ÷»úÉèÖÃÎļþ£¨ÀýÈ磬/etc/nginx/sites-available/example.com£©£¬²¢Ìí¼ÓÒÔÏÂÉèÖãº
location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
µÇ¼ºó¸´ÖÆ
ÆäÖУº
location ~ \.php$£ºÆ¥ÅäËùÓÐÒÔ .php ×îºóµÄÎļþ
try_files $uri =404;£ºÈôÊÇÎļþ²»±£´æ£¬Ôò·µ»Ø 404 ¹ýʧ
fastcgi_pass unix:/run/php/php7.4-fpm.sock;£º½«ÇëÇóת·¢µ½ PHP-FPM Ì×½Ó×Ö
fastcgi_index index.php;£ºÖ¸¶¨Ä¬ÈÏË÷ÒýÎļþ
include fastcgi_params;£º°üÀ¨ FastCGI ²ÎÊý
ÉúÑIJ¢Í˳öÉèÖÃÎļþ¡£
ÖØÆô nginx£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
PHP ÏÖÔÚÓ¦¸ÃÔÚ nginx ÖÐÆô¶¯²¢ÔËÐС£
ÒÔÉϾÍÊÇnginxÔõôÆô¶¯phpµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡