博主信息
博文 63
粉丝 2
评论 0
访问量 192106
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
记一次虚拟机CentOS-7|Nginx部署Laravel框架
书声的博客
原创
1429人浏览过

一次部署Laravel框架后的总结

一、下载框架
通过 Composer 创建项目:composer create-project --prefer-dist laravel/laravel blog

二、配置
通过Composer安装的Laravel框架会缺少vender依赖目录,此时执行:

  1. composer install
  2. 或者 composer update

三、检查有无.env文件
若无.env文件,在项目目录下执行:cp .env.example .env

然后如果访问首页时报错:No application encryption key has been specified
在框架根目录下,执行:php artisan key:generate

四、根据框架手册修改Nginx配置文件

  1. server {
  2. listen 80;
  3. server_name example.com;
  4. root /example.com/public;
  5. add_header X-Frame-Options "SAMEORIGIN";
  6. add_header X-XSS-Protection "1; mode=block";
  7. add_header X-Content-Type-Options "nosniff";
  8. index index.html index.htm index.php;
  9. charset utf-8;
  10. location / {
  11. try_files $uri $uri/ /index.php?$query_string;
  12. }
  13. location = /favicon.ico { access_log off; log_not_found off; }
  14. location = /robots.txt { access_log off; log_not_found off; }
  15. error_page 404 /index.php;
  16. location ~ \.php$ {
  17. fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  18. fastcgi_index index.php;
  19. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  20. include fastcgi_params;
  21. }
  22. location ~ /\.(?!well-known).* {
  23. deny all;
  24. }
  25. }

五、使用宝塔面板时,需要修改的项

本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学