linux中openSUSE 的 Apache配置步驟詳解

來源:互聯網
上載者:User

DNS 綁定 A 記錄#

首先在 DNS 上建立 A 記錄,將網域名稱綁定到相應 IP 上。
建立網站目錄#

在伺服器上,添加 /srv/www/vhosts/www.111cn.net 目錄,並在該目錄下建立一個 index.html 檔案 – 用於測試。
配置 Apache#

建立虛擬機器主機設定檔#

 代碼如下 複製代碼
$ cd /etc/apache2/vhosts.d
$ sudo cp vhost.template www.111cn.net.conf

修改 www.111cn.net.conf 檔案內容如下:

 代碼如下 複製代碼

<VirtualHost *:80>
    ServerName www.111cn.net
    ServerAdmin chenxsan@gmail.com

    DocumentRoot /srv/www/vhosts/www.111cn.net

    ErrorLog /var/log/apache2/www.111cn.net-error_log
    CustomLog /var/log/apache2/www.111cn.net-access_log combined

    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName Off

    # configures the footer on server-generated documents
    ServerSignature On

    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/srv/www/vhosts/www.111cn.net">
        AllowOverride All
        Options FollowSymLinks

        Order allow,deny
        Allow from all

    </Directory>

</VirtualHost>

之後重啟 Apache:

$ sudo rcapache2 restart

訪問 www.111cn.net 網址,已經可以看到 index.html 檔案的內容了。如果我們之前未添加 index.html 檔案,訪問的話,則會出現如下錯誤資訊:
Access forbidden!
You don’t have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
www.111cn.net

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.