2014年7月1日 星期二

CodeIgniter Installation

1. download CodeIgniter 3.0 release from github


2. extrace all the file into /var/www/html/CI



3. to remove index.php (http://127.0.0.1/Test instead of http://127.0.0.1/index.php/Test

A: modify httpd.conf, add a virtualhost with  AllowOverride All

B: in /var/www/html/CI , add a .htaccess with rewrite rule
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|$)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]


C: modify config.php and set index_page to blank
$config['index_page'] = '';

4. In   /var/www/html/CI/application/controllers  

add a Test.php
class Test extends CI_Controller {

        public function index()
        {
                echo 'Hello World!';
        }
}
?>

Browser : http://127.0.0.1/Test  or http://127.0.0.1/index.php/Test



5. Install Ion Auth 2

download Ion Auth 2 from https://github.com/benedmunds/CodeIgniter-Ion-Auth

copy controllers / language / libraries / models / views to /var/www/html/CI/application
rename  files to support V3 UpperCaseFirst class name


config/ion_auth.php               =>   config/Ion_auth.php
models/ion_auth_model.php         =>   models/Ion_auth_model.php
models/ion_auth_mongodb_model.php =>   models/Ion_auth_mongodb_model.php
execute sql

remember to set Selinux , httpd_can_network_connect_db
setsebool -P httpd_can_network_connect_db 1

Browser : http://192.168.1.155:8080/Auth/

and Login with default email and password

6. Add CSS / JS Folder

mkdir /var/www/html/CI/assets
mkdir /var/www/html/CI/assets/css
mkdir /var/www/html/CI/assets/javascript

make sure in the .httaccess
RewriteCond $1 !^(index\.php|images|assets|robots\.txt|$)

in the view
<link type="text/css" rel="stylesheet" href="/assets/css/test.css" media="all" />

Apache AllowOverride in Virtual Host


    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/default
    ServerName dummy-host.example.com
    ErrorLog logs/default-error_log
    CustomLog logs/default-access_log common
           
               AllowOverride All
           





in /var/www/html/default

[root@test-20140423 test]# ls -al /var/www/html/default/test/
總計 12
drwxr-xr-x. 2 root root 4096 2014-07-01 15:36 .
drwxr-xr-x. 3 root root 4096 2014-07-01 15:23 ..
-rw-r--r--. 1 root root   17 2014-07-01 15:36 .htaccess

[root@test-20140423 test]# more .htaccess
Options -Indexes


try to http://127.0.0.1/test/

Forbidden

You don't have permission to access /test/ on this server.


in error-log
[Tue Jul 01 15:38:37 2014] [error] [client 10.10.50.57] Directory index forbidden by Options directive: /var/www/html/default/test/