# 作業手順書 ## CodeIgniterインストール *** ### 目次 1. [更新履歴](#更新履歴) 1. [備考](#備考) 1. [事前準備](#事前準備) 1. [手順](#手順) *** ### 更新履歴 |ver|更新日|更新内容| |:---|:---|:---| |1.0|2019-04-12|新規作成| *** ### 参考 * [CodeIgniter インストール](http://codeigniter.jp/user_guide/3/installation/index.html) * [CodeIgniterでCSS効かせて静的ページを作るまで](https://qiita.com/saken649/items/a678836df65ebe24b606) *** ### 事前準備 1. Oracle VM VirtualBoxインストール http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html?ssSourceSiteId=otnjp 1. Vagrantインストール https://www.vagrantup.com/downloads.html 1. Vagrant CentOS6.7環境構築 1. Vagrant CentOS6.7環境にLAMP環境築(Apache + MySQL + PHP) 1. ルードディレクトリ作成 cmd > ```mkdir c:\Vagrant\centos67``` 1. 注意事項 * ※1:「```%project_name%```」はプロジェクト毎に変更すること *** ### 手順 1. 「CodeIgniter」のダウンロード https://www.codeigniter.com/user_guide/installation/downloads.html ```CodeIgniter-3.1.10``` 1. 「CodeIgniter」を解凍して作業ディレクトリへ移動 移動後:```C:\Vagrant\centos67\CodeIgniter-3.1.10``` 1. ディレクト名をプロジェクト名へ変更 変更前:```C:\Vagrant\centos67\CodeIgniter-3.1.10``` 変更後:```C:\Vagrant\centos67\%project_name%``` (※1) 1. プロジェクトディレクトリ直下に「.htaccess」を作成する ```%project_name%\.htaccess``` (※1) 1. index.phpファイルをURIより取り除く 「.htaccess」に以下を追加する (※1) ``` RewriteEngine on RewriteCond $1 !^(index\.php|css|user_guide|.+\.gif$|.+\.jpg$|.+\.png$|.+\.js$) RewriteRule ^(.*)$ /%project_name%/index.php/$1 [L] ``` 1. 「application/config/autoload.php」更新 ``` //$autoload['helper'] = array(); $autoload['helper'] = array('url'); ``` 1. 「application/config/config.php」更新 1. BaseUrl更新 (※1) ``` //$config['base_url'] = ''; $config['base_url'] = 'http://192.168.33.10/%project_name%/'; ``` 1. mod_rewriteによるindex.phpの除外 ``` //$config['index_page'] = 'index.php'; $config['index_page'] = ''; ``` 1. クエリ文字ベースアプローチの有効化 ``` //$config['enable_query_strings'] = FALSE; $config['enable_query_strings'] = TRUE; ``` 1. vagrantで開発環境を起動 cmd > ```vagrant ssh``` cmd > ```vagrant up``` 1. ユーザー変更 [vagrant@localhost ~]$ ```su root``` Password:```vagrant``` 1. rootディレクトリへ移動 [root@localhost vagrant]$ ```cd /``` 1. Apache停止 [root@localhost /]$ ```service httpd stop``` 1. Apache設定ファイルのバックアップファイル作成 1. ディレクトリ移動 [root@localhost /]$ ```cd /etc/httpd/conf``` 1. 「httpd.conf」のバックアップファイルを作成 [root@localhost conf]$ ```cp httpd.conf httpd.conf.org``` 1. Apache設定ファイル変更 1. 「httpd.conf」を開く [root@localhost conf]$ ```vi httpd.conf``` 1. 「httpd.conf」の設定を変更 入力開始:```a``` 入力終了:```Esc``` ``` # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # #AllowOverride None AllowOverride All #Allへ変更して.htaccessによりリライトを許可する ``` ``` # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # # The index.html.var file (a type-map) is used to deliver content- # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # #DirectoryIndex index.html index.html.var DirectoryIndex index.php index.html index.html.var #index.php追加 ``` ``` # If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php #新規追加 AddType application/x-httpd-php-source .phps #新規追加 ``` 1. 保存して「httpd.conf」ファイルを閉じる ```:wq``` 1. シンボリックリンク作成 (※1) [root@localhost conf]$ ```cd /``` [root@localhost /]$ ```sudo ln -s /vagrant/%project_name% /var/www/html/%project_name%``` 1. Apache起動 [root@localhost /]$ ```service httpd start``` 1. 動作確認 指定ページへアクセスする (※1) http://192.168.33.10/%project_name%/welcom