webserver / apache webdav / apache httpd

s

问题3:nginx 比 apache速度快的原因分析

序号 nginx apache 备注
1

事件驱动架构:Nginx采用事件驱动的架构,能够以非阻塞方式处理多个并发连接,而不需要为每个连接创建新的线程或进程。这使得Nginx在高负载情况下更高效,而Apache使用多进程/多线程模型,这可能导致更多的资源消耗和上下文切换。

异步非阻塞:Nginx使用异步非阻塞方式处理客户端请求。这意味着它可以同时处理多个请求而无需等待每个请求的完成,从而提高了并发性和性能。

epoll模型:在Linux上,Nginx通常使用epoll作为事件模型。epoll是一种高效的I/O多路复用技术,允许Nginx同时处理大量连接而无需创建大量线程或进程。

prefork模型:在prefork模型中,每个客户端请求都会创建一个独立的子进程来处理。这导致了较高的内存开销,因为每个子进程都包含一个完整的Apache实例。这是传统的多进程模型。

worker模型:在worker模型中,Apache创建一组子进程,每个子进程可以处理多个连接,但每个连接仍然使用一个单独的线程。这有助于减少内存开销,但仍然使用线程。

event模型:在event模型中,Apache结合了多进程和异步事件处理。它使用多进程来处理连接,但仅使用一个线程来监听和处理事件。这降低了内存消耗,但仍然使用线程来处理事件。

event > worker > perfork
 

单进程/多进程模型:通常情况下,Nginx使用单进程或多进程的方式工作,每个进程可以处理多个连接。这降低了内存消耗,提高了性能。

   
2 内存管理:Nginx使用内存池来管理内存分配,减少了内存碎片和频繁的内存分配/释放操作,提高了性能。相比之下,Apache使用传统的内存管理方式,可能会导致更多的内存碎片问题。    
3 静态文件处理:Nginx在处理静态文件时非常高效,能够通过简单的文件读取和发送来提供静态内容,而无需执行复杂的处理逻辑。Apache的每个请求都需要在处理时执行更多的模块和逻辑,这会导致更多的CPU和内存消耗。    
4 配置灵活性:Nginx的配置文件语法简洁,允许快速和灵活的配置,这使得它在高负载情况下更容易调整和优化。相比之下,Apache的配置文件可能会更复杂,需要更多的配置和调整来达到类似的性能水平。    
5 TCP协议本身并不是导致Nginx相对更快的原因,但Nginx的性能优化、事件驱动架构以及其他因素使它在处理大量连接和请求时更高效,这有助于提高Web服务器性能。    
6      

-

 

操作系统 select支持 poll支持 epoll支持

kqueue支持 

Linux
Windows
macOS
FreeBSD
NetBSD
OpenBSD
Solaris
AIX
HP-UX

-

I/O多路复用机制特点 select poll epoll
复杂度 中等
最大文件描述符数 通常受限于系统限制 通常受限于系统限制 没有明显限制
高并发连接处理 不适合高并发连接数 不适合高并发连接数 适合高并发连接数
激活文件描述符数量 O(n) O(n) O(1)
阻塞操作的开销
批量处理文件描述符 需要遍历整个文件描述符集合 需要遍历整个文件描述符集合 仅处理活跃的文件描述符
内存开销 中等
效率 中等
支持Edge Trigger
支持Level Trigger
支持EPOLLET模式
适用情况 小规模连接 中等规模连接 大规模或高并发连接

-

问题3:替换http默认80端口为82

解决3:

#!/bin/bash
setenforce 0
yum install -y httpd &> /dev/null
echo "sed-test" > /var/www/html/index.html
# 方法1:搜索Listten 80打头的行并替换0为2
sed -i '/^Listten 80/s/0/2' /etc/httpd/conf/httpd.conf  
# 写法2:直接全局替换
# sed -i 's/Listen 80/Listen 82/g' /etc/httpd/conf/httpd.conf ; grep 82 /etc/httpd/conf/httpd.conf
systemctl restart httpd
systemctl enable httpd

问题2:jdk1.6下使用sardine和jackrabbit-webdav的问题

解决2:https://www.cnblogs.com/claireyuancy/p/7101667.html

好了就这样,假设遇到如上问题,怎么搞都不正确,就换下jdk版本号吧~~

问题1:wamp5 apache虚拟主机配置问题httpd.conf错误authz_core:error

解决1:https://www.cxybj.com/?p=51

将虚拟主机配置中的
Order allow, deny
Allow from all
改成
Require all granted

完整如下
<VirtualHost *:80>
ServerAdmin admin@cxybj.com
DocumentRoot D:\PHP\cxybj.com
ServerName hqstu.com
<Directory "D:/PHP/cxybj.com">
Options FollowSymlinks
AllowOverride none
Require all granted
</Directory>
</VirtualHost>

 

Linux(CentOS7) 搭建webdav服务

https://blog.csdn.net/wsp_1138886114/article/details/115009166

1、安装apache webdav

文件:/opt/apache_webdav_install.sh

内容:

#!/usr/bin/bash
echo -e '\033[32m======= 安装webdav服务 使用超级权限执行!==========\033[0m'
sleep 3

echo "1. 执行安装apache web服务"
sudo yum -y install httpd

echo "2. 创建并配置 webdav.conf"
sudo mkdir /var/www/html/webdav
sudo chown -R apache:apache /var/www/html/webdav
sudo chmod -R 755 /var/www/html/webdav
touch /etc/httpd/conf.d/webdav.conf
cat >> /etc/httpd/conf.d/webdav.conf <<"EOF"
DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/webdav/
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined
        Alias /webdav /var/www/html/webdav
        <Directory /var/www/html/webdav>
            DAV On
            Options +Indexes
            IndexOptions FancyIndexing
            AddDefaultCharset UTF-8
            AuthType Basic
            AuthName "webdav"
            AuthUserFile /etc/httpd/.htpasswd
            Require valid-user
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>
EOF

echo "3. 启动测试 webdav"
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
sudo httpd -v
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-all | grep services
echo "done!"

2、创建webdav登录用户

sudo htpasswd -c htpasswd -c /etc/httpd/conf/passwd_basic 'newsit'  # 其中newsit为用户名

[root@sctssitapp06 ~]# ll /etc/httpd/conf/passwd_basic

-rw-r--r-- 1 root root 45 Jul 12 11:21 /etc/httpd/conf/passwd_basic

3、基本启停

sudo systemctl start httpd      # 启动服务
sudo systemctl status httpd     # 查看服务启动信息
sudo systemctl stop httpd       # 关闭服务
sudo systemctl restart httpd.service   # 重启服务
sudo systemctl reload httpd     # 修改配置后重新加载服务
sudo systemctl disable httpd    # 禁用Apache服务
sudo systemctl enable httpd     # 启用Apache服务
sudo httpd -v                   # 查看版本

4、测试验证,防火墙调整访问 。 // 若是无法联通,需要打开HTTP和HTTPS端口80和443:或者关闭防火墙

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

#================================================================
sudo systemctl stop firewalld         # 临时关闭防火墙
sudo systemctl disable firewalld      # 防止防火墙开启启动

 

 

Centos 7.3.1611 配置 Apache2.4.6 WebDav   / https://blog.51cto.com/xinghan/2289632

[root@sftspstapp906 files]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@sftspstapp906 files]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Apr 12 2017 21:03:28

1、创建文件:

[root@sftspstapp906 files]# vim /etc/httpd/conf.d/httpd-dav.conf 

 1 Listen 8080
 2 DavLockDB /data/webdav/DavLock
 3 <VirtualHost 10.244.213.179:8080>
 4     DocumentRoot "/data/webroot"
 5     <Directory "/data/webroot/">
 6         Options Indexes FollowSymLinks Multiviews
 7         Require all granted
 8         AllowOverride None
 9         AddDefaultCharset UTF-8
10     </Directory>
11     Alias /files /data/webroot/files/
12     <Location /files>
13         DAV On
14         AuthName "WebDAV Server"
15         AuthType Basic
16         AuthUserFile "/etc/httpd/conf/passwd_basic"
17         Require valid-user
# 必须这样加,表示除了get外逗得账户认证
18 <LimitExcept GET> 19 require user newsit 20 </LimitExcept> 21 </Location> 22 </VirtualHost>

2、创建文件夹和DAVLock文件

[root@sftspstapp906 conf]#  mkdir -p /data/webdav/ ; mkdir -p /data/webroot/files

[root@sftspstapp906 conf]#  touch /data/webdav/DAVLock

3、创建index.html

下面webroot目录新建index.html,为了默认展示下欢迎页面。

[root@sftspstapp906 conf]# echo "welcome root dir"  > /data/webroot/index.html

下面webdav目录新建index.html,则无法索引列表目录展示,可以不需要。

[root@sftspstapp906 conf]# echo "welcome webdav dir"  > /data/webroot/files/index.html   

4、配置webdav 用户名密码

[root@sftspstapp906 ~]# htpasswd -c /etc/httpd/conf/passwd_basic newsit

New password: 输入密码

Re-type new password: 输入密码

Adding password for user newsit

5、 重启http

[root@sftspstapp906 conf]# httpd -k restart   

6、访问http

http://xxxx:8080/ ,访问ok

http://xxxx:8080/files ,访问ok

 

https://www.iteye.com/blog/icarusliu-366513

1.Redirect requested but followRedirects is disabled:URL的后面没有加上'/',如在我的程序里面

URL应该是:http://localhost:8080/slide/,但是写成http://localhost:8080/slide就会出现这样的错误.

 

解决httpd: Could not reliably determine the server's fully qualified domain name

https://www.cnblogs.com/52linux/archive/2012/03/24/2415637.html

用记事本打开 httpd.conf

将里面的 #ServerName localhost:80 注释去掉即可。

再执行 httpd

然后可以通过浏览器访问 http://localhost:80 ,如果页面显示 “It works!” ,即表示apache已安装并启动成功。

++++++++++++++++++++++++++++++++++++++++++++

using localhost.localdomain for ServerName 说不能确认服务器完全确认域名 localhost.localdoman 这个问题怎么解决

最佳答案:

vi /etc/httpd/conf/httpd.conf 加入一句 ServerName localhost:80

 

1、安装软件

[root@sctssitapp140 conf]#  yum install httpd.x86_64

2、检查版本

[root@sctssitapp140 conf]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Apr 12 2017 21:03:28
[root@sctssitapp140 conf]# httpd -V
Server version: Apache/2.4.6 (CentOS)
Server built:   Apr 12 2017 21:03:28
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

3、部署配置 apache webdav

创建文件夹和文件

[root@sctssitapp140 conf]# mkdir -p /opt/webdav/DAV ; mkdir -p /opt/webroot

[root@sctssitapp140 conf]# touch /opt/webdav/DAV/DAVLock ; touch /opt/webroot/index.html

[root@sctssitapp140 conf]# echo "index" > /opt/webroot/index.html

赋予文件夹权限:

[root@sctssitapp140 conf]#  chmod 777 -R /opt/webdav/DAV/

4、创建用户账户密码

[root@sctssitapp140 conf]#  htpasswd -c /etc/httpd/conf/passwd_basic dav_admin

5、配置httpd.conf 

文件:/etc/httpd/conf/httpd.conf

内容如下

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName localhost:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/var/www/html"
DocumentRoot "/opt/webroot"

#
# Relax access to content within /var/www.
#
# <Directory "/var/www">
<Directory "/opt/webroot">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
# <Directory "/var/www/html">
<Directory "/opt/webroot">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    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>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts. 
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the 
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

# tangxje added "DAVLockDB" 20151217
DAVLockDB "/opt/webdav/DAV/DAVLock"

# tangxje config WebDAV ################# start ##########
<Directory /opt/webdav/files_sit2/>
  Options Indexes FollowSymLinks MultiViews
  #Options Indexes MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
</Directory>

Alias /files_sit2 /opt/webdav/files_sit2/
<Location /files_sit2>
 DAV On
 AuthName "WebDAV"
 AuthType Basic
 AuthUserFile /etc/httpd/conf/passwd_basic
 #Require valid-user    #此处已注释,暂时不用输入用户名密码即可打开浏览器
    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <LimitExcept GET>
        require user dav_admin
    </LimitExcept>
</Location>

 6、重启apache http 服务

[root@sctssitapp140 httpd]# httpd -k restart

 7、AnyClient 6.0软件验证webdav 

打开软件配置方法如下:

HOST配置      http://10.243.93.34/files_sit2

username配置

password配置

protcool配置:webdav

 

s

问题1:Failed to resolve server name for 10.24.41.161 (check DNS)   /   RedHat 6.3 64位系统 / apache http 2.2.22-7

[davadmin@sctsdemo webroot]$ /opt/apache/bin/httpd -k start

1 [Wed Aug 23 21:31:06 2017] [error] (EAI 2)Name or service not known: Failed to resolve server name for 10.24.41.161 (check DNS) -- or specify an explicit ServerName

解决1:

新增配置 /etc/hosts 自解析DNS的ip地址即可。

 

问题2:使用root赋权davadmin用户使用apache整个目录,准备启动apache 2.2.22-7,报错如下:

[davadmin@sctsdemo logs]# chown -R davadmin.davadmin /opt/apache
[davadmin@sctsdemo logs]# chmod 755 -R /opt/apache
[davadmin@sctsdemo logs]# su - davadmin
[davadmin@sctsdemo logs]$ id
uid=504(davadmin) gid=504(davadmin) groups=504(davadmin) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[davadmin@sctsdemo logs]$ /opt/apache/bin/httpd -k start
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

 

解决2:

Linux普通用户使用sudo权限启停apache服务

http://www.cnblogs.com/abclife/p/5028885.html

sudo的工作过程如下:
1,用户执行sudo时,系统会主动寻找/etc/sudoers文件,判断该用户是否有执行sudo的权限
2,确认用户具有可执行sudo的权限后,让用户输入密码确认
3,若密码输入成功,则开始执行sudo后续的命令
4,root执行sudo时不需要输入密码(对应配置文件中"root ALL=(ALL) ALL"这样一条规则)
5,若欲切换的身份与执行者的身份相同,也不需要输入密码

使用VIM编辑/etc/sudoers,或者直接使用visudo编辑sudo规则
添加一条规则:
user01 ALL=(root) /etc/init.d/httpd

如果不想每次都要输入密码,可以进行以下设置:
user01 ALL=(root)NOPASSWD: /etc/init.d/httpd

修改范例二

# tangxje start 20170824
davadmin ALL=(root)NOPASSWD:  /opt/apache/bin/httpd
# tangxje end 20170824

 

Redhat 6.3 64位关闭SELinux和防火墙方法

http://blog.csdn.net/superbfly/article/details/49125125

Redhat使用了SELinux来增强安全,关闭的办法为:
1. 永久有效
修改 /etc/selinux/config 文件中的 SELINUX="" 为 disabled ,然后重启。
2. 即时生效
setenforce 0

关闭防火墙的方法为:
1. 永久性生效
开启:chkconfig iptables on 
关闭:chkconfig iptables off
2. 即时生效,重启后失效
开启:service iptables start
关闭:service iptables stop

需要说明的是对于 Linux 下的其它服务都可以用以上命令执行开启和关闭操作

补充:
a. 防火墙还需要关闭ipv6的防火墙:
chkconfig ip6tables off
并且可以通过如下命令查看状态:
chkconfig --list iptables
b. selinux状态可以通过以下命令查看:
sestatus

Linux下不重启永久修改hostname /  适用于RedHat 6.3 / CentOS 6.3系统,不适用于RedHat 7.3 / CentOS 7.3系统
http://blog.csdn.net/sz_bdqn/article/details/46554717
Linux下不重启永久修改hostname
1、如果只是修改hostname可以通过如下命令
hostname newHostname 
注意:这种修改方式只有当前有效,等服务器重启后hostname就会失效,回到原来的hostname。
2、如果需要永久修改hostname可通过如下命令
vi /etc/sysconfig/network 
修改其中的HOSTNAME项,不过此种方法需要重启后生效。
3、于是在不重启又能永久修改hostname的方式是结合上述两种,这样便能做到不用重启当前也生效,重启后也生效。

 

使用 Apache Jackrabbit 实现 WebDAV 客户端

https://www.ibm.com/developerworks/cn/java/j-lo-jackrabbit/

 1 import java.io.FileInputStream;
 2 import java.io.IOException;
 3 
 4 import org.apache.commons.httpclient.Credentials;
 5 import org.apache.commons.httpclient.HttpClient;
 6 import org.apache.commons.httpclient.StatusLine;
 7 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 8 import org.apache.commons.httpclient.auth.AuthScope;
 9 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
10 import org.apache.commons.httpclient.methods.RequestEntity;
11 import org.apache.jackrabbit.webdav.DavConstants;
12 import org.apache.jackrabbit.webdav.DavException;
13 import org.apache.jackrabbit.webdav.MultiStatus;
14 import org.apache.jackrabbit.webdav.MultiStatusResponse;
15 import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
16 import org.apache.jackrabbit.webdav.client.methods.DavMethod;
17 import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
18 import org.apache.jackrabbit.webdav.client.methods.LockMethod;
19 import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
20 import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
21 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
22 import org.apache.jackrabbit.webdav.client.methods.PutMethod;
23 import org.apache.jackrabbit.webdav.client.methods.UnLockMethod;
24 import org.apache.jackrabbit.webdav.lock.Scope;
25 import org.apache.jackrabbit.webdav.lock.Type;
26 
27 public class DavClient {
28 
29     public static void main(String [] args) throws IOException, DavException {
30 
31         HttpClient client = new HttpClient();
32         Credentials creds = new UsernamePasswordCredentials("admin", "passw0rd");
33         client.getState().setCredentials(AuthScope.ANY, creds);
34 
35         // MKCOL method - 新建目录
36         DavMethod mkCol = new MkColMethod("http://127.0.0.1/uploads/test");
37         client.executeMethod(mkCol);
38         
39         int statusCode = mkCol.getStatusCode();
40         String statusText = mkCol.getStatusText();
41         StatusLine statusLine = mkCol.getStatusLine();
42         System.out.println("mkcol test folder:" + statusCode + " " + statusText);
43         System.out.println(statusLine.toString());
44         
45         // Put Method - 上传本地文件
46         PutMethod put = new PutMethod("http://127.0.0.1/uploads/test/lena.jpg");
47         RequestEntity requestEntity = new InputStreamRequestEntity(new FileInputStream("lena.jpg"));
48         put.setRequestEntity(requestEntity);
49         client.executeMethod(put);
50         System.out.println("put image file:" + put.getStatusCode() + " " + put.getStatusText());
51 
52         // CopyMethod(String uri, String destinationUri, boolean overwrite) - 远程拷贝本文
53         DavMethod copy = new CopyMethod("http://127.0.0.1/uploads/test/lena.jpg",
54                 "http://127.0.0.1/uploads/test/lena2.jpg", true);
55         client.executeMethod(copy);
56         System.out.println("copy image file:" + copy.getStatusCode() + " " + copy.getStatusText());
57 
58         //MoveMethod(String uri, String destinationUri, boolean overwrite) - 远程重命名文件
59         DavMethod move = new MoveMethod("http://127.0.0.1/uploads/test/lena.jpg",
60                 "http://127.0.0.1/uploads/test/lena3.jpg", true);
61         client.executeMethod(move);
62         System.out.println("move image file:" + move.getStatusCode() + " " + move.getStatusText());
63 
64         //LockMethod(String uri, Scope lockScope, Type lockType, String owner, long timeout, boolean isDeep) - 文件加锁操作
65         LockMethod lock = new LockMethod("http://127.0.0.1/uploads/test/lena.jpg", Scope.SHARED, Type.WRITE, "admin",
66                 10000l, false);
67         client.executeMethod(lock);
68         String lockToken = lock.getLockToken();
69         System.out.println("lock image file:" + lock.getStatusCode() + " " + lock.getStatusText());
70 
71         //UnLockMethod(String uri, String lockToken) - 文件解锁操作
72         DavMethod unlock = new UnLockMethod("http://127.0.0.1/uploads/test/lena.jpg", lockToken);
73         client.executeMethod(unlock);
74         System.out.println("unlock image file:" + unlock.getStatusCode() + " " + unlock.getStatusText());
75 
76         // Find Method - 查找文件操作
77         DavMethod find = new PropFindMethod("http://127.0.0.1/uploads/test/", DavConstants.PROPFIND_ALL_PROP,
78                 DavConstants.DEPTH_1);
79         client.executeMethod(find);
80         MultiStatus multiStatus = find.getResponseBodyAsMultiStatus();
81         MultiStatusResponse [] responses = multiStatus.getResponses();
82         System.out.println("Folders and files:");
83         for (int i = 0; i < responses.length; i++) {
84             System.out.println(responses[i].getHref());
85         }
86 
87         // Delete Method - 删除远程文件
88         DavMethod delete = new DeleteMethod("http://127.0.0.1/uploads/test/");
89         client.executeMethod(delete);
90         System.out.println("delete test folder:" + delete.getStatusCode() + " " + delete.getStatusText());
91 
92     }
93     
94 }

 

 

[davadmin@sctspreapp03 testwa-cst]$ more /data/find.txt 
移走文件服务器里文件夹大于300天的,减少磁盘空间
/opt/webdav/files/snapshot
/opt/webdav/files/testwa-cst
# find ./ -maxdepth 1 -mtime +300 -type d | xargs -I {} mv {} /data/snapshot300day/

 

 

 

end

posted @ 2019-12-09 11:57  siemens800  阅读(765)  评论(0编辑  收藏  举报