簡體   English   中英

如何在apache vhosts文件中列出所有當前條目以顯示在開發人員站點的默認網頁上?

[英]How can I list all the current entries in my apache vhosts file for display on my dev site's default web page?

我有一個開發服務器,上面運行着大量站點,並且它每周更改一次。 我想要一個動態列表,而不是不斷更新默認網頁以提供指向它的鏈接。

基本上我想展示

<ul>
  <li><a href="http://example1.dev.ourdomain.com">example1.dev.ourdomain.com</a></li>
  <li><a href="http://example1.staging.ourdomain.com">example1.dev.ourdomain.com</a></li>
  <li><a href="http://example2.dev.ourdomain.com">example2.dev.ourdomain.com</a></li>
  <li><a href="http://example2.staging.ourdomain.com">example2.dev.ourdomain.com</a></li>
</ul>

動態地為我們的開發人員服務。

由於這是一個非常簡單的網站,僅鏈接到網站,因此我將在服務器端包含中使用html。

1)我需要在apache配置中使用它(例如/etc/httpd/conf/httpd.conf):

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

crontab提取網址並從中創建鏈接:

30 2 * * * /usr/sbin/httpd -S | egrep -i 'ourdomain.com' | egrep -i 'namevhost' | sed -e 's/.* \([0-9A-Za-z.-]*\.ourdomain\.com\).*/<li><a href="http:\/\/\1">\1<\/a><\/li>/i' > /websites/ourdomain/current_sites.html

(一個問題...這都只是namevhost條目,我可能必須更具體一些)

3)在/websites/ourdomain/index.shtml創建html頁面

<html><body>
   <h3>This list is compiled from the current VHOST entries every night at 2:30 am</h3>
   <ul class="links">
     <!--#include virtual="current_sites.html" -->
   </ul>
</body></html>

4)每當有人在dev.ourdomain.com上鍵入我們尚未處理的任何內容時,將vhosts文件更新為默認值(這不是全部必要,僅是我們的設置)

<VirtualHost *:80>

  ServerName dev.ourdomain.com
  ServerAlias *.dev.ourdomain.com

  DocumentRoot /websites/ourdomain
  <Directory /websites/ourdomain>
    # This relaxes Apache security settings.
    AllowOverride all
    # MultiViews must be turned off.
    Options -MultiViews
    Options +Includes
    # Redirects
    RewriteEngine on
    RewriteBase /websites/ourdomain
  </Directory>

  # Our security group
  <Location />
    Require user admin
  </Location>

</VirtualHost>

我想就是這樣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM