11.3 Apache 伺服器啟用 Module mod_userdir

1. Enable module mod_userdir
$ sudo a2enmod userdir
2. Configure module mod_userdir
$ sudo vim /etc/apache2/mods-enabled/userdir.conf

<IfModule mod_userdir.c>
    UserDir public_html
    UserDir disabled root
    <Directory /home/*/public_html>
        AllowOverride FileInfo AuthConfig Limit Indexes
        Options MultiViews SymLinksIfOwnerMatch IncludesNoExec
        <Limit GET POST OPTIONS>
            Order allow,deny
            Allow from all
        </Limit>
        <LimitExcept GET POST OPTIONS>
            Order deny,allow
            Deny from all
        </LimitExcept>
    </Directory>
</IfModule>
3. Configure module mod_php5
$ sudo vim /etc/apache2/mods-enabled/php5.conf

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To reenable php in user directories comment the following
    # lines (from <IfModule ...> to </IfModule>.) Do NOT set it
    # to On as it prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_value engine Off
    #    </Directory>
    #</IfModule>
</IfModule>
4. Configure php.ini
$ sudo vim /etc/php5/apache2/php.ini

disable_functions = pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait,
pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wexitstatus,
pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch,
pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo,
pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority, exec,
passthru, shell_exec, system, proc_open, popen, curl_exec, curl_multi_exec,
parse_ini_file, show_source, phpinfo
5. Restart service apache2
$ sudo service apache2 restart