Ubuntu环境下配置laravel运行环境
一、实现过程的参考信息
二、具体操作步骤
1、前提条件:需有lnmp运行环境
2、配置composer
代码如下:
$:curl -sS https://getcomposer.org/installer | php
$:mv composer.phar /usr/local/bin/composer
3、配置参数
进入nginx.conf配置参数
cd /usr/local/nginx/conf
vi nginx.conf
可以看到:
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
#设置主页默认路径 laravel项目/public
root /home/wwwroot/default/public;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
#删除php配置,否则try_files会出错,无法搜索laravel路径
# include enable-php.conf;
#新增 支持laravel 优雅链接
location / {
try_files $uri $uri/ /index.php?$query_string;
}
#新增 支持php 的配置
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#--------------------------------------不变----------------------------------------------------------
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}
include vhost/*.conf;
}
4、即可完成laravel配置
记得重启lnmp,是改变生效
lnmp restart
网友评论