在 Ubuntu 8.0.4下设置静态IP和虚拟机

来源:互联网 发布:软件培训公司 编辑:程序博客网 时间:2024/05/29 09:29

1-手动修改网络配置文件:

sudo gedit /etc/network/interfaces

加入(或者修改)下列行:

auto lo eth0
iface lo inet loopback
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0:0
iface eth0:0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0:1
iface eth0:1 inet static
address 192.168.1.12
netmask 255.255.255.0
gateway 192.168.1.1

保存修改。

2.2-手动修改DNS配置文件:

sudo nano /etc/resolv.conf

加入(或者修改)下列行:

# Generated by NetworkManager
nameserver 192.168.1.1
nameserver 202.106.46.151

保存修改。

2.3- 手动重启网络服务:

sudo /etc/init.d/networking restart

返回结果如下:

*Reconfiguring network interfaces… [OK]

现在,你可以在终端里输入ifconfig命令来查看你修改的结果。如果不对,你还需要重启下。
设置apache的虚拟机
1 在workspace里添加doucument root
2 在/etc/apache2/sites-available 创建虚拟机配置文件 192.168.1.10, 内容如下:

<VirtualHost 192.168.1.10:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/edwin/Zend/workspaces/DefaultWorkspace/ZfProjects-Main/Public

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/192.168.1.10.error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/192.168.1.10.access.log combined

Alias /doc/ "/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


<VirtualHost *:80>

3 重启apache 服务
sudo a2ensite 192.168.1.10
sudo /etc/init.d/apache2 restart