Ubuntu16.10ApachePHPServer

zengjf發表於2017-02-27
/*******************************************************************************************
 *                           Ubuntu 16.10 Apache PHP Server 
 * 說明:
 *     需要用到16.10系統上裝一個PHP的環境來做程式碼測試,記錄一下幾個關鍵的配置。
 *
 *                                                        2017-2-27 深圳 南山平山村 曾劍鋒
 ******************************************************************************************/

一、參考文件:
    1. Apache提示You don`t have permission to access / on this server問題解決
        http://sjpsega.iteye.com/blog/1507439 
    2. Multiple ports on Apache2
        http://serverfault.com/questions/722493/multiple-ports-on-apache2

二、開啟埠
    /etc/apache2/ports.conf
        # If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in
        # /etc/apache2/sites-enabled/000-default.conf
        
        Listen 80
        
        <IfModule ssl_module>
                Listen 443
        </IfModule>
        
        <IfModule mod_gnutls.c>
                Listen 443
        </IfModule>
        
        listen 8888   # 開啟獨立的埠
        
        # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

三、配置路徑
    /etc/apache2/sites-available/001-ARMDesktop.conf
        <VirtualHost *:8888> # The ServerName directive sets the request scheme, hostname and port that
                # the server uses to identify itself. This is used when creating
                # redirection URLs. In the context of virtual hosts, the ServerName
                # specifies what hostname must appear in the request`s Host: header to
                # match this virtual host. For the default virtual host (this file) this
                # value is not decisive as it is used as a last resort host regardless.
                # However, you must set it for any further virtual host explicitly.
                #ServerName www.example.com
        
                ServerAdmin webmaster@localhost
                DocumentRoot /home/zengjf/zengjf/zengjfos/ARMDesktop
        
                # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
                # error, crit, alert, emerg.
                # It is also possible to configure the loglevel for particular
                # modules, e.g.
                #LogLevel info ssl:warn
        
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
        
                # For most configuration files from conf-available/, which are
                # enabled or disabled at a global level, it is possible to
                # include a line for only one particular virtual host. For example the
                # following line enables the CGI configuration for this host only
                # after it has been globally disabled with "a2disconf".
                #Include conf-available/serve-cgi-bin.conf
        </VirtualHost>
        
        # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

四、error:
    1. You don`t have permission to access / on this server.

    2. 解決辦法:
        /etc/apache2/apache2.conf
            ...
            # Sets the default security model of the Apache2 HTTPD server. It does
            # not allow access to the root filesystem outside of /usr/share and /var/www.
            # The former is used by web applications packaged in Debian,
            # the latter may be used for local directories served by the web server. If
            # your system is serving content from a sub-directory in /srv you must allow
            # access here, or in any related virtual host.
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
                    Require all denied
            </Directory>
            
            <Directory /usr/share>
                    AllowOverride None
                    Require all granted
            </Directory>
            
            <Directory /var/www/>
                    Options Indexes FollowSymLinks
                    AllowOverride None
                    Require all granted
            </Directory>
            
            <Directory /home/zengjf/zengjf/zengjfos/ARMDesktop>
                    Options Indexes FollowSymLinks
                    Require all granted
            </Directory>
            
            #<Directory /srv/>
            #       Options Indexes FollowSymLinks
            #       AllowOverride None
            #       Require all granted
            #</Directory>
            ...