×ðÁú¿­Ê±

CentOS´î½¨webЧÀÍÆ÷µÄÓòÃû°ó¶¨ÓëÐéÄâÖ÷»úÉèÖü¼ÇÉ

centos´î½¨webЧÀÍÆ÷µÄÓòÃû°ó¶¨ÓëÐéÄâÖ÷»úÉèÖü¼ÇÉ

µ¼Ó

ÔڴWebЧÀÍÆ÷ʱ£¬ÓòÃû°ó¶¨ÓëÐéÄâÖ÷»úµÄÉèÖÃÊǺÜÊÇÖ÷ÒªµÄÒ»²½¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚCentOSÉϾÙÐÐÓòÃû°ó¶¨ºÍÐéÄâÖ÷»úµÄÉèÖ㬲¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

Ò»¡¢ÓòÃû°ó¶¨

ÐÞ¸ÄhostsÎļþ

Ê×ÏÈ£¬ÐèÒªÔÚCentOSµÄhostsÎļþÖÐÌí¼ÓÓòÃûÓëIPµØµãµÄÓ³Éä¹Øϵ¡£ÕÒµ½²¢·­¿ªhostsÎļþ£¬Ò»Ñùƽ³£Î»ÓÚ/etc/hosts£º

sudo vi /etc/hosts

ÔÚÎļþµÄĩβÌí¼ÓÈçÏÂÐУ¬ÆäÖДwww.example.com”Ϊ×Ô½ç˵µÄÓòÃû£¬”192.168.0.100″ΪЧÀÍÆ÷µÄIPµØµã£º

192.168.0.100 www.example.com

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

ÉèÖÃDNSÆÊÎö

ÈôÊÇÄãµÄÓòÃûÊǾ­ÓÉ×¢²áµÄ£¬²¢ÇÒDNSÆÊÎöÒѾ­ÉúЧ£¬¿ÉÒÔÌø¹ýÕâÒ»²½¡£²»È»£¬ÐèÒªÔÚÓòÃû×¢²áÉ̵ĿØÖÆÃæ°åÖн«ÓòÃûÖ¸ÏòЧÀÍÆ÷µÄIPµØµã¡£

ÉèÖÃApache

½ÓÏÂÀ´£¬ÐèÒªÉèÖÃApacheЧÀÍÆ÷ÒÔ½«ÓòÃûÖ¸Ïò׼ȷµÄĿ¼¡£·­¿ªApacheµÄÖ÷ÉèÖÃÎļþhttpd.conf£º

sudo vi /etc/httpd/conf/httpd.conf

ÕÒµ½²¢ÐÞ¸ÄÈçÏÂÐУ¬½«”www.example.com”¸Ä³ÉÄãÏë°ó¶¨µÄÓòÃû£º

ServerName www.example.com:80

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

ÖØÆôApacheЧÀÍ£¬Ê¹ÉèÖÃÉúЧ£º

sudo service httpd restart

¶þ¡¢ÐéÄâÖ÷»úµÄÉèÖÃ

½¨ÉèÐéÄâÖ÷»úĿ¼

ÐéÄâÖ÷»úµÄÉèÖÃÐèÒªÒ»¸ö×ÔÁ¦µÄĿ¼À´´æ·ÅÍøÕ¾Îļþ¡£Ê×ÏÈ£¬½¨ÉèÒ»¸öĿ¼£¬ÓÃÓÚ´æ·ÅÐéÄâÖ÷»úµÄÎļþ£º

sudo mkdir /var/www/virtual_host

ÐÞ¸ÄApacheÉèÖÃÎļþ

·­¿ªApacheµÄÐéÄâÖ÷»úÉèÖÃÎļþhttpd-vhosts.conf£º

sudo vi /etc/httpd/conf.d/httpd-vhosts.conf

ÔÚÎļþĩ⣬Ìí¼ÓÈçÏÂÄÚÈÝ£¬Ìæ»»”example.com”ΪÄãµÄÓòÃû£¬”/var/www/virtual_host/example.com”ΪÄã¸Õ¸Õ½¨ÉèµÄĿ¼·¾¶£º

ServerName example.com
DocumentRoot /var/www/virtual_host/example.com
<Directory /var/www/virtual_host/example.com>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

ÉèÖÃȨÏÞ

ΪÁËÈ·±£ÍøÕ¾Îļþ¿ÉÒÔ±»Apache»á¼û£¬ÐèÒªÐÞ¸ÄÐéÄâÖ÷»úĿ¼µÄȨÏÞ£º

sudo chown -R apache:apache /var/www/virtual_host/example.com

sudo chmod -R 755 /var/www/virtual_host/example.com

ÖØÆôApacheЧÀÍ

ÖØÆôApacheЧÀÍ£¬Ê¹ÉèÖÃÉúЧ£º

sudo service httpd restart

ÖÁ´Ë£¬ÐéÄâÖ÷»úµÄÉèÖþÍÍê³ÉÁË¡£

´úÂëʾÀý£º

½¨Éèindex.htmlÎļþ

ÔÚÐéÄâÖ÷»úĿ¼ÖУ¬½¨ÉèÒ»¸öindex.htmlÎļþ£¬×÷ΪÍøÕ¾µÄÊ×Ò³£º

sudo vi /var/www/virtual_host/example.com/index.html

½«ÒÔÏÂÄÚÈÝÕ³Ìùµ½ÎļþÖУº

<title>Welcome to example.com!</title>

µÇ¼ºó¸´ÖÆ

<h1>Welcome to example.com!</h1>
<p>This is the default web page for the domain example.com.</p>

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇCentOS´î½¨webЧÀÍÆ÷µÄÓòÃû°ó¶¨ÓëÐéÄâÖ÷»úÉèÖü¼ÇɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿