zoukankan      html  css  js  c++  java
  • httpd服务配置 centos httpd + ubuntu conf位置

    自己配置过程:

    centos

    安装httpd:

    [root@bian91 ~]# yum install -y apache
    Loaded plugins: fastestmirror, security
    Determining fastest mirrors
    * base: mirror.bit.edu.cn
    * extras: mirrors.btte.net
    * updates: ftp.sjtu.edu.cn
    base | 3.7 kB 00:00
    base/primary_db | 4.6 MB 00:01
    extras | 3.4 kB 00:00
    extras/primary_db | 32 kB 00:00
    updates | 3.4 kB 00:00
    updates/primary_db | 1.9 MB 00:02
    Setting up Install Process
    No package apache available.
    Error: Nothing to do
    [root@bian91 ~]# yum install -y httpd
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base: mirror.bit.edu.cn
    * extras: mirrors.btte.net
    * updates: ftp.sjtu.edu.cn
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.x86_64 0:2.2.15-47.el6.centos will be installed
    --> Processing Dependency: httpd-tools = 2.2.15-47.el6.centos for package: httpd-2.2.15-47.el6.centos.x86_64
    --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-47.el6.centos.x86_64
    --> Running transaction check
    ---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
    ---> Package httpd-tools.x86_64 0:2.2.15-47.el6.centos will be installed
    --> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: httpd-tools-2.2.15-47.el6.centos.x86_64
    --> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: httpd-tools-2.2.15-47.el6.centos.x86_64
    --> Running transaction check
    ---> Package openssl.x86_64 0:1.0.0-27.el6 will be updated
    --> Processing Dependency: openssl = 1.0.0-27.el6 for package: openssl-devel-1.0.0-27.el6.x86_64
    ---> Package openssl.x86_64 0:1.0.1e-42.el6 will be an update
    --> Running transaction check
    ---> Package openssl-devel.x86_64 0:1.0.0-27.el6 will be updated
    ---> Package openssl-devel.x86_64 0:1.0.1e-42.el6 will be an update
    --> Finished Dependency Resolution

    Dependencies Resolved

    ===============================================================================================================================================================================================
    Package Arch Version Repository Size
    ===============================================================================================================================================================================================
    Installing:
    httpd x86_64 2.2.15-47.el6.centos updates 830 k
    Installing for dependencies:
    apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
    httpd-tools x86_64 2.2.15-47.el6.centos updates 77 k
    Updating for dependencies:
    openssl x86_64 1.0.1e-42.el6 base 1.5 M
    openssl-devel x86_64 1.0.1e-42.el6 base 1.2 M

    Transaction Summary
    ===============================================================================================================================================================================================
    Install 3 Package(s)
    Upgrade 2 Package(s)

    Total download size: 3.6 M
    Downloading Packages:
    (1/5): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm | 15 kB 00:00
    (2/5): httpd-2.2.15-47.el6.centos.x86_64.rpm | 830 kB 00:00
    (3/5): httpd-tools-2.2.15-47.el6.centos.x86_64.rpm | 77 kB 00:00
    (4/5): openssl-1.0.1e-42.el6.x86_64.rpm | 1.5 MB 00:01
    (5/5): openssl-devel-1.0.1e-42.el6.x86_64.rpm | 1.2 MB 00:00
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total 1.4 MB/s | 3.6 MB 00:02
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Updating : openssl-1.0.1e-42.el6.x86_64 1/7
    Installing : httpd-tools-2.2.15-47.el6.centos.x86_64 2/7
    Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/7
    Installing : httpd-2.2.15-47.el6.centos.x86_64 4/7
    Updating : openssl-devel-1.0.1e-42.el6.x86_64 5/7
    Cleanup : openssl-devel-1.0.0-27.el6.x86_64 6/7
    Cleanup : openssl-1.0.0-27.el6.x86_64 7/7
    Verifying : openssl-devel-1.0.1e-42.el6.x86_64 1/7
    Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 2/7
    Verifying : httpd-tools-2.2.15-47.el6.centos.x86_64 3/7
    Verifying : openssl-1.0.1e-42.el6.x86_64 4/7
    Verifying : httpd-2.2.15-47.el6.centos.x86_64 5/7
    Verifying : openssl-1.0.0-27.el6.x86_64 6/7
    Verifying : openssl-devel-1.0.0-27.el6.x86_64 7/7

    Installed:
    httpd.x86_64 0:2.2.15-47.el6.centos

    Dependency Installed:
    apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-47.el6.centos

    Dependency Updated:
    openssl.x86_64 0:1.0.1e-42.el6 openssl-devel.x86_64 0:1.0.1e-42.el6

    Complete!

    查看配置文件:

    [root@bian91 ~]# rpm -qc httpd
    /etc/httpd/conf.d/welcome.conf
    /etc/httpd/conf/httpd.conf
    /etc/httpd/conf/magic
    /etc/logrotate.d/httpd
    /etc/sysconfig/htcacheclean
    /etc/sysconfig/httpd
    /var/www/error/HTTP_BAD_GATEWAY.html.var
    /var/www/error/HTTP_BAD_REQUEST.html.var
    /var/www/error/HTTP_FORBIDDEN.html.var
    /var/www/error/HTTP_GONE.html.var
    /var/www/error/HTTP_INTERNAL_SERVER_ERROR.html.var
    /var/www/error/HTTP_LENGTH_REQUIRED.html.var
    /var/www/error/HTTP_METHOD_NOT_ALLOWED.html.var
    /var/www/error/HTTP_NOT_FOUND.html.var
    /var/www/error/HTTP_NOT_IMPLEMENTED.html.var
    /var/www/error/HTTP_PRECONDITION_FAILED.html.var
    /var/www/error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
    /var/www/error/HTTP_REQUEST_TIME_OUT.html.var
    /var/www/error/HTTP_REQUEST_URI_TOO_LARGE.html.var
    /var/www/error/HTTP_SERVICE_UNAVAILABLE.html.var
    /var/www/error/HTTP_UNAUTHORIZED.html.var
    /var/www/error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
    /var/www/error/HTTP_VARIANT_ALSO_VARIES.html.var
    /var/www/error/contact.html.var
    /var/www/error/include/bottom.html
    /var/www/error/include/spacer.html
    /var/www/error/include/top.html

    修改配置文件:

    vi /etc/httpd/conf/httpd.conf

    在最后添加

    #<VirtualHost *:80>
    # ServerAdmin webmaster@dummy-host.example.com
    # DocumentRoot /www/docs/dummy-host.example.com
    # ServerName dummy-host.example.com
    # ErrorLog logs/dummy-host.example.com-error_log
    # CustomLog logs/dummy-host.example.com-access_log common
    Alias /public "/public"
     <Directory "/public">
     #开启目录列表索引搜索模式
     Options Indexes
     Order allow,deny
     IndexOptions NameWidth=25 Charset=UTF-8
     Allow from all
     </Directory>
    #</VirtualHost>

    查看目录:

    目录为/var/www/html

    [root@bian91 ~]# grep "Doc" /etc/httpd/conf/httpd.conf
    # DocumentRoot: The directory out of which you will serve your
    DocumentRoot "/var/www/html"

    创建目录:

     mkdir /public

    ln -s /public/ /var/www/html/public

    启动服务:

     service httpd start

    配置开机启动:

    chkconfig httpd on

    可以通过网页打开192.168.x.xxx/public查看目录 

    以下为网上配置过程:

    linux版本 RHEL7.0

    IP地址172.7.16.111

    apache服务的包名为httpd,检查包

    clip_image001

    使用yum源安装包,
    配置yum方法可以参考我的博客 《linux yum源配置方法》http://blog.itpub.net/27771627/viewspace-1223153/

    [root@rh ~]# yum -y install httpd

    Loaded plugins: langpacks, product-id, subscription-manager

    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

    testyum | 4.1 kB 00:00:00

    Resolving Dependencies

    --> Running transaction check

    ---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed

    --> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64

    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64

    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64

    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64

    --> Running transaction check

    ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed

    ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed

    ---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed

    ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed

    --> Finished Dependency Resolution

    Dependencies Resolved

    ==================================================================================================================

    Package Arch Version Repository Size

    ==================================================================================================================

    Installing:

    httpd x86_64 2.4.6-17.el7 testyum 1.2 M

    Installing for dependencies:

    apr x86_64 1.4.8-3.el7 testyum 103 k

    apr-util x86_64 1.5.2-6.el7 testyum 92 k

    httpd-tools x86_64 2.4.6-17.el7 testyum 77 k

    mailcap noarch 2.1.41-2.el7 testyum 31 k

    Transaction Summary

    ==================================================================================================================

    Install 1 Package (+4 Dependent packages)

    Total download size: 1.5 M

    Installed size: 4.3 M

    Downloading packages:

    ------------------------------------------------------------------------------------------------------------------

    Total 4.3 MB/s | 1.5 MB 00:00:00

    Running transaction check

    Running transaction test

    Transaction test succeeded

    Running transaction

    Installing : apr-1.4.8-3.el7.x86_64 1/5

    Installing : apr-util-1.5.2-6.el7.x86_64 2/5

    Installing : httpd-tools-2.4.6-17.el7.x86_64 3/5

    Installing : mailcap-2.1.41-2.el7.noarch 4/5

    Installing : httpd-2.4.6-17.el7.x86_64 5/5

    Verifying : mailcap-2.1.41-2.el7.noarch 1/5

    Verifying : httpd-tools-2.4.6-17.el7.x86_64 2/5

    Verifying : apr-1.4.8-3.el7.x86_64 3/5

    Verifying : apr-util-1.5.2-6.el7.x86_64 4/5

    Verifying : httpd-2.4.6-17.el7.x86_64 5/5

    Installed:

    httpd.x86_64 0:2.4.6-17.el7

    Dependency Installed:

    apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-17.el7

    mailcap.noarch 0:2.1.41-2.el7

    Complete!

    查看配置文件

    clip_image002

    需要配置的文件为/etc/httpd/conf/httpd.conf

    查看配置文件,过滤以下字段,默认主页路径为以下

    clip_image003

    默认主页名为index.html

    clip_image004

    进入主页路径,创建一个测试网页

    clip_image005

    重启httpd服务

    clip_image006

    设置开机自启动

    clip_image007

    设置防火墙,使http服务可以通过防火墙

    clip_image008

    重启防火墙

    clip_image009

    本机测试http服务配置成功

    clip_image010

    windows客户端浏览器测试成功

    clip_image011

    至此apache服务已经配置成功,接下来继续配置目录共享

    创建共享目录,将共享文件放里面

    clip_image012

    编辑配置文件/etc/httpd/conf.d/autoindex.conf

    加入如下配置内容

    Alias /share "/LiuZhenSHARE"

    <directory "="" liuzhenshare"="">

    Options Indexes MultiViews FollowSymlinks

    AllowOverride None

    Require all granted

    clip_image013

    修改完配置文件,重启服务

    clip_image014

    安装elink包在server本机测试

    [root@rh LiuZhenSHARE]# yum -y install elinks

    Loaded plugins: langpacks, product-id, subscription-manager

    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

    Resolving Dependencies

    --> Running transaction check

    ---> Package elinks.x86_64 0:0.12-0.36.pre6.el7 will be installed

    --> Processing Dependency: libnss_compat_ossl.so.0()(64bit) for package: elinks-0.12-0.36.pre6.el7.x86_64

    --> Running transaction check

    ---> Package nss_compat_ossl.x86_64 0:0.9.6-8.el7 will be installed

    --> Finished Dependency Resolution

    Dependencies Resolved

    ==================================================================================================================

    Package Arch Version Repository Size

    ==================================================================================================================

    Installing:

    elinks x86_64 0.12-0.36.pre6.el7 testyum 882 k

    Installing for dependencies:

    nss_compat_ossl x86_64 0.9.6-8.el7 testyum 37 k

    Transaction Summary

    ==================================================================================================================

    Install 1 Package (+1 Dependent package)

    Total download size: 919 k

    Installed size: 2.7 M

    Downloading packages:

    ------------------------------------------------------------------------------------------------------------------

    Total 2.5 MB/s | 919 kB 00:00:00

    Running transaction check

    Running transaction test

    Transaction test succeeded

    Running transaction

    Installing : nss_compat_ossl-0.9.6-8.el7.x86_64 1/2

    Installing : elinks-0.12-0.36.pre6.el7.x86_64 2/2

    Verifying : elinks-0.12-0.36.pre6.el7.x86_64 1/2

    Verifying : nss_compat_ossl-0.9.6-8.el7.x86_64 2/2

    Installed:

    elinks.x86_64 0:0.12-0.36.pre6.el7

    Dependency Installed:

    nss_compat_ossl.x86_64 0:0.9.6-8.el7

    Complete!

    执行以下命令server端本机测试

    clip_image015

    执行后出现share的文件

    clip_image016

    使用windows浏览器测试,

    clip_image017

    测试成功,配置完成

    关于ubuntu配置文件,严格地说Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的 apache软件包)的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行: 

    引用 

    # Include module configuration: 
    Include /etc/apache2/mods-enabled/*.load 
    Include /etc/apache2/mods-enabled/*.conf 

    # Include all the user configurations: 
    Include /etc/apache2/httpd.conf 

    # Include ports listing 
    Include /etc/apache2/ports.conf 
    …… 

    # Include generic snippets of statements 
    Include /etc/apache2/conf.d/ 

    # Include the virtual host configurations: 
    Include /etc/apache2/sites-enabled/ 
    结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯。 

    安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。怎么知道 的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。经过搜索,发现在 /etc /apache2/sites-enabled/000-default中,里面有这样的内容: 

    引用 

    NameVirtualHost * 
    <VirtualHost *> 
    ServerAdmin webmaster @localhost 

    DocumentRoot /var/www/

    主要就是配置 /etc /apache2/sites-enabled/000-default

    里边/var/www/ 改为/var/www/html

  • 相关阅读:
    虚拟机NetworkAdapter三种方式的区别
    skia
    android gralloc是什么意思
    两个工作机会
    Ubuntu apt-get更新源替换及加速方法
    Vuforia和Metaio相继被收购,开发者们还有这些AR引擎可以选
    OpenCV 为啥勾搭上 OpenGL
    感受2万元的黑科技 微软MR头显HoloLens测评
    影创 我们的职位
    java基础-servlet-2:生命周期
  • 原文地址:https://www.cnblogs.com/banwhui/p/4667729.html
Copyright © 2011-2022 走看看