25 ຄຳ ຖາມ ສຳ ພາດ Apache ສຳ ລັບຜູ້ເລີ່ມຕົ້ນແລະຕົວກາງ
ພວກເຮົາຂໍຂອບໃຈຜູ້ອ່ານທຸກທ່ານທີ່ໄດ້ຮັບ ຄຳ ຕອບ ສຳ ລັບສ່ວນ ສຳ ພາດ Linux ໃໝ່ ຂອງພວກເຮົາ. ແລະຕອນນີ້ພວກເຮົາໄດ້ເລີ່ມຕົ້ນພາກສ່ວນການຮຽນຮູ້ທີ່ສະຫລາດ ສຳ ລັບ ຄຳ ຖາມ ສຳ ພາດແລະສືບຕໍ່ໃນບົດຄວາມມື້ນີ້ຄືກັນສຸມໃສ່ ຄຳ ຖາມ ສຳ ພາດກ່ຽວກັບ Basic to Intermediate Apache ເຊິ່ງຈະຊ່ວຍໃຫ້ທ່ານກຽມຕົວເອງ.
ໃນພາກນີ້, ພວກເຮົາໄດ້ກວມເອົາ ຄຳ ຖາມ ສຳ ພາດ 25 Apache ທີ່ ໜ້າ ສົນໃຈພ້ອມກັບ ຄຳ ຕອບຂອງພວກເຂົາເພື່ອໃຫ້ທ່ານເຂົ້າໃຈບາງຢ່າງກ່ຽວກັບ Apache ທີ່ທ່ານບໍ່ເຄີຍຮູ້ມາກ່ອນ.
ກ່ອນທີ່ທ່ານຈະອ່ານບົດຄວາມນີ້, ພວກເຮົາຂໍແນະ ນຳ ໃຫ້ທ່ານຢ່າພະຍາຍາມຈົດ ຈຳ ຄຳ ຕອບ, ຕ້ອງພະຍາຍາມ ທຳ ຄວາມເຂົ້າໃຈສະຖານະການກ່ອນອື່ນ ໝົດ.
rpm -qa | grep httpd httpd-devel-2.2.15-29.el6.centos.i686 httpd-2.2.15-29.el6.centos.i686 httpd-tools-2.2.15-29.el6.centos.i686
httpd -v Server version: Apache/2.2.15 (Unix) Server built: Aug 13 2013 17:27:11
netstat -antp | grep http tcp 0 0 :::80 :::* LISTEN 1076/httpd tcp 0 0 :::443 :::* LISTEN 1076/httpd
yum install httpd
apt-get install apache2
cd /etc/httpd/ ls -l total 8 drwxr-xr-x. 2 root root 4096 Dec 24 21:44 conf drwxr-xr-x. 2 root root 4096 Dec 25 02:09 conf.d lrwxrwxrwx 1 root root 19 Oct 13 19:06 logs -> ../../var/log/httpd lrwxrwxrwx 1 root root 27 Oct 13 19:06 modules -> ../../usr/lib/httpd/modules lrwxrwxrwx 1 root root 19 Oct 13 19:06 run -> ../../var/run/httpd
cd /etc/apache2 ls -l total 84 -rw-r--r-- 1 root root 7113 Jul 24 16:15 apache2.conf drwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-available drwxr-xr-x 2 root root 4096 Dec 16 11:45 conf.d drwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-enabled -rw-r--r-- 1 root root 1782 Jul 21 02:14 envvars -rw-r--r-- 1 root root 31063 Jul 21 02:14 magic drwxr-xr-x 2 root root 12288 Dec 16 11:48 mods-available drwxr-xr-x 2 root root 4096 Dec 16 11:48 mods-enabled -rw-r--r-- 1 root root 315 Jul 21 02:14 ports.conf drwxr-xr-x 2 root root 4096 Dec 16 11:48 sites-available drwxr-xr-x 2 root root 4096 Dec 6 00:04 sites-enabled
7. Apache ສາມາດຮັບປະກັນໄດ້ດ້ວຍການຫໍ່ຂອງ TCP ບໍ?
ສົມມຸດວ່າທ່ານມີຫລາຍ IP ທີ່ຖືກມອບ ໝາຍ ໃຫ້ກັບເຄື່ອງ Linux ຂອງທ່ານແລະຢາກໃຫ້ Apache ໄດ້ຮັບ ຄຳ ຮ້ອງຂໍ HTTP ໃນພອດ Ethernet ພິເສດຫລືອິນເຕີເຟດ, ເຖິງແມ່ນວ່າມັນສາມາດເຮັດໄດ້ດ້ວຍ ຄຳ ສັ່ງຟັງ.
ເພື່ອປ່ຽນພອດທີ່ຢູ່ໃນຕອນຕົ້ນຂອງ Apache, ກະລຸນາເປີດເອກະສານຕັ້ງຄ່າຕົ້ນຕໍຂອງ Apache ຂອງທ່ານ httpd.conf ຫຼືໄຟລ໌ apache2.conf ກັບບັນນາທິການ VI.
vi /etc/httpd/conf/httpd.conf vi /etc/apache2/apache2.conf
ຄົ້ນຫາ ຄຳ ວ່າ "ຟັງ", ໃຫ້ ຄຳ ເຫັນຕົ້ນສະບັບແລະຂຽນທິດທາງຂອງທ່ານຢູ່ລຸ່ມເສັ້ນນັ້ນ.
# Listen 80 Listen 8080 OR Listen 172.16.16.1:8080
ບັນທຶກເອກະສານດັ່ງກ່າວແລະເລີ່ມຕົ້ນເວັບ server ຄືນ ໃໝ່.
service httpd restart service apache2 restart
ການ ນຳ ໃຊ້ Alias directive, ສ່ວນຂອງໂມດູນ mod_alias ຂອງ Apache. syntax ເລີ່ມຕົ້ນຂອງ ຄຳ ສັ່ງ Alias ແມ່ນ:
Alias /images /var/data/images/
ນີ້ແມ່ນຕົວຢ່າງຂ້າງເທິງນີ້,/ຮູບພາບຕ່າງໆ url ໃສ່ ຄຳ ນຳ ໜ້າ/var/data/ຮູບພາບຕ່າງໆທີ່ ໝາຍ ຄວາມວ່າລູກຄ້າຈະສອບຖາມ“ http://www.example.com/images/sample-image.png” ແລະ Apache ຈະເລືອກເອົາ“ sample-image.png” file ຈາກ /var/data/images/sample-image.png ເທິງ server. ມັນຍັງເອີ້ນວ່າ URL ແຜນທີ່.
ການຕັ້ງຄ່າຄ່າເລີ່ມຕົ້ນຂອງ DirectoryIndex ແມ່ນ .html index.html index.php, ຖ້າທ່ານມີຊື່ທີ່ແຕກຕ່າງກັນຂອງເອກະສານ ທຳ ອິດຂອງທ່ານ, ທ່ານ ຈຳ ເປັນຕ້ອງເຮັດການປ່ຽນແປງໃນ httpd.conf ຫຼື apache2.conf ສຳ ລັບຄ່າ DirectoryIndex ເພື່ອສະແດງຄ່ານັ້ນໃຫ້ກັບ browser ຂອງລູກຄ້າຂອງທ່ານ.
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # # The index.html.var file (a type-map) is used to deliver content- # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # DirectoryIndex index.html index.html.var index.cgi .exe
ການຢຸດລາຍຊື່ໄດເລກະທໍລີ Apache, ທ່ານສາມາດ ກຳ ນົດກົດລະບຽບຕໍ່ໄປນີ້ໃນແຟ້ມການຕັ້ງຄ່າຕົ້ນຕໍທົ່ວໂລກຫຼືໃນເອກະສານ .htaccess ສຳ ລັບເວັບໄຊທ໌ໃດ ໜຶ່ງ.
<Directory /var/www/html> Options -Indexes </Directory>
ທ່ານສາມາດເພີ່ມ ຄຳ ແນະ ນຳ ຫຼາຍຢ່າງທີ່ທ່ານຕ້ອງການ ສຳ ລັບໂດເມນຂອງທ່ານ, ແຕ່ວ່າສອງລາຍການທີ່ ໜ້ອຍ ທີ່ສຸດ ສຳ ລັບເວບໄຊທ໌ທີ່ເຮັດວຽກແມ່ນ ServerName ແລະ DocumentRoot. ພວກເຮົາມັກຈະ ກຳ ນົດພາກ Virtual Host ຂອງພວກເຮົາຢູ່ທາງລຸ່ມຂອງເອກະສານ httpd.conf ໃນເຄື່ອງ Linux.
<VirtualHost *:80> ServerAdmin [email DocumentRoot /www/docs/dummy-host.example.com ServerName dummy-host.example.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
<
<
ສໍາລັບຂໍ້ມູນເພີ່ມເຕີມ, ອ່ານກ່ຽວກັບວິທີການສ້າງຊື່/IP ທີ່ໃຊ້ Virtual Host ທີ່ຢູ່ໃນ Apache.
<
ຕົວຢ່າງ: ຂ້ອຍຕ້ອງການໃສ່ຂີດ ຈຳ ກັດ 100000 ໄບຕ໌ໃນໂຟນເດີ/var/www/html/tecmin/uploads. ດັ່ງນັ້ນ, ທ່ານ ຈຳ ເປັນຕ້ອງເພີ່ມ ຄຳ ແນະ ນຳ ຕໍ່ໄປນີ້ໃນແຟ້ມການຕັ້ງຄ່າຂອງ Apache.
<Directory "/var/www/html/tecmint/uploads"> LimitRequestBody 100000 </Directory>
<
ສຳ ລັບຂໍ້ມູນເພີ່ມເຕີມ, ອ່ານບົດຄວາມທີ່ຈະແນະ ນຳ ວິທີການຕິດຕັ້ງແລະ ກຳ ຫນົດຄ່າ mod_evasive ໃນ Apache.
ເມື່ອໃດກໍ່ຕາມທີ່ມີການຮ້ອງຂໍ https, ສາມບາດກ້າວເຫຼົ່ານີ້ Apache ປະຕິບັດຕາມ:
<
ນີ້ແມ່ນພຽງ 25 ຄຳ ຖາມທີ່ໄດ້ຮັບຄວາມນິຍົມທີ່ສຸດຈາກບັນດານັກ ສຳ ພາດ, ກະລຸນາໃຫ້ ຄຳ ຖາມ ສຳ ພາດເພີ່ມເຕີມເຊິ່ງທ່ານໄດ້ປະເຊີນ ໜ້າ ໃນການ ສຳ ພາດຂອງທ່ານທີ່ຜ່ານມາແລະຊ່ວຍຄົນອື່ນຜ່ານພາກ ຄຳ ເຫັນຂອງພວກເຮົາຂ້າງລຸ່ມນີ້.
ພວກເຮົາຍັງແນະ ນຳ ໃຫ້ທ່ານອ່ານບົດຄວາມທີ່ຜ່ານມາຂອງພວກເຮົາກ່ຽວກັບ Apache.
<
ນອກຈາກນີ້, ພວກເຮົາຍັງມີຄວາມພູມໃຈທີ່ຈະປະກາດວ່າພາກສ່ວນ ຄຳ ຖາມ/ຄຳ ຕອບ Beta ຂອງ TecMint Ask ຂອງພວກເຮົາໄດ້ເປີດຕົວແລ້ວ. ຖ້າທ່ານມີ ຄຳ ຖາມກ່ຽວກັບຫົວຂໍ້ Linux ໃດໆ. ກະລຸນາເຂົ້າຮ່ວມກັບພວກເຮົາແລະຂຽນ ຄຳ ຖາມ/ຄຳ ຖາມຂອງທ່ານທີ່ https://linux-console.net/ask/.
ຂ້ອຍຈະມີ ຄຳ ຖາມ ສຳ ພາດເພີ່ມເຕີມກ່ຽວກັບ DNS, server, PHP ແລະອື່ນໆໃນບົດຄວາມໃນອະນາຄົດຂອງພວກເຮົາ, ຈົນກວ່າຈະຢູ່ Geeky ແລະເຊື່ອມຕໍ່ກັບ TecMint.com.