ວິທີການເປີດໃຊ້ໂມດູນ Apache Userdir ໃນ RHEL / CentOS
ປື້ມຄູ່ມືຜູ້ໃຊ້ຫລື Userdir ແມ່ນໂມດູນ Apache, ເຊິ່ງຊ່ວຍໃຫ້ໄດເລກະທໍລີສະເພາະຂອງຜູ້ໃຊ້ສາມາດຊອກຫາໄດ້ໂດຍຜ່ານເຄື່ອງແມ່ຂ່າຍເວັບໄຊຕ໌ Apache ໂດຍໃຊ້ http://example.com/~user/
syntax.
ຕົວຢ່າງເຊັ່ນເມື່ອໂມດູນ mod_userdir ຖືກເປີດໃຊ້ງານ, ບັນຊີຜູ້ໃຊ້ໃນລະບົບຈະສາມາດເຂົ້າເຖິງເນື້ອຫາຢູ່ໃນລາຍການເຮືອນຂອງພວກເຂົາກັບໂລກຜ່ານ server web server.
ໃນບົດຂຽນນີ້, ພວກເຮົາຈະສະແດງວິທີການທີ່ຈະເຮັດໃຫ້ຜູ້ ນຳ ໃຊ້ Apache (mod_userdir) ໃຊ້ໃນເຄື່ອງແມ່ຂ່າຍ RHEL, CentOS, ແລະ Fedora ໂດຍໃຊ້ Apache web server.
ບົດແນະ ນຳ ນີ້ຖືວ່າທ່ານໄດ້ຕິດຕັ້ງ server server ຂອງ Apache ແລ້ວໃນການແຈກຈ່າຍ Linux ຂອງທ່ານແລ້ວ. ຖ້າທ່ານບໍ່ມີ, ທ່ານສາມາດຕິດຕັ້ງມັນໂດຍໃຊ້ຂັ້ນຕອນຕໍ່ໄປນີ້…
ຂັ້ນຕອນທີ 1: ຕິດຕັ້ງ Apache HTTP Server
ການຕິດຕັ້ງ server web server, ໃຊ້ ຄຳ ສັ່ງຕໍ່ໄປນີ້ໃນການແຈກຈ່າຍ Linux ຂອງທ່ານ.
# yum install httpd [On CentOS/RHEL] # dnf install httpd [On Fedora]
ຂັ້ນຕອນທີ 2: ເປີດໃຊ້ Apache Userdirs
ຕອນນີ້ທ່ານ ຈຳ ເປັນຕ້ອງ ກຳ ຫນົດຄ່າເຊີຟເວີເວັບໄຊຕ໌ Apache ຂອງທ່ານເພື່ອ ນຳ ໃຊ້ໂມດູນນີ້ໃນແຟ້ມການຕັ້ງຄ່າ /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: ສ້າງປື້ມຄູ່ມືຜູ້ໃຊ້
ຕອນນີ້ທ່ານ ຈຳ ເປັນຕ້ອງສ້າງໄດເລກະທໍລີ/ໄດເລກະທໍລີ/ໄດເລກະທໍລີ/ລາຍຊື່ຢູ່ໃນລາຍການເຮືອນຂອງຜູ້ໃຊ້/ຜູ້ໃຊ້. ຍົກຕົວຢ່າງ, ໃນທີ່ນີ້ຂ້ອຍ ກຳ ລັງສ້າງລະບົບ public_html
ພາຍໃຕ້ໄດເລກະທໍລີເຮືອນຂອງຜູ້ໃຊ້ tecmint.
# mkdir /home/tecmint/public_html
ຕໍ່ໄປ, ນຳ ໃຊ້ສິດອະນຸຍາດທີ່ຖືກຕ້ອງໃນ ໜ້າ ທຳ ອິດຂອງຜູ້ ນຳ ໃຊ້ແລະລາຍການ public_html.
# chmod 711 /home/tecmint # chown tecmint:tecmint /home/tecmint/public_html # chmod 755 /home/tecmint/public_html
ພ້ອມກັນນີ້, ກຳ ນົດສະພາບການ SELinux ທີ່ຖືກຕ້ອງ ສຳ ລັບເຮືອນ hom Apache (httpd_enable_homedirs).
# setsebool -P httpd_enable_homedirs true # chcon -R -t httpd_sys_content_t /home/tecmint/public_html
ຂັ້ນຕອນທີ 4: ທົດສອບ Enabled Apache Userdir
ສຸດທ້າຍ, ກວດສອບ Userdir ໂດຍຊີ້ຕົວທ່ອງເວັບຂອງທ່ານໄປທີ່ hostname server ຫຼື IP address ຕາມດ້ວຍຊື່ຜູ້ໃຊ້.
http://example.com/~tecmint OR http://192.168.0.105/~tecmint
ຖ້າທ່ານຕ້ອງການ, ທ່ານຍັງສາມາດທົດສອບ ໜ້າ HTML ແລະຂໍ້ມູນ PHP ໂດຍການສ້າງເອກະສານຕໍ່ໄປນີ້.
ສ້າງເອກະສານ /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 ສາມາດອະນຸຍາດໃຫ້ຜູ້ໃຊ້ສາມາດແບ່ງປັນເນື້ອໃນຈາກລາຍການເຮືອນຂອງເຂົາເຈົ້າ. ຖ້າທ່ານມີ ຄຳ ຖາມກ່ຽວກັບບົດຂຽນນີ້, ທ່ານສາມາດສອບຖາມໄດ້ໃນສ່ວນ ຄຳ ເຫັນຂ້າງລຸ່ມນີ້.