安裝Nginx
關于apt命令
安裝PHP7.3
centos7安裝php,? ? ? ?3.1 Raspbian從stretch升級到Buster
? ? ? ?3.2?PHP7.3安裝設置
? ?4.?配置nginx解析PHP
更新樹莓派系統
sudo?apt-get?update???--更新的listsudo?apt-get?upgrade??--將軟件進行更新??不建議
centos安裝php,1、安裝 Nginx
sudo apt-get install nginx
2、啟動Nginx
sudo /etc/init.d/nginx start
或
centos7.5、sudo systemctl start nginx
查看Nginx運行狀態
sudo systemctl status nginx
重新加載Nginx,使配置生效
centos7.3?sudo systemctl reload nginx
3、測試安裝是否成功(nginx默認是80端口)。
將樹莓派的ip地址設為靜態ip(我的是192.168.1.131),先從內網測試是否安裝成功,在同一個局域網的機子上的瀏覽器上訪問 192.168.1.131。如果出現下圖則說明nginx安裝成功;
centos7安裝哪個版本。或者使用命令行命令:
curl 127.0.0.1
默認的網站根目錄:/var/www/html
nginx配置文件目錄:/etc/nginx/
nginx主配置文件位置:/etc/nginx/nginx.conf
centos安裝python3.6,其中主配置文件
/etc/nginx/nginx.conf
中引入配置文件
include /etc/nginx/sites-enabled/*;
在
/etc/nginx/sites-enabled/default
文件中引入默認主目錄
root /var/www/html;
nginx常用管理命令:
啟動nginx: sudo systemctl start nginx
關閉nginx:sudo systemctl stop nginx
設置nginx開機啟動:sudo systemctl enable nginx
apt-get update 更新軟件源中的所有軟件列表。?
apt-get upgrade 更新軟件。?
apt-get dist-upgrade 更新系統版本。如果你對新版本軟件的需求不是那么迫切,可以不執行
安裝Php?7.3
執行 sudo apt-get update 后,
安裝php?7.3?發現沒有找到
sudo apt-cache search php7.3-fpm
樹莓派3b(stretch)只支持到php7.0?
嘗試更新一下軟件源??-----這步沒必要,不用執行
樹莓派3B更換阿里云的軟件源
我的樹莓派使用的 stretch 系統
可能通過下面命令查看
lsb_release -sc
先備份一下原來的源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
編輯源文件
sudo nano /etc/apt/sources.list
將原來的deb.......和deb-src......兩行注釋掉
或者直接在這兩行修改
deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpideb-src http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
區別就在于域名
3、編輯后保存并退出文件,執行
sudo apt-get updatesudo apt-get upgrade -y
4、完成
上面幾步執行完后,還是找不到php7.3
即使單獨指定php的源,如下,也不能安裝成功
apt-get install apt-transport-https lsb-release ca-certificateswget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpgecho "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.listapt-get update
后來發現原來是目錄官方還不支持
stretch系統的php新版本(7.1 7.2 7.3),針對stretch只支持到php7.0
You will have to build from Source Code, though it may cause dependencies issues:
https://github.com/php/php-src
所以直接升級到buster,就可以直接安裝php7.3了
升級步驟如下:
1.In the files /etc/apt/sources.list and /etc/apt/sources.list.d/raspi.list, change every use of the word “stretch” to “buster”.
即把相關源還是換回來,修改后,兩個文件內容如下:
/etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi# Uncomment line below then 'apt-get update' to enable 'apt-get source'#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
/etc/apt/sources.list.d/raspi.list
deb http://archive.raspberrypi.org/debian/ buster main ui# Uncomment line below then 'apt-get update' to enable 'apt-get source'#deb-src?http://archive.raspberrypi.org/debian/?buster?main?ui
再執行如下命令
2.?sudo?apt?update3.?sudo?apt?dist-upgrade
重啟
然后執行如下命令
4. sudo apt purge timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk clipit usermode gucharmap gnome-system-tools pavucontrol
詳細查看
https://www.raspberrypi.org/blog/buster-the-new-version-of-raspbian/
升級完后,系統空間占用明顯增加
更新后,再次查詢php7.3
然后安裝PHP7.3:
sudo apt install -y -t buster php7.3-fpm php7.3-curl php7.3-gd php7.3-intl php7.3-mbstring php7.3-mysql php7.3-imap php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-xmlrpc php7.3-zip
通過下面命令查看安裝結果
php -v
查看php.ini配置文件位置
pi@raspberrypi:~ $ php -i|grep "Loaded Configuration File"Loaded?Configuration?File?=>?/etc/php/7.3/cli/php.ini
注意,
實際上配置文件有兩個,另外一個在/etc/php/7.3/fpm/php.ini。
通過命令行調用php時,會使用第一個配置文件;通過fpm調用php(例如nginx)會使用第二個配置文件。
php-fpm常用管理命令:
開啟php-fpm: sudo systemctl start php7.3-fpm
關閉php-fpm: sudo systemctl stop php7.3-fpm
重啟php-fpm: sudo systemctl restart php7.3-fpm
查看php-fpm: sudo systemctl status php7.3-fpm
編輯php-fpm配置文件:vi /etc/php/7.3/fpm/php-fpm.ini
編輯配置nginx文件:
sudo nano /etc/nginx/sites-enabled/default
找到index指令,添加index.php。修改后:
index index.php index.html index.htm index.nginx-debian.html;
找到# pass PHP scripts to FastCGI server后面的location,刪除注釋。修改后如下圖:
保存后重啟nginx:
sudo systemctl restart nginx
在網站根目錄創建一個php文件:
sudo vi /var/www/html/index.php
寫入以下php代碼并保存:
phpphpinfo();
在瀏覽器中輸入樹莓派的IP地址即可看到phpinfo。
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态