時間:2023-05-31 15:42:01 | 來源:網(wǎng)站運營
時間:2023-05-31 15:42:01 來源:網(wǎng)站運營
樹莓派+wordpress搭建個人網(wǎng)頁/博客:sudo apt install nginx #安裝Nginxsudo apt install php7.3 #安裝PHP及相關(guān)應(yīng)用,可能你安裝的時候7.3已經(jīng)不是最新版了,百度一下最新版然后修改版本號即可sudo apt install php7.3-fpmsudo apt install php7.3-mysqlsudo apt install php7.3-commonsudo apt install mariadb-server #安裝MaraiDB
之后我們需要對我們的Nginx進行一些簡單的配置,輸入下列命令sudo nano /etc/nginx/sites-available/default
找到和下面相對應(yīng)的部分并用下面的將原部分覆蓋# Default server configuration#server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html index.php; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # 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; # 設(shè)置腳本文件請求的路徑 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 引入fastcgi的配置文件 include fastcgi_params; } }
Ctrl+O保存文檔,Ctrl+X退出sudo /etc/init.d/nginx restartsudo /etc/init.d/php7.3-fpm restart
兩次均出現(xiàn)OK即表示重啟成功sudo service mariadb restart #輸入這兩行命令無任何提示是正?,F(xiàn)象sudo service nginx restart
接著輸入下列命令sudo chmod 777 /var/ #下面三行給文件授予權(quán)限sudo chmod 777 /var/wwwsudo chmod 777 /var/www/htmlcd /var/www/html #該文件夾下為網(wǎng)站根目錄sudo nano index.php #新建PHP文件進行測試
在index.php中輸入<?php phpinfo(); ?>,保存后退出,在瀏覽器中輸入你的樹莓派ip/index.php,如果看到了下圖的phpinfo 信息,說明php和nginx配置成功sudo apt install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html
完成后在瀏覽器內(nèi)輸入你的樹莓派ip/phpmyadmin,出現(xiàn)下方圖片即說明配置成功sudo mysql -u root -p #進入mariaDB環(huán)境,第一次登陸是沒有密碼的,直接按回車即可
輸入下列命令sudo chmod 777 /var/www/html/blog
之后你需要給你的網(wǎng)站創(chuàng)建一個數(shù)據(jù)庫,打開樹莓派瀏覽器進入phpmyadmin,點數(shù)據(jù)庫,輸入數(shù)據(jù)庫名就可以直接點創(chuàng)建了sudo apt install vsftpd #安裝ftpd服務(wù)
安裝成功后,ftpd就已經(jīng)可以登錄和瀏覽文件了,但是不能寫,需要更改寫權(quán)限。sudo passwd root
然后輸入兩遍密碼sudo --unlock root #解鎖root用戶
然后再輸入su,輸入剛剛的密碼,進入root用戶nano /etc/vsftpd.conf
去掉write_enable=YES前面的#,保存退出service vsftpd restart #重啟服務(wù)
之后再重啟樹莓派即可sudo apt install git
然后我們需要把我們的目錄設(shè)定在網(wǎng)站的根目錄下cd /var/www/html/
然后使用git工具將github上的開源項目pi dashboard給clone下來并賦予權(quán)限sudo git clone https://github.com/spoonysonny/pi-dashboard.gitsudo chown-R www-data pi-dashboard #為pi dashboard賦予權(quán)限
打開瀏覽器,輸入你的樹莓派IP/dashboard,即可看到樹莓派的資源使用情況關(guān)鍵詞:樹莓
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。