1、安装Composer

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

2、安装Laravel

composer create-project laravel/laravel your-project-name

3、为 app/storage 目录下的文件设置写权限

4、配置 nginx

  1. location /laravel/public/ {
  2. try_files $uri $uri/ /laravel/public/index.php?$args;
  3. }

以下是我的配置:

  1. server {
  2. listen 80;
  3. #listen 443 ssl;
  4. #ssl_certificate /etc/nginx/server.crt;
  5. #ssl_certificate_key /etc/nginx/server.key;
  6. #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  7. #ssl_ciphers HIGH:!aNULL:!MD5;
  8. #ssl_prefer_server_ciphers on;
  9. set $root_path '/html/laravel/public';
  10. root $root_path;
  11. server_name www.ss.cn ss.cn;
  12. #charset koi8-r;
  13. #access_log /var/log/nginx/log/host.access.log main;
  14. location / {
  15. index index.html index.htm index.php;
  16. try_files $uri $uri/ /index.php?$query_string;
  17. if (!-e $request_filename){
  18. rewrite ^/(.*) /index.php last;
  19. }
  20. }
  21. #error_page 404 /404.html;
  22. # redirect server error pages to the static page /50x.html
  23. #
  24. error_page 500 502 503 504 /50x.html;
  25. location = /50x.html {
  26. root $root_path;
  27. }
  28. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  29. #
  30. #location ~ \.php$ {
  31. # proxy_pass http://127.0.0.1;
  32. #}
  33. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  34. #
  35. location ~ \.php$ {
  36. root $root_path;
  37. fastcgi_pass fpm:9000;
  38. fastcgi_index index.php;
  39. #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  40. include fastcgi_params;
  41. # 设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量
  42. set $fastcgi_script_name2 $fastcgi_script_name;
  43. if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
  44. set $fastcgi_script_name2 $1;
  45. set $path_info $2;
  46. }
  47. fastcgi_param PATH_INFO $path_info;
  48. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
  49. fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
  50. }
  51. # deny access to .htaccess files, if Apache's document root
  52. # concurs with nginx's one
  53. #
  54. location ~ /\.ht {
  55. deny all;
  56. }
  57. }