通过SSL执行PHP CGI脚本

在亚马逊Linux上的Apache 2.4(大概相当于RH 7,我想),与各种版本的PHP

当启用SSL时,我遇到了一个问题,试图让PHP CGI脚本在我的Web服务器上运行。 例如:

http://52.example.com/phpinfo.php 

给出正确的输出,但是当我启用SSL(即https://52.example.com ),我得到一个404错误:

 The requested URL /php-fcgi/php-cgi-5.2.17/phpinfo.php was not found on this server. 

以下是我的/ var / www / vhosts目录中的52.conf文件的内容:

  <VirtualHost *:443> ServerName 52.example.com DocumentRoot /var/www/vhosts/52 <Directory "/var/www/vhosts/52/"> AddHandler php-cgi .php Action php-cgi /php-fcgi/php-cgi-5.2.17 <FilesMatch "\.php$"> Options ExecCGI SetHandler php-cgi </FilesMatch> </Directory> 

其中site.conf是一个虚拟主机定义。

这里是php-cgi-5.2.17文件的内容:

 #!/bin/sh version="5.2.17" PHPRC=/opt/phpfarm/inst/php-${version}/lib/php.ini export PHPRC PHP_FCGI_CHILDREN=3 export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_MAX_REQUESTS # which php-cgi binary to execute exec /opt/phpfarm/inst/php-${version}/bin/php-cgi 

正如你可以告诉,我使用PHPFarm服务器不同版本的PHP到不同的子域。

请注意,我不确定 SSL是否是我悲伤的原因,但似乎非常可疑。

如果有人有任何想法或想法,我会永远感激。 提前致谢。

Apache默认使用不同的主机configuration文件作为默认的SSL服务器。 而我没有看到你的configuration,你张贴的片段的任何SSL参考….

所以..它可能会回落到任何默认的主机被定义,并指向错误的DocumentRoot。

运行apache2ctl -S以查看当前正在运行的名称/别名,地址和端口。 它也会告诉你什么configuration文件定义了它,以及定义在哪一行开始。

 VirtualHost configuration: 10.99.88.55:443 is a NameVirtualHost default server example.com (/etc/apache2/sites-enabled/example.com.conf:1) port 443 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1) alias www.example.com port 443 namevhost mail.example.com (/etc/apache2/sites-enabled/mail.example.com.conf:1) port 443 namevhost ww2.example.com (/etc/apache2/sites-enabled/ww2.example.com.conf:1) *:80 is a NameVirtualHost default server www.example.com (/etc/apache2/sites-enabled/000-default.conf:2) port 80 namevhost www.example.com (/etc/apache2/sites-enabled/000-default.conf:2) alias example.com port 80 namevhost ww2.example.com (/etc/apache2/sites-enabled/000-default.conf:7) port 80 namevhost mail.example.com (/etc/apache2/sites-enabled/000-default.conf:11) 

编辑包含一个主机定义的例子,用SSL指令指向一个letsencrypt证书,并在http上将相同的站点redirect到https –

 <VirtualHost 10.99.99.123:443> ServerName example.com ServerAlias www.example.com ServerAdmin [email protected] SSLEngine on SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown DocumentRoot /var/www-example.com <directory /var/www-example.com> Options All AllowOverride All Require all granted </directory> ErrorLog ${APACHE_LOG_DIR}/ssl-example.com-error.log CustomLog ${APACHE_LOG_DIR}/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" CustomLog ${APACHE_LOG_DIR}/ssl-example.com-access.log combined </VirtualHost> <VirtualHost *:80> ServerName example.com ServerAlias www.example.com Redirect permanent / https://www.example.com </VirtualHost>