Blogger Information
Blog 63
fans 2
comment 0
visits 162967
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
记一次虚拟机CentOS-7|Nginx部署Laravel框架
书声的博客
Original
1263 people have browsed it

一次部署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. }

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

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post