logo资料库

linux下各种服务器配置大全.doc

第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
资料共11页,剩余部分请下载后查看
APACHE 服务的配置。 APACHE 的简介. APACHE 是世界上最流行的 Web 服务器软件之一,当然,提供 WWW 服务的还 有微软的 IIS,它是由微软开发的,只能用在微软的操作系统上,而 APACHE 是一 个自由软件。说到 APACHE,还要联想到 LAMP,这个近年来也是应用得非常广 泛,LAMP 就是:linux+apache+mysql+php。Apache 的特点是简单、速度快、性 能稳定。 APACHE 的安装。 配置 IP 地址: [root@rhel ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 IPADDR=192.168.100.101 NETMASK=255.255.255.0 [root@rhel ~]# service network restart 安装 apache: 首先安装下面这两个软件: [root@rhel ~]# rpm -ivh /misc/cd/Server/apr-1.2.7-11.el5_3.1.i386.rpm [root@rhel ~]# rpm -ivh /misc/cd/Server/apr-util-1.2.7-11.el5.i386.rpm 现在才能安装 httpd。 [root@rhel ~]# rpm -ivh /misc/cd/Server/httpd-2.2.3-43.el5.i386.rpm APACHE 简单的配置。 [root@rhel ~]# service httpd start 现在就可以测试一下了。如图,如下在地址栏输入 http://192.168.100.101,出现 如下画面,就说明 httpd 正常运行了。 //启动服务。
如果想把这个页面换成自己的网页,只需把写好的文件放入/var/www/html 下面即 可,下面举个简单的例子。如: [root@rhel ~]# echo chenbin.blog.51cto.com -> /var/www/html/index.html 访 问 测 试 一 下 :
用户的个人网站。 [root@rhel ~]# vi /etc/httpd/conf/httpd.conf :set number 找到,在下面有 //显示行号 UserDir disable #UserDir public_html 改成: #UserDir disable UserDir public_html [root@rhel ~]# service httpd restart 创建目录和网页文件。如果希望每个新建的用户都有一个 www 目录,只需在 /etc/skel/下添加 www 目录即可,因为每个用户的默认目录都是参考/etc/skel 的目 录。 [root@rhel ~]# mkdir public_html [root@rhel ~]# chmod 755 public_html //修改权限。
[root@rhel chenbin]# chmod 755 ~ [root@rhel ~]# echo hello > public_html/index.html 测试: 注意:在地址栏里输入的是 http://IP 地址或主机名/~root。在 root 前面有个~,在 键盘 ESC 键下面(数字1左边)那个键,要同时按住 shift 键。 那么有没有办法不输入那个~呢,当然是有的,最简单的方法就是添加一个链接: [root@rhel ~]# cd /var/www/html/ [root@rhel html]# ln -s /root/public_html/ root //创建一个链接,因为这里是 root 帐 户 , 所 以 是 /root/public_html , 如 果 是 其 他 用 户 , 应 该 是 /home/ 用 户 名 /public_html。 如果不想别人知道你的用户名,也可以把链接后面跟的用户名换成你想要的名字, 如: [root@rhel html]# ln -s /root/public_html/ linux 再访问: 当然还有别的方法,将在下面介绍。
现在如果我们有多个网站,但只有一个 IP 地址,那怎么让别人能同时访问这多个 网站呢? 相同 IP 不同端口的虚拟主机。 假设我们有一个 IP 是192.168.100.101,有两个网站,我们可以使用两个端口,比 如:一个使用81,一个使用82。 首先,把两个网站的目录和文件建立好。 [root@rhel html]# cd /var/www [root@rhel www]# mkdir html1 [root@rhel www]# mkdir html2 [root@rhel www]# echo html1 > html1/index.html [root@rhel www]# echo html2 > html2/index.html 修改配置文件: [root@rhel html]# vi /etc/httpd/conf/httpd.conf Listen 80 //在这下面添加两个端口 Listen 81 Listen 82 在最后添加: DocumentRoot /var/www/html1 DocumentRoot /var/www/html2 修改完成,重启服务: [root@rhel www]# service httpd restart 测试:
这时访问的时候有点不一样了,需要在 IP 地址后面加上:再加上端口号。 都可以访问,这就完成了。 不同 IP 相同端口的虚拟主机。 知道相同 IP 不同端口的配置了,这里相同端口不同 IP 就简单了,就按照上面的思 路做。 因为是多个 IP,所以这里就要配置多个 IP 地址,这里就配置子接口。 [root@rhel www]# ifconfig eth0:0 192.168.100.111 up [root@rhel www]# ifconfig eth0:1 192.168.100.112 up 创建目录和网页文件: [root@rhel www]# mkdir html3 [root@rhel www]# mkdir html4 [root@rhel www]# echo html3 > html3/index.html [root@rhel www]# echo html4 > html4/index.html 修改配置文件: [root@rhel www]# vi /etc/httpd/conf/httpd.conf 至于端口,就使用默认的80端口。 DocumentRoot /var/www/html3
DocumentRoot /var/www/html4 重启服务: [root@rhel www]# service httpd restart 测试: 下一个: 这个也就完成了。 使用域名的虚拟主机。 基于域名的虚拟主机,这就要用到 DNS 了,那么首先把 DNS 配置一下吧,虽然 前面有配置 DNS 的详细说明,但这里还是简单配置一下,就当复习一下。 安装 DNS 软件: [root@rhel www]# cd /misc/cd/Server/ [root@rhel Server]# rpm -ivh bind-9.3.6-4.P1.el5_4.2.i386.rpm [root@rhel Server]# rpm -ivh bind-chroot-9.3.6-4.P1.el5_4.2.i386.rpm [root@rhel Server]# rpm -ivh bind-utils-9.3.6-4.P1.el5_4.2.i386.rpm [root@rhel Server]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5_4.2.i386.rpm
[root@rhel Server]# cd ~ [root@rhel ~]# vi /var/named/chroot/etc/named.caching-nameserver.conf //修改一下 IP 地址。 listen-on port 53 { 192.168.100.101; }; allow-query { any; }; match-clients match-destinations { any; }; { any; }; //允许所有人查询。 //允许所有客户端。 //允许所有目标。 创建区域: [root@rhel ~]# vi /var/named/chroot/etc/named.rfc1912.zones 添加以下区域: zone "rhel1.com" IN { type master; file "rhel1.com.zone"; allow-update { none; }; }; zone "rhel2.com" IN { type master; file "rhel2.com.zone"; allow-update { none; }; }; 修改区域配置文件; [root@rhel ~]# cd /var/named/chroot/var/named/ [root@rhel named]# cp -p localhost.zone rhel1.com.zone //别忘了加-p。 [root@rhel named]# cp -p localhost.zone rhel2.com.zone [root@rhel named]# vi rhel1.com.zone www 192.168.100.101 IN A [root@rhel named]# vi rhel2.com.zone www IN A 192.168.100.101 //添加这一行 //也是添加这一行 配置完成,重启一下服务。 [root@rhel named]# service named restart 来测试一下 DNS:如图:
分享到:
收藏