1. ubuntu 服务器安装 apache 服务器软件:
sudo apt-get install apache2
2. 配置 apache 服务器:
cd /etc/apache2/sites-available
sudo cp 000-default.conf appserv.conf
sudo vim appserv.conf
注意红色字体修改;
<VirtualHost *:8010>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/appserv
<Directory /var/www/html/appserv>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
3. 创建 link 文件:
sudo ln -s /etc/apache2/sites-available/appserv.conf /etc/apache2/sites-enabled/appserv.conf
或者使用a2ensite 命令启用虚拟主机
sudo a2ensite appserv
4. 修改 ports.conf 允许 apache 监听8010端口:
sudo vim /etc/apache2/ports.conf
添加 Listen 8010
5. 重启apache 服务器
sudo /etc/init.d/apache2 restart
然后在浏览器访问:
http://192.168.1.250:8010/
Reference:
Ubuntu上安装Apache,每次重启,都会出现以下错误提示:
Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
解决方法:
http://blog.csdn.net/klinghr/article/details/5378271