사용자 도구

사이트 도구


application:apache:suphp

Howto install suphp for apache2 on ubuntu

ubuntu package install

  1. apt를 이용하여 패키지를 받는다.
    apt-get install libapache2-mod-suphp suphp-common libapache2-mod-php5 php5-mysql

/etc/suphp.conf

  1. suphp 설정파일(/etc/suphp.conf)를 수정한다.
    [global]
    ;Path to logfile
    logfile=/var/log/suphp/suphp.log
    
    ;Loglevel
    loglevel=info
    
    ;User Apache is running as
    webserver_user=www-data
    
    ;Path all scripts have to be in
    ;docroot=/var/www:${HOME}/public_html
    docroot=/
    
    ;Path to chroot() to before executing script
    ;chroot=/mychroot
    
    ; Security options
    allow_file_group_writeable=false
    allow_file_others_writeable=false
    allow_directory_group_writeable=false
    allow_directory_others_writeable=false
    
    ;Check wheter script is within DOCUMENT_ROOT
    check_vhost_docroot=true
    
    ;Send minor error messages to browser
    errors_to_browser=false
    
    ;PATH environment variable
    env_path=/bin:/usr/bin
    
    ;Umask to set, specify in octal notation
    ;umask=0077
    umask=0022
    
    ; Minimum UID
    min_uid=100
    
    ; Minimum GID
    min_gid=100
    
    [handlers]
    ;Handler for php-scripts
    application/x-httpd-suphp="php:/usr/bin/php-cgi"
    
    ;Handler for CGI-scripts
    x-suphp-cgi="execute:!self"
    

/etc/apache2/mods-enabled/suphp.conf

  1. php5 모듈을 중지시킨다.
     # a2dismod php5 
  2. suphp 모듈을 활성화시킨다.
     # a2enmod suphp 
  3. apache2의 suphp.conf 설정을 한다.
    <IfModule mod_suphp.c>
        <FilesMatch "\.ph(p[345]?|tml)$">
            SetHandler application/x-httpd-suphp
        </FilesMatch>
        suPHP_AddHandler application/x-httpd-suphp
    
        <Directory />
            suPHP_Engine on
        </Directory>
    
        # By default, disable suPHP for debian packaged web applications as files
        # are owned by root and cannot be executed by suPHP because of min_uid.
        <Directory /usr/share>
            suPHP_Engine off
        </Directory>
    
    # # Use a specific php config file (a dir which contains a php.ini file)
    #       suPHP_ConfigPath /etc/php5/cgi/suphp/
            suPHP_ConfigPath /etc/php5/cgi/suphp/
    # # Tells mod_suphp NOT to handle requests with the type <mime-type>.
    #       suPHP_RemoveHandler <mime-type>
    </IfModule>

/etc/php5/cgi/suphp/php.ini

  1. apache2 설정파일인 suphp.conf 에 있는 php.ini 를 만들어 준다.
    # cd /etc/php5/cgi
    # mkdir suphp
    # cd suphp
    # cp ../php.ini
  2. <?php 이외에 <? 도 적용이 되도록 short_open_tag를 활성화시켜준다.
    # vi /etc/php5/cgi/suphp/php.ini
    ...
    ; starlits@adminschool.net
    short_open_tag = On
    ...

/etc/apache2/sites-enabled/001-adminschool.conf

  1. virtual host 설정을 한다.
    <VirtualHost *:80>
        ServerName adminschool.net
        ServerAdmin webmaster@adminshcool.net
        DocumentRoot /home/admin/html
        <Directory /home/admin/html>
            Require all granted
        </Directory>
        <IfModule mod_suphp.c>
            suPHP_Engine on
        </IfModule>
        ErrorLog /var/log/apache2/adminschool.net-error.log
        CustomLog /var/log/apache2/adminschool.net-access.log combined env=!dontlog
    </VirtualHost>
    
application/apache/suphp.txt · 마지막으로 수정됨: 2015/10/29 01:44 저자 starlits