RHEL/CentOS -ב Apache Userdir -ה לודומ תא ליעפהל דציכ


. http://example.com/~user/ ריבחתה תועצמאב י'צאפא לש טנרטניא תרש תועצמאב שמתשמל תויפיצפס תוירפס רזחאל רשפאמה ,י'צאפא לודומ אוה Userdir וא םישמתשמ ךירדמ

.Apache טנרטניאה תרש תועצמאב םלועה םע םהלש תיבה תוירפסב ןכותל תשגל ולכוי תכרעמב םישמתשמה תונובשח ,לעפומ mod_userdir לודומ רשאכ ,המגודל

.Apache טנרטניאה תרש תועצמאב Fedora -ו RHEL, CentOS יתרשב Apache (mod_userdir) -ה ירמוש תא ליעפהל דציכ ךל הארנ ונא הז רמאמב

... אבה ךילהה יפל התוא ןיקתהל לכות ,תאז תישע אל םא .ךלש סקוניל תצפהב י'צאפא לש טנרטניאה תרש ןקתומ רבכש החינמ וז הכרדה

י'צאפא לש HTTP -ה תרש תא ןקתה :1 בלש

.ךלש סקוניל תצפהב האבה הדוקפב שמתשה ,Apache לש טנרטניאה תרש תא ןיקתהל ידכ

# yum install httpd           [On CentOS/RHEL]
# dnf install httpd           [On Fedora]

Apache לש םישמתשמה תא לעפה :2 בלש

.רתויב תובוטה תויורשפאה םע רדגומ רבכש , /etc/httpd/conf.d/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 tecmint

    #
    # 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>

.הרוצתה ץבוקב האבה הרדגהב שמתשה ,רחא דחא ףאל אל ךא , UserDir תוירפסל תשגל םישמתשמ רפסמל רשפאל ידכ

UserDir disabled
UserDir enabled testuser1 testuser2 testuser3

.הרוצתה ץבוקב האבה הרדגהב שמתשה ,םישמתשמ רפסמל תאז תיבשהל ךא , UserDir תוירפסל תשגל םישמתשמה לכל רשפאל ידכ

UserDir enabled
UserDir disabled testuser4 testuser5 testuser6

.םינורחאה םייונישה תא ליחהל ידכ Apache טנרטניאה תרש תא שדחמ ליעפהל ךילע ,ךיתושירדל םאתהב הרוצתה תורדגה תא רידגתש רחאל

# systemctl restart httpd.service  [On SystemD]
# service httpd restart            [On SysVInit]

םישמתשמ תוירפס תריצי :3 בלש

.tecmint לש שמתשמה לש תיבה תיירפס תחת public_html הירפס רצוי ינא ןאכ ,המגודל .שמתשמה/שמתשמה לש תיבה תוירפסב תוירפס/ public_html הירפס רוציל ךילע תעכ

# mkdir /home/tecmint/public_html

.html_תוירוביצהו תיבה תוירפס לע תונוכנה תואשרהה תא לחה ,ןכמ רחאל

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

.(httpd_enable_homedirs) י'צאפא לש םירדאמוה רובע ןוכנ SELinux רשקה רדגה ,ןכ ומכ

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

לעפומ Apache Userdir תא קודב :4 בלש

.שמתשמה םש תא וירחאו IP -ה תבותכ וא תרשה חראמ םש לא ךלש ןפדפדה תיינפה ידי לע Userdir -ה תא תמא ,ףוסבל

http://example.com/~tecmint
OR
http://192.168.0.105/~tecmint

.םיאבה םיצבקה תריצי ידי לע PHP עדימו HTML יפד קודבל םג לכות ,הצרת םא

.אבה ןכותה םע ץבוק home/tecmint/public_html/test.html/ רוצ

<html>
  <head>
    <title>TecMint is Best Site for Linux</title>
  </head>
  <body>
    <h1>TecMint is Best Site for Linux</h1>
  </body>
</html>

.אבה ןכותה םע ץבוק home/tecmint/public_html/test.php/ רוצ

<?php
  phpinfo();
?>

.הטמל תורעהה ףיעסב לואשל ססהת לא ,הז רמאמל עגונב תולאש ךל שי םא .םהלש תיבה תוירפסמ ןכות ףתשל םישמתשמל רשפאל Userdir לודומל רשפאל דציכ ונרבסה ,הז רמאמב !לכה הז