Chinaunix
标题:
apache+php-fpm如何实现cgi程序
[打印本页]
作者:
行走的小布鞋
时间:
2015-03-20 16:32
标题:
apache+php-fpm如何实现cgi程序
各位前辈,大家好,有个问题想请教大家。
我在部署Nagios应用程序,遇到一个问题,就是使用apache+php-fpm结构部署nagios应用的时候,cgi程序无法运行,具体点说,就是
我通过浏览器点击一个菜单栏,点击之后,本来应该运行一个应用程序,/nagios/cgi-bin/status.cgi,但是,这个应用没有运行,系统紧紧是把他当做一个普通文件,然后页面弹出一个下载框。不知道我说明白没有,就是在我认为,通过浏览器访问一个cgi文件,正常情况下,应该是cgi文件在服务器运行,然后把运行后的结果返回到浏览器。
而现在的情况是,他把cgi文件,当做一个普通html文件了,没有运行,如何解决。
我在网上搜了一下,多数是说该Directory中的访问权限,Allow from all,Options ExecCGI,我试过了,还是不行。
我把配置文件贴出来,麻烦各位大侠帮忙看看
httpd.conf:
ServerRoot "/usr/local/apache"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User apache
Group apache
</IfModule>
ServerAdmin you@example.com
ServerName cacti.test.com:80
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
DocumentRoot "/usr/local/apache/htdocs"
<Directory "/usr/local/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.php 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" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/usr/local/apache/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler cgi-script .cgi .pl
</IfModule>
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
复制代码
这个是vhost文件:
<VirtualHost *:80>
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1
DocumentRoot "/usr/local/apache/htdocs"
ServerName cacti.test.com
ErrorLog "logs/cacti-error_log"
CustomLog "logs/cacti-access_log" common
</VirtualHost>
<VirtualHost *:80>
ProxyRequests off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/nagios/share/$1
#ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1
DocumentRoot "/usr/local/nagios/share"
ServerName nagios.test.com
ErrorLog "logs/nagios-error_log"
CustomLog "logs/nagios-access_log" common
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
</VirtualHost>
复制代码
实在不知道问题在哪里?请大侠帮帮忙了
作者:
行走的小布鞋
时间:
2015-03-20 17:09
没有人么???自己顶顶
作者:
bikong0411
时间:
2015-03-21 09:02
<Directory "/server/apache2/cgi-bin">;
AllowOverride None
Options +ExecCGI
SetHandler cgi-script
Options ExecCGI
Order allow,deny
Allow from all
</Directory>;
AddHandler cgi-script .cgi 话说你看下127.0.0.1:9000服务在不在
作者:
行走的小布鞋
时间:
2015-03-23 11:18
这个服务确实是在的,谢谢亲,我找到原因了,说来不好意思,因为cgi模块没有加载进来。我太相信apache了,哈哈
回复
3#
bikong0411
作者:
bikong0411
时间:
2015-03-24 09:59
回复
4#
行走的小布鞋
找到原因就好
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2