Kako omogućiti Apache Userdir modul na RHEL/CentOS
Korisnički imenik ili Userdir je Apache modul koji omogućuje dohvaćanje korisničkih imenika putem Apache web poslužitelja pomoću http://example.com/ ~user/
sintaksa.
Na primjer, kada je omogućen modul mod_userdir, korisnički računi u sustavu moći će pristupiti sadržaju u svojim kućnim imenicima sa svijetom putem Apache web poslužitelja.
U ovom članku ćemo vam pokazati kako omogućiti Apache userdirs (mod_userdir) na RHEL, CentOS i Fedora poslužitelji koji koriste Apache web poslužitelj.
Ovaj vodič pretpostavlja da već imate Apache web poslužitelj instaliran na vašoj Linux distribuciji. Ako niste, možete ga instalirati pomoću sljedećeg postupka…
Korak 1: Instalirajte Apache HTTP poslužitelj
Da biste instalirali Apache web poslužitelj, upotrijebite sljedeću naredbu na vašoj Linux distribuciji.
yum install httpd [On CentOS/RHEL]
dnf install httpd [On Fedora]
Korak 2: Omogućite Apache Userdirs
Sada trebate konfigurirati svoj Apache web poslužitelj za korištenje ovog modula u konfiguracijskoj datoteci /etc/httpd/conf.d/userdir.conf
, koja je već konfigurirana s najboljim opcijama.
vi /etc/httpd/conf.d/userdir.conf
Zatim potvrdite sadržaj otprilike kao ispod.
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>
Kako biste dopustili da nekolicina korisnika ima pristup UserDir
direktorijima, ali ne i bilo kome drugome, upotrijebite sljedeću postavku u konfiguracijskoj datoteci.
UserDir disabled
UserDir enabled testuser1 testuser2 testuser3
Da biste svim korisnicima dopustili pristup direktorijima UserDir
, ali to onemogućili nekolicini korisnika, upotrijebite sljedeću postavku u konfiguracijskoj datoteci.
UserDir enabled
UserDir disabled testuser4 testuser5 testuser6
Nakon što napravite konfiguracijske postavke prema svojim zahtjevima, trebate ponovno pokrenuti Apache web poslužitelj kako biste primijenili nedavne promjene.
systemctl restart httpd.service [On SystemD]
service httpd restart [On SysVInit]
Korak 3: Stvaranje korisničkih imenika
Sada trebate stvoriti public_html
direktorij/direktorije u korisničkim/korisničkim početnim direktorijima. Na primjer, ovdje stvaram public_html
direktorij u korisničkom početnom direktoriju tecmint.
mkdir /home/tecmint/public_html
Zatim primijenite ispravna dopuštenja na korisničke home i public_html direktorije.
chmod 711 /home/tecmint
chown tecmint:tecmint /home/tecmint/public_html
chmod 755 /home/tecmint/public_html
Također, postavite ispravan SELinux kontekst za Apache homedirs (httpd_enable_homedirs).
setsebool -P httpd_enable_homedirs true
chcon -R -t httpd_sys_content_t /home/tecmint/public_html
Korak 4: Testirajte omogućen Apache Userdir
Na kraju, provjerite Userdir usmjeravanjem svog preglednika na naziv hosta poslužitelja ili IP adresu iza koje slijedi korisničko ime.
http://example.com/~tecmint
OR
http://192.168.0.105/~tecmint
Ako želite, također možete testirati HTML stranice i PHP informacije stvaranjem sljedećih datoteka.
Stvorite datoteku /home/tecmint/public_html/test.html sa sljedećim sadržajem.
<html>
<head>
<title>TecMint is Best Site for Linux</title>
</head>
<body>
<h1>TecMint is Best Site for Linux</h1>
</body>
</html>
Napravite datoteku /home/tecmint/public_html/test.php sa sljedećim sadržajem.
<?php
phpinfo();
?>
To je sve! U ovom smo članku objasnili kako omogućiti modul Userdir da korisnicima omogući dijeljenje sadržaja iz njihovih kućnih direktorija. Ako imate pitanja u vezi s ovim člankom, slobodno ih postavite u odjeljku za komentare u nastavku.