Posted on April 23, 2011, 8:29 pm
httpd-vhosts.conf ជាហ្វាល់ មួយ របស់ Apache Web Server ប្រើសំរាប់ កំណត់ទីតាំង Default នៃ Web Project របស់លោកអ្នក ។
វាប្រៀបដូចជា Dictionary ប្រើសំរាប់ Mape ទីតាំង នៃ Web Project របស់លោកអ្នក ជាមួយនិង Address ដែល អ្នក Request ពី Web Browser ។
ហេតុអ្វី vhosts.conf ?
គឺមាភាពងាយស្រួលក្នុងការ access web project របស់អ្នក
ស្រួលចាំ local web project address (friendly name)
ឧ. http://www.example.local => Access file ក្នុង (D:/wamp/www/example)
ឧ. http://www.meas.local => Access file ក្នុង (D:/wamp/www/meas)
![]() |
របៀប Configure ?
១.)
ចុច លើ Wamp Server របស់អ្នក => Apache => httpd.conf
ហើយស្វែរក ពាក្យ (Include conf/extra/httpd-vhosts.conf) សូម លុប សញ្ញា (#
) ចេញពីមុខវា
# Include conf/extra/httpd-vhosts.conf => Include conf/extra/httpd-vhosts.conf
![]() |
២.)
ចូលទៅក្នុងទីតាំងដែលបានតំឡើង Apache ហើយរកមើល ឯកសារ (httpd-vhosts.conf) ដើម្បីកែរ
ជាទូទៅវាស្ថិតនៅក្នុង (wamp\bin\apache\Apache2.2.17\conf\extra \httpd-vhosts.conf) សូមបើក ឯកសារនេះដើម្បី បន្ថែម (វាជា Text File)
រកមើល កូដខាងក្រោម ហើយ កែវា
<virtualhost *:80="">
ServerAdmin webmaster@dummy-host.hleclerc-PC.ingenidev
DocumentRoot ទីតាំង Web Project របស់អ្នក
ServerName Friendly Name សំរាប់ប្រើ
ServerAlias Alias Name សំរាប់ប្រើ
ErrorLog "logs/dummy-host.hleclerc-PC.ingenidev-error.log"
CustomLog "logs/dummy-host.hleclerc-PC.ingenidev-access.log" common
</virtualhost>
ឧ.
<virtualhost *:80="">
ServerAdmin webmaster@dummy-host.hleclerc-PC.ingenidev
DocumentRoot "D:/wamp/www/my_web_project"
ServerName my_web_project.local
ServerAlias www.my_web_project.local
ErrorLog "logs/dummy-host.hleclerc-PC.ingenidev-error.log"
CustomLog "logs/dummy-host.hleclerc-PC.ingenidev-access.log" common
</virtualhost>
សូម Save ហើយបិតវា ។
៣.)
នៅមិនទាន់ចប់ទេ ដំណាក់កាលចុង ក្រោយ គឺត្រូវចូលទៅ កែ host file មួយទៀត
ចូលបើឯកសារ text file នៅទីតាំនេះ (C:\WINDOWS\system32\drivers\etc) ហើយ បើក file (HOSTS) ជាមួយ NotePad or WordPad ហើយសរសេបន្ថែម នៅពីក្រោម
defaultIP Tab ServerName Tab ServerAlias (ServerName និង ServerAlias ដូចដែលអ្នកបានកែនៅក្នុង httpd-vhosts.conf)
ឧ.
127.0.0.1 my_web_project.local www.my_web_project.local
Save File ហើ Restar Apache Server ឡើងវិញ ហើសាកល្បង បើក Web Project របស់អ្នក ជាមួយ Address ថ្មី ៕