Raspberry PI Raspbian 安裝 Web Server

CentOS系統網站安裝、架設與管理
回覆文章
inho
文章: 26
註冊時間: 2017-12-08, 23:00

Raspberry PI Raspbian 安裝 Web Server

文章 inho » 2018-02-11, 08:25

Raspberry PI Raspbian OS 安裝 Web Server 相關套件包括:Nginx, MariaDB、PHP-FPM
一、安裝 Nginx (不用 Apache,原因可查閱相關網站)
使用 “aptitude” package manager to install Nginx and php-fpm on the Raspberry from the Raspbian repositories.
https://howtoraspberrypi.com/install-ng ... web-server
$ sudo aptitude install nginx php-fpm
1、設定 Nginx
(1)、modify the folder containing your sites, add the index.php pages as default pages, and finally add PHP.
Nginx 設定檔在:/etc/nginx/sites-available/default
$ sudo vi /etc/nginx/sites-available/default
從檔案中找到這一行:
index index.html index.htm index.nginx-debian.html;
取代為:
index index.html index.htm index.php
(2)、設定在 Nginx 啟動時,也啟動 php-fpm
從檔案中找到這幾行:
# location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock;
#}
修改後:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
==================================================
修改之後存檔
2、修改首頁目錄的屬性及測試首頁
$ sudo chown -R www-data:pi /var/www/html/
$ sudo chmod -R 770 /var/www/html/
測試 phpinfo.php 的測試首頁
$ echo "<?php phpinfo(); ?>" > /var/www/html/index.php
$ echo 'Nginx work’s !' > /var/www/html/index.html

// 啟動 Nginx,並設定開機自動啟動:
$ sudo systemctl start nginx.service
$ sudo systemctl enable nginx.service
$ sudo /etc/init.d/nginx restart
$ sudo /etc/init.d/nginx restart
並利用瀏覽器 查看測試首頁是否成功,網址: http://localhosthttp://192.168.1.XXX

============================================================================
二、安裝MariaDB

回覆文章