服务器上安装Laravel(LNMP)

从零开始部署 Laravel(视频):https://www.codecasts.com/series/deploy-laravel-app-on-vps

从零开始部署 Laravel项目(文章): https://www.codecasts.com/discuss/laravel/laravel-project-from-scratch-deployment-752

1
2
3
4
5
6
7
8
9
10
11
12
13
apt-get update 
apt-get install php
apt-get install php-mysql
apt-get install php-fpm
apt-get install php-curl php-xml php-mcrypt php-json php-gd php-mbstring
apt-get install nginx
apt-get install mysql-server

vim /etc/php/7.1/fpm/php.ini // 将cgi.fix_pathinfo=1这一行去掉注释,将1改为0
vim /etc/php/7.1/fpm/pool.d/www.conf
// 配置这个 listen = /var/run/php/php7.1-fpm.sock
service php7.1-fpm restart
或者 /etc/init.d/php7.1-fpm restart

Nginx 基础配置如下:

vim /etc/nginx/sites-available/default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/laravel-ubuntu/public;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

还有就是,把你的项目根目录的所有者改为: www-data:www-data
最后给,storage 文件夹权限,重启 Nginxphp7.1-fpm
打赏

SPhard wechat
欢迎您扫一扫上面的微信公众号( 或者搜索:darrenliuwei )订阅
如果觉得本文对您有启发,可以随意打赏一点鼓励我继续更新!