raspbian-buster安裝Nginx並調用php

//安裝
$ sudo apt-get install nginx -y
//啓動狀態相關命令
$ sudo  systemctl status nginx.service
$ sudo  systemctl start nginx.service
$ sudo  systemctl stop nginx.service
$ sudo  systemctl enable nginx.service
//要安裝php 參考 https://blog.csdn.net/qq_35590198/article/details/100659154
$ sudo vim /etc/nginx/sites-enabled/default		
//配置參考,分爲2個部分,第一個是index行要添加index.php,如下:
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;
//第二個是要刪除 pass PHP scripts to FastCGI server 中的幾行註釋,如下:
        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }
 //保存退出
 $ sudo systemctl restart nginx.service		//重啓Nginx
 //
$ sudo nano /var/www/html/phpinfo.php	//添加phpinfo文件,寫入如下內容
<?php
phpinfo();
?>
//瀏覽器輸入ip/phpinfo.php測試,顯示php內容即正常
http://raspbian_ip/phpinfo.php
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章