0
我擁有最新的全新Debian服務器。該網站只能託管1個單一的域名。 DNS由註冊商解決,A指向我的專用服務器。網站存在於/var/www/
。將域名添加到Debian服務器的最簡單方法是什麼?
什麼是最簡單的方法(一步一步)配置Apache來添加此域名?
我擁有最新的全新Debian服務器。該網站只能託管1個單一的域名。 DNS由註冊商解決,A指向我的專用服務器。網站存在於/var/www/
。將域名添加到Debian服務器的最簡單方法是什麼?
什麼是最簡單的方法(一步一步)配置Apache來添加此域名?
這應該是非常簡單明瞭:
sudo aptitude install apache2
)sudo service apache2 restart
)/etc/hosts
你也可以使用自動向導sudo dpkg-reconfigure apache2
。
我認爲這應該是足夠的,如果你的DNS已經指向你的IP。
如果你確實需要更改配置文件,它在etc/apache2/sites-available/default
,包含以下(默認):
NameVirtualHost *
<VirtualHost *>
ServerAdmin [email protected] # <= Email of webadmin (shown on error pages)
DocumentRoot /var/www/ # <= Root of your web server with public access
<Directory />
Options FollowSymLinks
AllowOverride None # <= Disable usage of .htaccess files
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have/go to the right place
#RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
至於hosts文件,你可以添加以下內容:
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#Virtual Hosts
12.34.56.789 example.com #<= change here :)
然後,不要忘記用適當的工具(iptables,fail2ban,...)保護您的web服務器