网站首页 > 技术教程 正文
前言:
项目测试,部署,我们难免会想着将不同的项目放到不同的目录去访问,或则作为程序员的你,仅仅是为了把妹也好~本文带你简单配置httpd实现访问不同的一二级域名访问不同的项目目录结构。
阅读本文前需要你拥有自己的阿里云 ecs 服务器,并且一个域名。这里讲的httpd实现反向代理方案,至于https的代理需要ssl证书,这里不做讲解。当然了,还有nginx的实现,后面我再陆续给大家讲解。
正文:
1.先 yum list 看看有没有你可以的包
yum list httpd
2.如果有的话,比如我用 x86_64 版,就可以安装
yum install httpd.x86_64
3.添加二级域名解析
4.修改代理配置
进入到安装目录:
cd /etc/httpd/conf vi httpd.conf
完整 httpd.conf 配置如下
ServerRoot "/etc/httpd" Listen 80 LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule php5_module modules/libphp5.so Include conf.modules.d/*.conf User apache Group apache ServerAdmin root@localhost #ServerName www.example.com:80 <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/var/www/html" <Directory "/var/www"> AllowOverride None Require all granted </Directory> # Further relax access to the default document root: <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig /etc/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> AddDefaultCharset UTF-8 <IfModule mime_magic_module> MIMEMagicFile conf/magic </IfModule> EnableSendfile on IncludeOptional conf.d/*.conf <VirtualHost *:80> ServerAdmin scqshine@yeah.net DocumentRoot "/var/www/html" ServerName www.beijingdesigner.com ServerAlias www.beijingdesigner.com beijingdesigner.com DirectoryIndex index.php index.html index.htm </VirtualHost> <VirtualHost *:80> ServerAdmin scqshine@yeah.net DocumentRoot "/var/www/app" ServerName app.beijingdesigner.com ServerAlias app.beijingdesigner.com DirectoryIndex index.php index.html index.htm </VirtualHost> <VirtualHost *:80> ServerAdmin scqshine@yeah.net DocumentRoot "/var/www/contact" ServerName contact.beijingdesigner.com ServerAlias contact.beijingdesigner.com DirectoryIndex index.php index.html index.htm </VirtualHost>
编辑完后:ew!保存退出即可。
说明:
这里模拟的是三个目录,你可以将你的项目分别部署到这三个目录进行访问。
为什么端口都写成 80,因为 http 访问 ip 后不跟端口号的话,
会自动跳转到 80 端口,所以这里配好 80 后,你部署好项目,直
接重启 httpd 服务,浏览器输入你的一级域名/二级域名不带端口
号,直接就打开了你的上面配置的< DirectoryIndex >的项目了,比
如 index.html/index.php/index.htm等。如果你还没准备好一个
完整的 javaweb 项目,或则 php 项目,那么你只需要在你设定好的
目录下放一个 index.html 即可,以便后续测试。
5.停止httpd 服务
service httpd stop
6.开启httpd 服务
service httpd start
7.验证
访问一级域名:
www.beijingdesigner.com
访问二级域名:
app.beijingdesigner.com
访问二级级域名:
contact.beijingdesigner.com
好了,以上就是httpd的实现方式,后面我们循序渐进,给大家讲nginx实现方式。
猜你喜欢
- 2024-10-14 如何通过nginx反向代理来调试代码?
- 2024-10-14 云服务器部署1【Nginx、Supervisor、Flask、Python】
- 2024-10-14 利用ngrok或nginx公开内网服务到外网
- 2024-10-14 Nginx 配置 Https 免费证书访问(视频看不了是否配置了https证书)
- 2024-10-14 nginx反向代理配置去除前缀(nginx做反向代理后屏蔽url)
- 2024-10-14 经验分享:日活1万的wap页,每天稳定带来2000个激活
- 2024-10-14 nginx下关于配置https证书的流程(nginx配置文件详解)
- 2024-10-02 单域名服务器下部署多个二级目录的laravel应用
- 2024-10-02 Nginx 配置 Https 免费证书访问(视频看不了是否配置了https证书)
- 2024-10-02 SEO必知:如何将顶级域名做301重定向到www二级域名
你 发表评论:
欢迎- 08-06linux 和 windows文件格式互相转换
- 08-06谷歌 ChromeOS 已支持 7z、iso、tar 文件格式
- 08-06Linux下比较文件内容的6种方法
- 08-06文件格式及功能汇总
- 08-0610个Linux文件内容查看命令的实用示例
- 08-06Linux-如何区分不同文件类型
- 08-06Zabbix技术分享——监控windows进程资源使用情况
- 08-06Linux系统卡顿?学会ps命令这三招,轻松定位问题进程
- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)