站長資訊網
        最全最豐富的資訊網站

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        User Directory或Userdir是一個Apache模塊,它允許使用http://example.com/~user/語法通過Apache Web服務器檢索特定于用戶的目錄。

        例如,當啟用mod_userdir模塊時,系統上的用戶帳戶將能夠通過Apache Web服務器訪問其主目錄中的內容。

        在本文中,我們將向您展示如何使用Apache Web服務器在RHEL,CentOS和Fedora服務器上啟用Apache userdirs(mod_userdir)。

        本教程假設您已經在Linux發行版上安裝了Apache Web服務器。 如果還沒有,可以使用以下步驟安裝它…

        第1步:安裝Apache HTTP Server

        要安裝Apache Web服務器,請在Linux發行版上使用以下命令。

        [linuxidc@localhost www.linuxidc.com]$ sudo yum install httpd          [在 CentOS/RHEL 上]
        [linuxidc@localhost www.linuxidc.com]$ sudo dnf install httpd          [在 Fedora 上]

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        在CentOS 7上安裝Apache

        第2步:啟用Apache Userdirs

        現在,您需要配置Apache Web服務器以在配置文件/etc/apache2/mods-available/userdir.conf中使用此模塊,該文件已配置了最佳選項。

        # vi /etc/httpd/conf.d/userdir.conf

        然后驗證內容如下所示。

        # directory if a ~user request is received.
        #
        # The path to the end user account ‘public_html’ directory must be
        # accessible to the webserver userid.  This usually means that ~userid
        # must have permissions of 711, ~userid/public_html must have permissions
        # of 755, and documents contained therein must be world-readable.
        # Otherwise, the client will only receive a “403 Forbidden” message.
        #
        <IfModule mod_userdir.c>
            #
            # UserDir is disabled by default since it can confirm the presence
            # of a username on the system (depending on home directory
            # permissions).
            #
            UserDir enabled linuxidc

            #
            # To enable requests to /~user/ to serve the user’s public_html
            # directory, remove the “UserDir disabled” line above, and uncomment
            # the following line instead:
            #
            UserDir public_html
        </IfModule>

        #
        # Control access to UserDir directories.  The following is an example
        # for a site where these directories are restricted to read-only.
        #
        <Directory “/home/*/public_html”>
            ## Apache 2.4 users use following ##
            AllowOverride FileInfo AuthConfig Limit Indexes
            Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
            Require method GET POST OPTIONS

        ## Apache 2.2 users use following ##
                Options Indexes Includes FollowSymLinks       
                AllowOverride All
                Allow from all
                Order deny,allow
        </Directory>

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        要允許少數用戶訪問UserDir目錄,但不允許其他人訪問,請在配置文件中使用以下設置。

        UserDir disabled
        UserDir enabled testuser1 testuser2 testuser3

        要允許所有用戶訪問UserDir目錄,但對少數用戶禁用此功能,請在配置文件中使用以下設置。

        UserDir enabled
        UserDir disabled testuser4 testuser5 testuser6

        根據需要進行配置設置后,需要重新啟動Apache Web服務器以應用最近的更改。

        # systemctl restart httpd.service  [在 SystemD 上]
        # service httpd restart            [在 SysVInit 上]

        第3步:創建用戶目錄

        現在,您需要在user/users主目錄中創建一個public_html 目錄/目錄。 例如,這里我在linuxidc的用戶主目錄下創建一個public_html目錄。

        # mkdir /home/linuxidc/public_html

        接下來,在用戶home和public_html目錄上應用正確的權限。

        # chmod 711 /home/linuxidc
        # chown linuxidc:linuxidc /home/linuxidc/public_html
        # chmod 755 /home/linuxidc/public_html

        另外,為Apache homedir(httpd_enable_homedirs)設置正確的SELinux context。

        # setsebool -P httpd_enable_homedirs true
        # chcon -R -t httpd_sys_content_t /home/linuxidc/public_html

        第4步:測試啟用Apache Userdir

        最后,通過將瀏覽器指向服務器主機名或IP地址,然后是用戶名來驗證Userdir。

        http://www.linuxidc.com/~linuxidc/

        http://IP地址/~linuxidc

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        如果需要,還可以通過創建以下文件來測試HTML頁面和PHP信息。

        使用以下內容創建/home/linuxidc/public_html/linuxidc.com.html文件。

        <html>
          <head>
            <title>linuxidc.com is Best Site for Linux</title>
          </head>
          <body>
            <h1>linuxidc.com is Best Site for Linux</h1>
          </body>
        </html>

        如下圖:

        如何在RHEL/CentOS上啟用Apache Userdir模塊

        使用以下內容創建/home/linuxidc/public_html/linuxidc.com.php文件。

        <?php
          phpinfo();
        ?>

        OK,在本文中,我們解釋了如何啟用Userdir模塊來允許用戶共享來自其主目錄的內容。如果您對本文有任何疑問,請在下面的評論部分提出。

        贊(0)
        分享到: 更多 (0)
        網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
        主站蜘蛛池模板: 日本熟妇亚洲欧美精品区| 精品人妻va出轨中文字幕| 尤物TV国产精品看片在线| 亚洲国产成人久久精品动漫| 久久精品国产亚洲av水果派| 久久夜色撩人精品国产小说| 亚洲视频精品在线| 国产成人精品久久免费动漫| 久久久久久九九99精品 | 国产精品永久免费| 欧美精品免费线视频观看视频| 大伊香蕉精品一区视频在线| 精品久久8x国产免费观看| 亚洲午夜精品久久久久久浪潮 | 成人午夜精品久久久久久久小说| 人妻AV一区二区三区精品| 亚洲一区精品伊人久久伊人| 热久久国产欧美一区二区精品| 久久精品国产福利国产琪琪| 香蕉99久久国产综合精品宅男自| 国产在线精品网址你懂的| 精品人妻系列无码天堂| 在线涩涩免费观看国产精品 | 999久久久免费国产精品播放| 精品日产一区二区三区手机| 99视频精品全部在线观看| 国产乱码精品一品二品| 久久亚洲中文字幕精品有坂深雪| 亚洲高清国产拍精品26U| 亚洲AV日韩精品久久久久| 婷婷国产成人精品视频| 亚洲AV无码久久精品蜜桃| 日韩精品久久无码人妻中文字幕| 日本午夜精品一区二区三区电影 | 国产精品成人免费观看| 国产精品自在在线午夜福利| 九色精品视频在线观看| 亚洲国产成人a精品不卡在线| 亚洲精品国产精品乱码不卡√| 久久国产免费观看精品3| 91久久婷婷国产综合精品青草|