日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux apache ip配置,linux apache虚拟主机配置(基于ip,端口,域名)

發布時間:2023/12/15 linux 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux apache ip配置,linux apache虚拟主机配置(基于ip,端口,域名) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

配置環境:

linux版本:Centos6.4

httpd版本:

[[email?protected] init.d]# pwd

/etc/init.d

[[email?protected] init.d]# httpd -v

Server version: Apache/2.2.15 (Unix)

Server built: Oct 19 2017 16:43:38

1,安裝httpd服務

yum install httpd -y

2,關閉selinux和防火墻

臨時設置selinux為permissive( disabled )狀態

Enforcing

[[email?protected] ~]# setenforce 0

Permissive

永久修改方法:

[[email?protected] ~]# vim /etc/sysconfig/selinux

SELINUX=permissive

3,關閉防火墻

service iptables stop

第一種,基于多ip訪問的配置:

1,先把httpd.conf備份一下,以防出錯,可以恢復

httpd.conf的文件路徑(?/etc/httpd/conf )

[[email?protected] conf]# ls

httpd.conf httpd.conf.bak magic

2,如果需要啟用虛擬主機配置,先把中心主機的配置注釋,

#DocumentRoot "/var/www/html"

3,在httpd.conf中,會默認包conf.d目錄中的所有 以.conf結尾的配置文件

Include conf.d/*.conf

所以,把虛擬主機的配置文件獨立出來放在conf.d目錄下

[[email?protected] httpd]# ls

conf conf.d logs modules run

[[email?protected] httpd]# pwd

/etc/httpd

[[email?protected] httpd]# cd conf.d

[[email?protected] conf.d]# pwd

/etc/httpd/conf.d

[[email?protected] conf.d]# ls

README VirtualHost.conf welcome.conf

VirtualHost.conf 配置文件內容:

ServerName www.7mxt.com

DocumentRoot "/www/7mxt.com"

ServerName www.7mxt.net

DocumentRoot "/www/7mxt.net"

我的主機ip是192.168.1.8,添加另一個ip:

ip addr add 192.168.1.2/24 dev eth0

在對應的目錄建立文件:

[[email?protected] www]# tree

.

├── 7mxt.com

│?? └── index.html

└── 7mxt.net

└── index.html

重啟服務: service httpd restart,在瀏覽器中分別用這兩個ip訪問,就能看到對應的頁面

第二種,基于多端口訪問的配置:

1,在VirtualHost.conf中增加一項配置:

ServerName www.7mxt.com

DocumentRoot "/www/7mxt.com"

ServerName www.7mxt.net

DocumentRoot "/www/7mxt.net"

ServerName www.abc.net

DocumentRoot "/www/abc.net"

2,在httpd.conf監聽8080端口

Listen 80

Listen 8080

3,/www建立對應的目錄和文件

重啟服務: service httpd restart,在瀏覽器中用http://192.168.1.2:8080/? 就能訪問到abc.net目錄下面的文件index.html內容

[[email?protected] www]# tree

.

├── 7mxt.com

│?? └── index.html

├── 7mxt.net

│?? └── index.html

└── abc.net

└── index.html

第三種:基于域名的主機配置

1,NameVirtualHost:指定192.168.1.8:80這個ip地址使用域名解釋

NameVirtualHost 192.168.1.8:80

ServerName www.7mxt.com

DocumentRoot "/www/7mxt.com"

ServerName www.7mxt.org

DocumentRoot "/www/7mxt.org"

ServerName www.7mxt.net

DocumentRoot "/www/7mxt.net"

ServerName www.abc.net

DocumentRoot "/www/abc.net"

2,在對應的目錄下建立文件

[[email?protected] www]# tree

.

├── 7mxt.com

│?? └── index.html

├── 7mxt.net

│?? └── index.html

├── 7mxt.org

│?? └── index.html

└── abc.net

└── index.html

3,在windows host文件中增加主機映射配置

【C:\Windows\System32\drivers\etc】

192.168.1.8 www.7mxt.com

192.168.1.8 www.7mxt.org

4,重啟服務: service httpd restart,分別用域名www.7mxt.com, www.7mxt.org就能訪問到對應的文件內容

使用ip: 192.168.1.8返回的是第一個虛擬主機的配置,即:www.7mxt.com對應目錄下面的內容

原文:http://www.cnblogs.com/ghostwu/p/7827104.html

總結

以上是生活随笔為你收集整理的linux apache ip配置,linux apache虚拟主机配置(基于ip,端口,域名)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。