樹苺派在2019年升級到了新的debian 10 也提供了新版本的php 使用,所以我們今天就針對php版本重新進行安裝,基本的laravel的環境.
安裝 php-7.3 及php_fpm
sudo apt install php7.3 php7.3-curl php7.3-gd php7.3-imap php7.3-json php7.3-mysql php7.3-opcache php7.3-xmlrpc php7.3-xml php7.3-fpm php7.3-zip php7.3-mbstring php7.3-sqlite3 php7.3-cli php7.3-readline -y
修改PHP7.3-FPM 使用者改為PI
vi /etc/php/7.3/fpm/pool.d/www.conf
#—-以下內容修改
#把 www-data 改成pi
;user = www-data
;group = www-data
user = pi
group = pi
###
;listen.owner = www-data
;listen.group = www-data
改成
listen.owner = pi
listen.group = pi
啟動PHP7.3-FPM
service php7.3-fpm start
systemctl enable php7.3-fpm
安裝Composer
sudo apt-get install composer
安裝 nodejs 和 npm
sudo apt-get install nodejs
sudo apt-get install npm
因為laravel需要用到nodejs所以安裝這些套件
安裝NIGNX HTTPD 伺服器
sudo apt-get install nginx
設定 nginx 的使用者為pi
sudo vi /etc/nginx/nginx.conf
#user www-data;
user pi;
修改預設的伺服器的php
sudo vi /etc/nginx/sites-available/default
#
#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;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
啟動NGINX
sudo serivce nginx start
sudo systemctl enable nginx
安裝laravel
composer create-project laravel/laravel laravel –prefer-dist
生成的laravel目錄會放置於/home/pi/laravel
設定nginx目錄指向laravel
sudo vi /etc/nginx/sites-available/default
#原始內容
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
#更改為以下內容
root /home/pi/laravel/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
重新啟動NGINX
sudo serivce nginx start
打完收功