프로그래밍/PHP

Install apache24 + PHP7 + CodeIgniter3 for Windows

채윤아빠 2018. 10. 17. 17:36
728x90
반응형


Windows 개발 환경에서 apache24 + PHP7 + CodeIgniter3 를 설치하여 연동하는 방법을 기술합니다.

CodeIgniter3 를 호출할 때, index.php가 없어도 되도록 rewrite 모듈 설정도 포함합니다.


Install apache24

  • apache24 download in https://www.apachelounge.com/download/ : Apache 2.4.35 Win64
  • Extract to "C:\Dev\Apache24" 
  • Edit httpd.conf : "C:\Dev\Apache24\conf\httpd.conf"
    • Set ServerRoot
      Define SRVROOT "c:/Dev/Apache24"
    • Set ServerName
      ServerName devwb.mydomain.com:80
    • Enable rewrite module
      LoadModule rewrite_module modules/mod_rewrite.so
    • Set php7 configurations
      # for thread safe
      LoadFile    "C:/Dev/php-7.2.10/php7ts.dll" 
      LoadModule    php7_module "C:/Dev/php-7.2.10/php7apache2_4.dll" 
      PHPIniDir    "C:/Dev/php-7.2.10/" 
      AddType    application/x-httpd-php .html .php
      
    • Set "/" Directory options
      <Directory />
          #AllowOverride none
          #Require all denied
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Order allow,deny
          allow from all
      </Directory>
      
    • Set dir_module option
      <IfModule dir_module>
          DirectoryIndex index.php index.html index.htm
      </IfModule>
      

Install php7

  • php7 downlaod in https://windows.php.net/download/ : PHP-7.2.10
  • Extract to "C:\Dev\php-7.2.10" 
  • Create php.ini
    • Copy "C:\Dev\php-7.2.10\php.ini-development" to "C:\Dev\php-7.2.10\php.ini"

Install CodeIgniter

  • Edit config.php : "C:\Dev\Apache24\htdocs\ci\application\config\config.php" 
    //$config['base_url'] = 'http://localhost/';
    $config['base_url'] = 'http://localhost/ci/';
    
    //$config['index_page'] = 'index.php';
    $config['index_page'] = '';
    
    $config['uri_protocol']    = 'REQUEST_URI';
    
    • $config['base_url'] 설정값을 CodeIgniter를 설치한 폴더에 맞게 수정
    • $config['index_page'] 설정값을 비워둠 ; index.php 없이도 RESTful API 와 같은 형태의 URI로 호출이 가능하도록 함
  • Create ".htaccess" : "C:\Dev\Apache24\htdocs\ci\.htaccess" 
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /ci
    
        RewriteCond $1 !^(index\.php|images|captcha|data|include|css|js|uploads|robots\.txt)
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        # Rewrite all other URLs to index.php/URL
        RewriteRule ^(.*)$ /ci/index.php/$1 [L]
    </IfModule>
    

참고자료