Ubuntu下通過apache建立虛擬機器主機

來源:互聯網
上載者:User

一個搞前端互動的,總會遇到這樣那樣的,不需要寫代碼去解決的問題,怎麼搞?
答:只能去大海裡撈,問題很明確但答案不一定靠譜,因為回答的人不用去考慮你是否會給自己系統搞崩潰。

那麼我只能把自己經過驗證的答案整出來,問題細化,做個記錄,同時協助還在摸索該問題的人。

第一步:

1 cd /etc/apache2/sites-available/

第二步:
拷貝另為一份設定檔,名字就叫appstore

1 cp default ./appstore

第三步:

1 sudo vi appstore

修改預設配置:

 1 <VirtualHost *:80> 2         ServerAdmin webmaster@localhost 3  4         DocumentRoot /var/www 5         <Directory /> 6                 Options FollowSymLinks 7                 AllowOverride None 8         </Directory> 9         <Directory /var/www/>10                 Options Indexes FollowSymLinks MultiViews11                 AllowOverride None12                 Order allow,deny13                 allow from all14         </Directory>15 16         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/17         <Directory "/usr/lib/cgi-bin">18                 AllowOverride None19                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch20                 Order allow,deny21                 Allow from all22         </Directory>23 24         ErrorLog ${APACHE_LOG_DIR}/error.log25 26         # Possible values include: debug, info, notice, warn, error, crit,27         # alert, emerg.28         LogLevel warn29 30         CustomLog ${APACHE_LOG_DIR}/access.log combined31 32     Alias /doc/ "/usr/share/doc/"33     <Directory "/usr/share/doc/">34         Options Indexes MultiViews FollowSymLinks35         AllowOverride None36         Order deny,allow37         Deny from all38         Allow from 127.0.0.0/255.0.0.0 ::1/12839     </Directory>40 41 </VirtualHost>

為:

 1 <VirtualHost *:8080>                          //連接埠和地址 2         ServerAdmin webmaster@localhost 3  4         DocumentRoot /var/www/appstore               //環境路徑(之前www是根目錄,如果訪問8080連接埠,那根目錄就是appstore) 5         <Directory /> 6                 Options FollowSymLinks 7                 AllowOverride None 8         </Directory> 9         <Directory /var/www/appstore/>               //環境路徑10                 Options Indexes FollowSymLinks MultiViews11                 AllowOverride None12                 Order allow,deny13                 allow from all14         </Directory>15 16         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/17         <Directory "/usr/lib/cgi-bin">18                 AllowOverride None19                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch20                 Order allow,deny21                 Allow from all22         </Directory>23 24         ErrorLog ${APACHE_LOG_DIR}/appstore_error.log          //apache錯誤列印25 26         # Possible values include: debug, info, notice, warn, error, crit,27         # alert, emerg.28         LogLevel warn29 30         CustomLog ${APACHE_LOG_DIR}/appstore_access.log combined        //apache進入錯誤列印31      Alias /doc/ "/usr/share/doc/"32      <Directory "/usr/share/doc/">33          Options Indexes MultiViews FollowSymLinks34          AllowOverride None35          Order deny,allow36          Deny from all37          Allow from 127.0.0.0/255.0.0.0 ::1/12838      </Directory>39 40 </VirtualHost>

第四步:

1 sudo vi ../ports.conf

增加:

1 NameVirtualHost *:80802     Listen 8080

第五步:

1 sudo a2ensite appstore

第六步:

1 sudo service apache2 restart

ok!訪問8080連接埠地址試試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.