千家信息网

如何进行源码编译搭建LAMP环境

发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,这篇文章将为大家详细讲解有关如何进行源码编译搭建LAMP环境,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。实战内容:搭建一个虚拟主机,并且演示三种不同
千家信息网最后更新 2024年09月23日如何进行源码编译搭建LAMP环境

这篇文章将为大家详细讲解有关如何进行源码编译搭建LAMP环境,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

实战内容:搭建一个虚拟主机,并且演示三种不同情况的浏览效果

1.开启虚拟主机


2.

方法1:通过不同的IP地址,解析不同域名

给服务器增加IP(另一个域名解析出来的那个IP)。

[root@xuegod60 conf]# ifconfigeth0:1 192.168.10.90 netmask 255.255.255.0 #添加一个ip

[root@xuegod60 conf]# mkdir -p/var/www/html/bbs #创建一个bbs目录

[root@xuegod60 conf]# echo"bbs.192.168.10.90" >/var/www/html/bbs/index.html

[root@xuegod60 conf]# ping192.168.10.90

PING 192.168.10.90(192.168.10.90) 56(84) bytes of data.

64 bytes from 192.168.10.90:icmp_seq=1 ttl=64 time=0.042 ms

修改httpd.conf

#vim httpd.conf 在文件的最后,添加以下内容

ServerAdminwebmaster@dummy-host.example.com

DocumentRoot/var/www/html/

ServerNamedummy-host.example.com

ErrorLoglogs/dummy-host.example.com-error_log

CustomLoglogs/dummy-host.example.com-access_log common

ServerAdminwebmaster@dummy-host.example.com

DocumentRoot/var/www/html/bbs/

ServerNamedummy-host.example.com

ErrorLoglogs/dummy-host.example.com-error_log

CustomLoglogs/dummy-host.example.com-access_log common

测试:

[root@xuegod60 conf]# service httpd restart

http://192.168.10.60/


http://192.168.10.90/


方法二:通过不同域名:

在域名管理后台,修改DNS配置,www.xuegod.com与bbs.xuegod.com解析成相同的IP。

修改httpd.conf

#vim httpd.conf

ServerAdminwebmaster@dummy-host.example.com

DocumentRoot/var/www/html/

ServerName www.xuegod.com

ErrorLog logs/www.xuegod.com-error_log

CustomLog logs/www.xuegod.com-access_logcommon

ServerAdminwebmaster@dummy-host.example.com

DocumentRoot /var/www/html/bbs/

ServerName bbs.xuegod.com

ErrorLog logs/bbs.xuegod.com-error_log

CustomLog logs/bbs.xuegod.com-access_log common

在windows下windows hosts文件在: C:\Windows\System32\drivers\etc

192.168.10.60 www.xuegod.com

192.168.10.60 bbs.xuegod.com

测试:

[root@xuegod60 conf]# servicehttpd restart

www.xuegod.com


bbs.xuegod.com


方法3:基于端口配置虚拟主机:

[root@xuegod60 conf]# vim /etc/httpd/conf/httpd.conf

添加90端口




ServerAdminwebmaster@dummy-host.example.com

DocumentRoot/var/www/html/

ServerNamewww.example.com

ErrorLoglogs/www.example.com-error_log

CustomLoglogs/www.example.com-access_log common

</VirtualHost>

ServerAdminwebmaster@dummy-host.example.com

DocumentRoot/var/www/html/bbs/

ServerNamebbs.example.com

ErrorLoglogs/bbs.example.com-error_log

CustomLoglogs/bbs.example.com-access_log common

测试:

[root@xuegod60 conf]# service httpd restart

http://192.168.10.60/


http://192.168.10.60:90


关于如何进行源码编译搭建LAMP环境就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0