• centos下利用httpd搭建http服务器方法


    centos下利用httpd搭建http服务器方法

    1. 解决的问题

    在开发测试过程中,分析图片任务需要将图片保存在服务器端,通过url来访问和下载该图片,这就需要使用一台图片服务器,但常常遇到图片服务器匮乏的情况,为了解决该问题,可以临时在自己电脑上搭建一个简易的图片服务器以供使用。本文给出了一种在centos系统上利用httpd搭建简易图片服务器的方法。

    2. 搭建步骤

    1)安装httpd服务
    在centos操作系统下执行shell命令:

    yum install httpd -y
    

    安装完成后,可通过命令whereis httpd查看安装位置

    [root@localhost ld]# whereis httpd
    httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd /usr/share/man/man8/httpd.8.gz
    

    rpm -qi httpd命令查看httpd的版本信息

    [root@localhost ld]# rpm -qi httpd
    Name        : httpd
    Version     : 2.4.6
    Release     : 80.el7.centos.1
    Architecture: x86_64
    Install Date: Mon 27 Aug 2018 02:10:31 PM CST
    Group       : System Environment/Daemons
    Size        : 9817285
    License     : ASL 2.0
    Signature   : RSA/SHA256, Tue 03 Jul 2018 10:31:55 PM CST, Key ID 24c6a8a7f4a80eb5
    Source RPM  : httpd-2.4.6-80.el7.centos.1.src.rpm
    Build Date  : Wed 27 Jun 2018 09:50:38 PM CST
    Build Host  : x86-01.bsys.centos.org
    Relocations : (not relocatable)
    Packager    : CentOS BuildSystem <http://bugs.centos.org>
    Vendor      : CentOS
    URL         : http://httpd.apache.org/
    Summary     : Apache HTTP Server
    Description :
    The Apache HTTP Server is a powerful, efficient, and extensible
    web server.
    

    2)启动http服务
    执行shell命令:

    systemctl start httpd.service
    

    3)配置文件说明
    配置文件为/etc/httpd/conf/ httpd.conf,有几个重要的参数需要配置:
    ① 端口
    Listen参数,默认值为80,但为了避免和其他程序冲突,修改为其他值。

    ② 静态文件的根目录

    DocumentRoot参数是需要生成url的文件存放路径。

    4)测试
    在浏览器输入http://服务器IP:port,看是否能进入HTTP样本网页,如果能进入如下页面,说明httpd服务器搭建成功。

    5)上传图片
    将需要生成url的图片上传到DocumentRoot指定的目录,即可在浏览器中访问和下载该图片。如保存lena.png图片在DocumentRoot指定的目录下,浏览器中输入http://10.66.91.11:7777/lena.png即可访问和下载该图片。

    1. 总结
      通过在centos中利用httpd服务搭建简易的图片服务器,即可将任意一个待分析的图片保存到指定目录后通过url进行图片的访问和下载分析。

    2. 参考
      1)Permission denied: make_sock: could not bind to address
      https://blog.csdn.net/ljm_503909378/article/details/41244659

    2) using localhost.localdomain for ServerName
    https://www.cnblogs.com/52linux/archive/2012/03/24/2415637.html

  • 相关阅读:
    关于 下载 nfs-utils时的 gssproxy conflicts with selinux-policy-3.13.1-102.el7.noarch 错误
    SCP命令
    DHCP服务
    NFS服务
    ssh免密登录
    可见性判断
    (八)图像处理
    (八)图像处理
    (八)Grahpics之Blit
    (七)时间动画_Time
  • 原文地址:https://www.cnblogs.com/walkinginthesun/p/9543001.html
Copyright © 2020-2023  润新知