LoginSignup
3
3

More than 5 years have passed since last update.

AWSにFuelPHP+nginx(SSL)の環境構築

Last updated at Posted at 2016-02-15

はじめに

AWSにFuelPHP + nginx(SSL)の環境構築した時のメモです。

概要

  1. gitのインストール
  2. composerのインストール
  3. oilのインストール
  4. プロジェクトの作成
  5. nginxの設定

詳細


gitのインストール

gitのインストールをします。

入れとかないと以下のようなエラーがでます。

Failed to download fuel/fuel from source: Failed to clone git@github.com:fuel/fuel.git, git was not found, check that it is installed and in your PATH env.

sh: git: command not found

Now trying to download from dist
yum install git

composerのインストール

composerのインストールをします。

curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin

composer.phar で入るのでcomposerでシンボリックリンクを作成します。
しないと以下のようなエラーがでます。
which: no composer in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/admin/.local/bin:/home/admin/bin)

shell-session
ln -s /bin/composer.phar /bin/composer


oilのインストール

oilをインストールします。

curl get.fuelphp.com/oil | sh

プロジェクト作成

以下のコマンドでプロジェクトを作成します。

oil create プロジェクト名

もし以下のようなエラーが出た場合、githubの制限でエラーになっているのでキーを取ります
Could not fetch https://api.github.com/repos/fuel/core/contents/composer.json?ref=befcce8da16420d07d4da1b267057b5c23e673fd, please create a GitHub OAuth token to go over the API rate limit

以下コマンドでトークンが取得できます。

curl -u 'ユーザー名' -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizations

コンフィグ設定をします。

composer.phar config -g github-oauth.github.com 取得したトークン

あとは、再実行すればOKです。


nginxの設定

nginxの設定を行います。htaccessが使用できませんので、直接書きます。
ついでにBASIC認証の設定もしました。

/etc/nginx/conf.d/ドメイン名
server {
       listen       443 ssl;
       server_name  ドメイン名;
       root   ドキュメントルート;
       charset   utf8;
       ssl                  on;
       ssl_certificate      /xxxx/ssl/server.crt;
       ssl_certificate_key  /xxxx/ssl/server.key;
       ssl_session_timeout  5m;
       ssl_protocols  SSLv2 TLSv1;
       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers   on;

       disable_symlinks off;

       location / {
           auth_basic "Restricted";
           auth_basic_user_file /xxxx/passwd.dat;
           index                index.php;
           try_files $uri $uri/ /index.php$is_args$args;
       }

       location ~ \.php$ {
           fastcgi_index  index.php;
           fastcgi_pass   unix:/XXXXX/php-fpm/php-fpm.sock;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
}

あとはnginxを再起動もしくはリロードでOKです。

あとがき

上記でとりあえずインストールまで完了すると思います。ここらへんの作業はほとんど同じだしchefとかansibleとかで自動化したいな。

その他

参考
composerでGitHub apiのアクセス制限対処法

履歴

2016/02/16 nginxのコンフィグに余計な設定があったので修正。また、シンボリックリンクを有効にする。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3