kenjis/codeigniter-deployer

CodeIgniter 3.0 部署工具

dev-master / 1.0.x-dev 2015-07-13 10:36 UTC

This package is auto-updated.

Last update: 2024-09-23 12:40:43 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

CodeIgniter 3.0 的部署工具。

您可以使用一条命令部署 CodeIgniter。

这是基于 Deployer 3.0。

文件夹结构

codeigniter/
└── deploy/
     ├── deploy.php ... config file for Deployer
     ├── deploy.sh  ... script to deploy
     └── logs/

要求

  • PHP 5.4.0 或更高版本
  • Composer
  • Git
  • SSH
  • Shell

安装

使用 Composer 安装此项目

$ cd /path/to/codeigniter/
$ composer require kenjis/codeigniter-deployer:1.0.x@dev --dev

deploy 文件夹安装到您的 CodeIgniter 应用程序文件夹中

$ php vendor/kenjis/codeigniter-deployer/install.php
  • 上述命令总是覆盖现有文件。
  • 您必须在 CodeIgniter 项目根目录中运行它。

配置

配置 deploy/deployer.php

服务器

// Your production server
server('prod', 'your.server.example.com', 22)
    ->user('username')
    ->forwardAgent()
    ->stage('production')
    ->env('branch', 'master')
    ->env('deploy_path', '/var/www/your-codeigniter-app');

有关详细信息,请参阅 https://github.com/deployphp/docs/blob/master/servers.md

仓库

// Your Git repository
set('repository', 'git@github.com:org/your-codeigniter-app.git');

您的服务器上需要 git 命令,并确保您可以在服务器上运行 git clone

参考

配置您的服务器

Apache

请参阅下面的示例。在这种情况下,/var/www/your-codeigniter-app 是基本文件夹。

your-codeigniter-app/
├── current -> /var/www/your-codeigniter-app/releases/20150529181638
└── releases/
     ├── 20150529180505/
     ├── 20150529181203/
     └── 20150529181638/

每次部署都安装在 releases/YYYYMMDDHHMMSS 文件夹中。

当前版本在 your-codeigniter-app/current 文件夹中,它是一个指向 releases/20150529181638 文件夹的符号链接。

所以如果您使用 codeigniter-composer-installer 的文件夹结构,您的 Apache 配置如下所示

DocumentRoot /var/www/your-codeigniter-app/current/public

如果您使用 CodeIgniter 作为默认文件夹结构,您的 Apache 配置如下所示

DocumentRoot /var/www/your-codeigniter-app/current

sudo

Deployer 将尝试使用 sudo 命令获取写权限,因此此命令必须在无需提示密码且无需 tty 的情况下运行。

以下是一个配置示例

Defaults:username !requiretty

username   ALL=(ALL) NOPASSWD: /usr/bin/setfacl

如果您不需要为部署使用 sudo,您可以在 deploy/deployer.php 中设置。

set('writable_use_sudo', false);

如何部署

$ cd /path/to/codeigniter/
$ cd deploy/
$ sh deploy.sh

CodeIgniter 3.0 的相关项目