×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

我今天把apache重装到/usr/local/myapp/apache_new中,可是执行/usr/local/myapp/apache_new/bin/apachectl start后apache却调用了原先的配置,cgi程序也调用愿先的程序. WHY?

本文发表在 rolia.net 枫下论坛原先的apache是打包在一个应用软件myapp中的,安装后其httpd.conf放在/usr/local/myapp/apache/conf下,内容见后,其使用8000端口.我重新编译安装的apache使用缺省配置80端口.
现在我执行/usr/local/myapp/apache_new/bin/apachectl start后apache打开的竟然是8000端口,奇怪.为什么不启动这个全新的apache环境呢?

-------------------------
老的/usr/local/myapp/apache/conf/httpd.conf
ServerRoot "/usr/local/myapp/apache"

PidFile logs/httpd.pid

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule prefork.c>
StartServers 1
MinSpareServers 2
MaxSpareServers 2
MaxClients 150
MaxRequestsPerChild 200
</IfModule>

<IfModule worker.c>
StartServers 1
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 200
</IfModule>

<IfModule perchild.c>
NumServers 1
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 200
</IfModule>

ServerAdmin support@myapp.com

ServerName 127.0.0.1

UseCanonicalName Off

DocumentRoot "/usr/local/myapp/apache/htdocs"

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/usr/local/myapp/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

DirectoryIndex /cgi-bin/myapp.exe

AccessFileName .htaccess

<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

TypesConfig conf/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off

ErrorLog /dev/null
LogLevel warn

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog /dev/null common

ServerSignature On

ScriptAlias /cgi-bin/ "/usr/local/myapp/apache/cgi-bin/"

<Directory "/usr/local/myapp/apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully

<IfDefine SSL>

Listen 443

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl

SSLPassPhraseDialog builtin

SSLSessionCache dbm:logs/ssl_scache
SSLSessionCacheTimeout 300

SSLMutex file:logs/ssl_mutex

SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

<VirtualHost _default_:443>

DocumentRoot "/usr/local/myapp/apache/htdocs"
ServerName 127.0.0.1:443
ErrorLog logs/error_log
TransferLog /dev/null

SSLEngine on

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile /usr/local/myapp/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/myapp/apache/conf/ssl.key/server.key






<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/usr/local/myapp/apache/cgi-bin">
SSLOptions +StdEnvVars
</Directory>

SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0

CustomLog /dev/null_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

</IfDefine>

Listen 8000

User mike
Group mike
-------------------------更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / 请教:Redhat9上有个CGI程序总返回500 Internal Server Error,但在Solaris上同样的程序就不出错.apache在运行,却看不到日志
    查看httpd.conf发现配置正确,如下:
    ServerRoot "/usr/local/myapp/apache"
    ..
    ErrorLog logs/error_log
    ..
    Listen 8000
    User mike
    Group mike
    在/usr/local/myapp/apache/logs/没有日志文件error_log,整个文件系统中也找不到此文件.改过目录及文件属主为mike,照样出错,仍然没有日志文件输出.

    那位能解答一下?
    any suggestion will be appreciated!!
    • ErrorLog用绝对路径试试
      • 试过,也不成:(
        • up
    • 1.试试改成 ErrorLog /usr/local/myapp/apache/logs/error_log 2.ps -elf | grep httpd 看看第一个httpd 是什么用户起的。一般是root 吧。 3.看看 httpd.conf有没有VirtualHost定义? 有的话看看那里的errorlog
      • 另外ps -elf | grep httpd 看看是不是你的httpd. 经常机器里有几套httpd,不一定那个在运行。
        • 1.绝对路经试过,不成;2.第一个httpd是root用户,其他的是mike,正常;3.VirtualHost日志也是error_log,而整个系统中都搜索不到此文件..另外,只有一套httpd.多谢!
          • 既然是在/usr/local/myapp/apache,那是你自己装的喽?不行就重装把。可以updatedb; locate error_log; locate httpd 查文件。
          • 要不把你的httpd.conf贴出来看看
            • 我今天把apache重装到/usr/local/myapp/apache_new中,可是执行/usr/local/myapp/apache_new/bin/apachectl start后apache却调用了原先的配置,cgi程序也调用愿先的程序. WHY?
              本文发表在 rolia.net 枫下论坛原先的apache是打包在一个应用软件myapp中的,安装后其httpd.conf放在/usr/local/myapp/apache/conf下,内容见后,其使用8000端口.我重新编译安装的apache使用缺省配置80端口.
              现在我执行/usr/local/myapp/apache_new/bin/apachectl start后apache打开的竟然是8000端口,奇怪.为什么不启动这个全新的apache环境呢?

              -------------------------
              老的/usr/local/myapp/apache/conf/httpd.conf
              ServerRoot "/usr/local/myapp/apache"

              PidFile logs/httpd.pid

              Timeout 300

              KeepAlive On

              MaxKeepAliveRequests 100

              KeepAliveTimeout 15

              <IfModule prefork.c>
              StartServers 1
              MinSpareServers 2
              MaxSpareServers 2
              MaxClients 150
              MaxRequestsPerChild 200
              </IfModule>

              <IfModule worker.c>
              StartServers 1
              MaxClients 150
              MinSpareThreads 25
              MaxSpareThreads 75
              ThreadsPerChild 25
              MaxRequestsPerChild 200
              </IfModule>

              <IfModule perchild.c>
              NumServers 1
              StartThreads 5
              MinSpareThreads 5
              MaxSpareThreads 10
              MaxThreadsPerChild 20
              MaxRequestsPerChild 200
              </IfModule>

              ServerAdmin support@myapp.com

              ServerName 127.0.0.1

              UseCanonicalName Off

              DocumentRoot "/usr/local/myapp/apache/htdocs"

              <Directory />
              Options FollowSymLinks
              AllowOverride None
              </Directory>

              <Directory "/usr/local/myapp/apache/htdocs">
              Options Indexes FollowSymLinks
              AllowOverride None
              Order allow,deny
              Allow from all
              </Directory>

              DirectoryIndex /cgi-bin/myapp.exe

              AccessFileName .htaccess

              <Files ~ "^\.ht">
              Order allow,deny
              Deny from all
              </Files>

              TypesConfig conf/mime.types

              DefaultType text/plain

              <IfModule mod_mime_magic.c>
              MIMEMagicFile conf/magic
              </IfModule>

              HostnameLookups Off

              ErrorLog /dev/null
              LogLevel warn

              LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
              LogFormat "%h %l %u %t \"%r\" %>s %b" common
              LogFormat "%{Referer}i -> %U" referer
              LogFormat "%{User-agent}i" agent

              CustomLog /dev/null common

              ServerSignature On

              ScriptAlias /cgi-bin/ "/usr/local/myapp/apache/cgi-bin/"

              <Directory "/usr/local/myapp/apache/cgi-bin">
              AllowOverride None
              Options None
              Order allow,deny
              Allow from all
              </Directory>

              BrowserMatch "Mozilla/2" nokeepalive
              BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
              BrowserMatch "RealPlayer 4\.0" force-response-1.0
              BrowserMatch "Java/1\.0" force-response-1.0
              BrowserMatch "JDK/1\.0" force-response-1.0

              BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
              BrowserMatch "^WebDrive" redirect-carefully

              <IfDefine SSL>

              Listen 443

              AddType application/x-x509-ca-cert .crt
              AddType application/x-pkcs7-crl .crl

              SSLPassPhraseDialog builtin

              SSLSessionCache dbm:logs/ssl_scache
              SSLSessionCacheTimeout 300

              SSLMutex file:logs/ssl_mutex

              SSLRandomSeed startup builtin
              SSLRandomSeed connect builtin

              <VirtualHost _default_:443>

              DocumentRoot "/usr/local/myapp/apache/htdocs"
              ServerName 127.0.0.1:443
              ErrorLog logs/error_log
              TransferLog /dev/null

              SSLEngine on

              SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

              SSLCertificateFile /usr/local/myapp/apache/conf/ssl.crt/server.crt
              SSLCertificateKeyFile /usr/local/myapp/apache/conf/ssl.key/server.key






              <Files ~ "\.(cgi|shtml|phtml|php3?)$">
              SSLOptions +StdEnvVars
              </Files>
              <Directory "/usr/local/myapp/apache/cgi-bin">
              SSLOptions +StdEnvVars
              </Directory>

              SetEnvIf User-Agent ".*MSIE.*" \
              nokeepalive ssl-unclean-shutdown \
              downgrade-1.0 force-response-1.0

              CustomLog /dev/null_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

              </VirtualHost>

              </IfDefine>

              Listen 8000

              User mike
              Group mike
              -------------------------更多精彩文章及讨论,请光临枫下论坛 rolia.net
            • 新的httpd.conf (/usr/local/myapp/apache_new/conf/httpd.conf)
              本文发表在 rolia.net 枫下论坛ServerRoot "/usr/local/myapp/apache_new"

              <IfModule !mpm_winnt.c>
              <IfModule !mpm_netware.c>
              </IfModule>
              </IfModule>

              <IfModule !mpm_netware.c>
              <IfModule !perchild.c>
              </IfModule>
              </IfModule>


              <IfModule !mpm_netware.c>
              PidFile logs/httpd.pid
              </IfModule>

              Timeout 300

              KeepAlive On

              MaxKeepAliveRequests 100

              KeepAliveTimeout 15


              <IfModule prefork.c>
              StartServers 5
              MinSpareServers 5
              MaxSpareServers 10
              MaxClients 150
              MaxRequestsPerChild 0
              </IfModule>

              <IfModule worker.c>
              StartServers 2
              MaxClients 150
              MinSpareThreads 25
              MaxSpareThreads 75
              ThreadsPerChild 25
              MaxRequestsPerChild 0
              </IfModule>

              <IfModule perchild.c>
              NumServers 5
              StartThreads 5
              MinSpareThreads 5
              MaxSpareThreads 10
              MaxThreadsPerChild 20
              MaxRequestsPerChild 0
              </IfModule>

              <IfModule mpm_winnt.c>
              ThreadsPerChild 250
              MaxRequestsPerChild 0
              </IfModule>

              <IfModule beos.c>
              StartThreads 10
              MaxClients 50
              MaxRequestsPerThread 10000
              </IfModule>

              <IfModule mpm_netware.c>
              ThreadStackSize 65536
              StartThreads 250
              MinSpareThreads 25
              MaxSpareThreads 250
              MaxThreads 1000
              MaxRequestsPerChild 0
              </IfModule>

              <IfModule mpmt_os2.c>
              StartServers 2
              MinSpareThreads 5
              MaxSpareThreads 10
              MaxRequestsPerChild 0
              </IfModule>


              Listen 80




              <IfModule !mpm_winnt.c>
              <IfModule !mpm_netware.c>
              User nobody
              </IfModule>
              </IfModule>

              ServerAdmin you@your.address


              UseCanonicalName Off

              DocumentRoot "/usr/local/myapp/apache_new/htdocs"

              <Directory />
              Options FollowSymLinks
              AllowOverride None
              </Directory>


              <Directory "/usr/local/myapp/apache_new/htdocs">

              Options Indexes FollowSymLinks

              AllowOverride None

              Order allow,deny
              Allow from all

              </Directory>

              UserDir public_html


              DirectoryIndex index.html index.html.var

              AccessFileName .htaccess

              <Files ~ "^\.ht">
              Order allow,deny
              Deny from all
              </Files>

              TypesConfig conf/mime.types

              DefaultType text/plain

              <IfModule mod_mime_magic.c>
              MIMEMagicFile conf/magic
              </IfModule>

              HostnameLookups Off



              ErrorLog logs/error_log

              LogLevel warn

              LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
              LogFormat "%h %l %u %t \"%r\" %>s %b" common
              LogFormat "%{Referer}i -> %U" referer
              LogFormat "%{User-agent}i" agent


              CustomLog logs/access_log common



              ServerTokens Full

              ServerSignature On

              Alias /icons/ "/usr/local/myapp/apache_new/icons/"

              <Directory "/usr/local/myapp/apache_new/icons">
              Options Indexes MultiViews
              AllowOverride None
              Order allow,deny
              Allow from all
              </Directory>

              AliasMatch ^/manual(?:/(?:de|en|fr|ja|ko|ru))?(/.*)?$ "/usr/local/myapp/apache_new/manual$1"

              <Directory "/usr/local/myapp/apache_new/manual">
              Options Indexes
              AllowOverride None
              Order allow,deny
              Allow from all

              <Files *.html>
              SetHandler type-map
              </Files>

              SetEnvIf Request_URI ^/manual/de/ prefer-language=de
              SetEnvIf Request_URI ^/manual/en/ prefer-language=en
              SetEnvIf Request_URI ^/manual/fr/ prefer-language=fr
              SetEnvIf Request_URI ^/manual/ja/ prefer-language=ja
              SetEnvIf Request_URI ^/manual/ko/ prefer-language=ko
              SetEnvIf Request_URI ^/manual/ru/ prefer-language=ru
              RedirectMatch 301 ^/manual(?:/(de|en|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
              </Directory>

              ScriptAlias /cgi-bin/ "/usr/local/myapp/apache_new/cgi-bin/"

              <IfModule mod_cgid.c>
              </IfModule>

              <Directory "/usr/local/myapp/apache_new/cgi-bin">
              AllowOverride None
              Options None
              Order allow,deny
              Allow from all
              </Directory>



              IndexOptions FancyIndexing VersionSort

              AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

              AddIconByType (TXT,/icons/text.gif) text/*
              AddIconByType (IMG,/icons/image2.gif) image/*
              AddIconByType (SND,/icons/sound2.gif) audio/*
              AddIconByType (VID,/icons/movie.gif) video/*

              AddIcon /icons/binary.gif .bin .exe
              AddIcon /icons/binhex.gif .hqx
              AddIcon /icons/tar.gif .tar
              AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
              AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
              AddIcon /icons/a.gif .ps .ai .eps
              AddIcon /icons/layout.gif .html .shtml .htm .pdf
              AddIcon /icons/text.gif .txt
              AddIcon /icons/c.gif .c
              AddIcon /icons/p.gif .pl .py
              AddIcon /icons/f.gif .for
              AddIcon /icons/dvi.gif .dvi
              AddIcon /icons/uuencoded.gif .uu
              AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
              AddIcon /icons/tex.gif .tex
              AddIcon /icons/bomb.gif core

              AddIcon /icons/back.gif ..
              AddIcon /icons/hand.right.gif README
              AddIcon /icons/folder.gif ^^DIRECTORY^^
              AddIcon /icons/blank.gif ^^BLANKICON^^

              DefaultIcon /icons/unknown.gif


              ReadmeName README.html
              HeaderName HEADER.html



              AddLanguage da .dk
              AddLanguage nl .nl
              AddLanguage en .en
              AddLanguage et .et
              AddLanguage fr .fr
              AddLanguage de .de
              AddLanguage he .he
              AddLanguage el .el
              AddLanguage it .it
              AddLanguage ja .ja
              AddLanguage pl .po
              AddLanguage ko .ko
              AddLanguage pt .pt
              AddLanguage nn .nn
              AddLanguage no .no
              AddLanguage pt-br .pt-br
              AddLanguage ltz .ltz
              AddLanguage ca .ca
              AddLanguage es .es
              AddLanguage sv .sv
              AddLanguage cs .cz .cs
              AddLanguage ru .ru
              AddLanguage zh-CN .zh-cn
              AddLanguage zh-TW .zh-tw
              AddLanguage hr .hr

              LanguagePriority en da nl et fr de el it ja ko no pl pt pt-br ltz ca es sv tw

              ForceLanguagePriority Prefer Fallback

              AddDefaultCharset ISO-8859-1

              AddCharset ISO-8859-1 .iso8859-1 .latin1
              AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
              AddCharset ISO-8859-3 .iso8859-3 .latin3
              AddCharset ISO-8859-4 .iso8859-4 .latin4
              AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
              AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
              AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
              AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
              AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
              AddCharset ISO-2022-JP .iso2022-jp .jis
              AddCharset ISO-2022-KR .iso2022-kr .kis
              AddCharset ISO-2022-CN .iso2022-cn .cis
              AddCharset Big5 .Big5 .big5
              AddCharset WINDOWS-1251 .cp-1251 .win-1251
              AddCharset CP866 .cp866
              AddCharset KOI8-r .koi8-r .koi8-ru
              AddCharset KOI8-ru .koi8-uk .ua
              AddCharset ISO-10646-UCS-2 .ucs2
              AddCharset ISO-10646-UCS-4 .ucs4
              AddCharset UTF-8 .utf8

              AddCharset GB2312 .gb2312 .gb
              AddCharset utf-7 .utf7
              AddCharset utf-8 .utf8
              AddCharset big5 .big5 .b5
              AddCharset EUC-TW .euc-tw
              AddCharset EUC-JP .euc-jp
              AddCharset EUC-KR .euc-kr
              AddCharset shift_jis .sjis

              AddType application/x-tar .tgz
              AddType image/x-icon .ico




              AddHandler type-map var







              BrowserMatch "Mozilla/2" nokeepalive
              BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
              BrowserMatch "RealPlayer 4\.0" force-response-1.0
              BrowserMatch "Java/1\.0" force-response-1.0
              BrowserMatch "JDK/1\.0" force-response-1.0

              BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
              BrowserMatch "^WebDrive" redirect-carefully
              BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
              BrowserMatch "^gnome-vfs" redirect-carefully




              <IfModule mod_ssl.c>
              Include conf/ssl.conf
              </IfModule>更多精彩文章及讨论,请光临枫下论坛 rolia.net
              • up
    • 新建的apache可以运行了,我把相应cgi程序拷贝进来,而且可以看到error_log了. "Premature end of script headers" 代表什么意思?
      error_log中完整的日志信息是:
      [Thu Jul 21 11:47:05 2005] [error] [client 192.168.201.175] Premature end of script headers: mydaemon.exe, referer: http://192.168.50.21:8000/cgi-bin/mydaemon.exe
      • http://httpd.apache.org/docs/misc/FAQ-F.html#premature-script-headers make sure mydaemon.exe has exec permission first.
        • -rwsr-sr-x 1 root root 4037204 Jul 20 15:27 /usr/local/myapp/apache/cgi-bin/mydaemon.exe I think the permission is enough.
          • what's the result when you directly run mydaemon? also do you really need setuid?
            • I don't think setuid is an issue. How to run the cgi program from the command line? just like: /usr/local/myapp/apache/cgi-bin/mydaemon.exe?cmd=SysDaemon_Start&uid=1&sid=0&name=HPD-SMTPD
      • 我将该cgi输出的内容重定向到tst.html.如果把tst.html放到apache/htdocs/下该页面可正常显示(http://192.168.50.21:8000/tst.html);如果放入apache/cgi-bin/下就返回错误(http://192.168.50.21:8000/cgi-bin/ttt.html)
        还是没有思路:-(
        • 修改CGI程序,在输出页面前改当前路经到/usr/local/myapp/apache/htdocs,还是不行!! 我已经基本晕菜了!
      • It is the permission setup problem for you apache. I have run into this problem before. It is wired. So try to change another CGI directory and assign the related permission to it.
    • 问题解决了,方法见连接, 感谢关注!