CentOS/Laravel

  1. composer问题
    /usr/bin/env: php: No such file or directory
    因为是编译安装的php7,php的可执行文件不在/usr/bin,而在/usr/local/php7/bin,所以可以创建链接过去
    ln -s /usr/bin/php /usr/local/php7/bin/php

  2. 安装laravel5.4

    • 方法一-通过 Laravel 安装工具
      composer global require "laravel/installer"
      laravel new blog
    • 方法二-通过 Composer Create-Project
      composer create-project --prefer-dist laravel/laravel blog
  3. Nginx配置Laravel

     user nginx nginx;
     worker_processes  1;
    
     pid        logs/nginx.pid;
     events {
         worker_connections  1024;
     }
    
     http {
         include       mime.types;
         default_type  application/octet-stream;
    
         sendfile on;
         tcp_nopush on;
    
         keepalive_timeout  65;
         gzip on;
    
         server
         {
             listen 80;
             server_name localhost;
             root /home/nginx/project/lavue/public;
             index index.html index.htm index.php;
    
             try_files $uri $uri/ @rewrite;
             location @rewrite {
                 rewrite ^/(.*)$ /index.php?_url=/$1;
             }
    
             location ~ .*\.(php|php5)?$
             {
                     fastcgi_pass 127.0.0.1:9000;
                     fastcgi_index index.php;
                     fastcgi_split_path_info       ^(.+\.php)(/.+)$;
                     fastcgi_param PATH_INFO       $fastcgi_path_info;
                     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                     include                       fastcgi_params;
             }
    
             location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
             {
                     expires 30d;
             }
    
             location ~ .*\.(js|css)?$
             {
                     expires 1h;
             }
    
             location ~ /\.ht {
                 deny all;
             }
         }
     }
    
  4. 【问题】配置nginx的root为 /home/xy/project/lavue/public,打开localhost,显示404或者403
    【解决】虽然project的owner是nginx,但是xy的owner是xy,可能是权限的问题,新建/home/nginx/project/,chown -R nginx nginx, chgrp -R nginx nginx,修改root路径,解决正常显示

你可能感兴趣的:(CentOS/Laravel)