在搭建好的LNMP环境下部署Laravel项目,以及composer

配置composer

原文链接:Centos6.6安装Composer
1.下载composer.phar

curl -sS https://getcomposer.org/installer | php

2.把composer.phar移动到环境下让其变成可执行

mv composer.phar /usr/local/bin/composer
  1. 查看版本
 composer -V

部署laravel项目

工具:MobaXterm
现在还没学会在 Linux 上使用 svn/git ,使用的方式粗暴一些。

  1. home 下新建 www 文件夹,把压缩的项目拖进去解压
    安装 unzip 工具
yum install unzip

进入目录使用

unzip xxx.zip
  1. 打开此目录 /etc/nginx/conf.d/default.conf 文件,配置如下:
#
# The default server
#

server {
    listen           80;
    server_name      www.whatwhat.top;
    root             /home/www/startLaravel/public/;
    index            index.php index.html index.htm;
    try_files        $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        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 ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
    }

    location ~ /\.ht {
         deny all;
    }
}

主要就是 root 路径对应到 laravelpublic

部署laravel项目2

学会了使用 git
安装 git

yum intall git

www 下部署在 GitHub 上的项目

git clone 项目地址

相比于拖拽复制,此方法相当快。
如果想删除项目,先进入项目所在文件夹,再使用如下:

rm -rf 目录名字

记住:一定要重启nginx

service nginx restart

第二次配置的时候,非常懵逼,为什么不行,没错啊,浪费一个小时才想起来修改了配置文件,竟然没有重启 nginx

接下来可能会报错,使用另一篇文档来写。

你可能感兴趣的:(在搭建好的LNMP环境下部署Laravel项目,以及composer)