温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2021-12-10 17:48:07 来源:亿速云 阅读:89 作者:柒染 栏目:大数据

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

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

1.开启虚拟主机

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

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   在文件的最后,添加以下内容

<VirtualHost192.168.10.60:80>

    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

</VirtualHost>

<VirtualHost 192.168.10.90:80>

    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

</VirtualHost>

测试:

[root@xuegod60 conf]# service httpd restart

http://192.168.10.60/

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

http://192.168.10.90/

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

方法二:通过不同域名:

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

修改httpd.conf

#vim httpd.conf

<VirtualHost *:80>

    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

</VirtualHost>

<VirtualHost *:80>

    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

</VirtualHost>

在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

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

bbs.xuegod.com

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

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

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

添加90端口

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

<VirtualHost *:80>

    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>

<VirtualHost *:90>

    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

</VirtualHost>

测试:

[root@xuegod60 conf]# service httpd restart

http://192.168.10.60/

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

http://192.168.10.60:90

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

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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI