(转)本地laravel项目部署上线

laravel本地Homestead开发部署上线

转载自Ubuntu 14/16下的Laravel LNMP线上环境自动部署脚本

说明
此脚本用于在一台全新的 Ubuntu 14.04 LTS上部署适合 Laravel 使用的 LNMP 生产环境。
此脚本参照了 Homestead 环境设置脚本 ,并做了更加适用于生产环境的效率和安全调优。项目地址:https://github.com/summerblue/laravel-ubuntu-init

软件列表

  • Ubuntu 14.04
  • Git
  • PHP 7.1
  • Nginx
  • MySQL
  • Sqlite3
  • Composer
  • Node 6 (With Yarn, PM2, Bower, Grunt, and Gulp)
  • Redis - Memcached
  • Beanstalkd

安装过程

  1. 下载脚本
wget https://raw.githubusercontent.com/summerblue/laravel-ubuntu-init/master/deploy.sh
chmod +x deploy.sh
  1. 配置MySQL密码
vi deploy.sh

# Configure
MYSQL_ROOT_PASSWORD="{{--Your Password--}}"
MYSQL_NORMAL_USER="estuser"
MYSQL_NORMAL_USER_PASSWORD="{{--Your Password--}}"
  1. 运行脚本
    ./deploy.sh

安装完成后

  1. git clone拉下项目到项目文件夹
  2. 站点目录权限
cd /data/www/{YOU PROJECT FOLDER NAME}
chown www:www -R ./
  1. 添加站点的Nginx配置
    站点的Nginx配置模板,写入按照域名命名的文件,放到 /etc/nginx/sites-enabled文件夹中。
    比如 /etc/nginx/sites-enabled/phphub.org:
server {
    listen 80;
    server_name {{---YOU-DOMAIN-NAME---}};
    root "{{---YOU-PROJECT-FOLDER---}}";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log /data/log/nginx/{{---YOU-PROJECT-NAME---}}-access.log;
    error_log  /data/log/nginx/{{---YOU-PROJECT-NAME---}}-error.log error;

    sendfile off;

    client_max_body_size 100m;

    include fastcgi.conf;

    location ~ /\.ht {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

完成之后重启Nginx
service nginx restart

posted @ 2018-01-16 20:40  ustc_rjgc2017  阅读(1302)  评论(0编辑  收藏  举报