Page 1 sur 1

[script perl] mon navigateur n'exécute pas les scripts perl.

Publié : mar. 03 nov. 2015, 04:09
par ignace72
Salut à tous,
Tout est dans le titre…quand j'essaye d’exécuter un script perl, mon navigateur me propose de l'ouvrir au lieu de l'exécuter.

Adresse du script :
https://ignace72.eu/test.cgi

Code : Tout sélectionner

#!/usr/bin/perl

print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Perl Environment Variables</title></head>
<body>
<h1>Perl Environment Variables</h1>
EndOfHTML

foreach $key (sort(keys %ENV)) {
    print "$key = $ENV{$key}<br>\n";
}

print "</body></html>";
Mon nginx.conf

Code : Tout sélectionner

user http;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

     #HSTS
     add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";

    sendfile        on;
    #tcp_nopush     on;

	error_log      /var/log/nginx/error.log;

	server_tokens off;

    #keepalive_timeout  0;
    keepalive_timeout  65;

	gzip            on;
	# désactivation de la compression pour les navigateur ne la prenant pas en charge (IE < 6)
	gzip_disable    "MSIE [1-6].(?!.*SV1)";
	gzip_vary       on;
	gzip_comp_level 3;
	gzip_proxied    any;
	gzip_buffers    16 8k;
	gzip_types text/plain text/html text/css application/json  application/x-javascript application/xml application/xml+rss  text/javascript;

    server {
        listen       80;
        server_name ignace72.eu;
	rewrite ^ https://$server_name$request_uri? permanent;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /srv/http;
            index  index.html index.htm index.php;
        }

	location ~ \.php$ {
		root           /srv/http;
     		fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
     		fastcgi_index  index.php;
     		include        fastcgi.conf;
	}


        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    server {
        listen       443 ssl spdy;
        server_name  localhost ignace72.eu;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate      /etc/ssl/serveur.crt	;
        ssl_certificate_key  /etc/ssl/serveur.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_prefer_server_ciphers  on;
        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
	ssl_dhparam /etc/ssl/dhparams.pem;

        ssl_stapling on;
        ssl_stapling_verify on;


        location / {
            root   /srv/http;
            index  index.html index.htm index.php;
        }

	error_page 404 /404.html;
   	location = /404.html {
	 root /srv/http; 
	}

	error_page 403 /403.html;
   	location = /403.html {
	 root /srv/http; 
	}


	location ~ \.php$ {
		root           /srv/http;
     		fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
     		fastcgi_index  index.php;
		fastcgi_param HTTPS on;
		fastcgi_param  PHP_ADMIN_VALUE  open_basedir="/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/";

     		include        fastcgi.conf;
	}
	

	location ^~ /awstats-icon {
   alias /usr/share/webapps/awstats/icon/;
   access_log off;
}
location ^~ /awstatscss {
   alias /usr/share/webapps/awstats/examples/css/;
   access_log off;
}
location ^~ /awstatsclasses {
   alias /usr/share/webapps/awstats/examples/classes/;
   access_log off;
}
location ~ ^/cgi-bin/.*\.(cgi|pl|py|rb) {
   gzip off;
   fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
   fastcgi_index cgi-bin.php;
   fastcgi_param SCRIPT_FILENAME    /etc/nginx/cgi-bin.php;
   fastcgi_param SCRIPT_NAME        /cgi-bin/cgi-bin.php;
   fastcgi_param X_SCRIPT_FILENAME  /usr/share/webapps/awstats$fastcgi_script_name;
   fastcgi_param X_SCRIPT_NAME      $fastcgi_script_name;
   fastcgi_param QUERY_STRING       $query_string;
   fastcgi_param REQUEST_METHOD     $request_method;
   fastcgi_param CONTENT_TYPE       $content_type;
   fastcgi_param CONTENT_LENGTH     $content_length;
   fastcgi_param GATEWAY_INTERFACE  CGI/1.1;
   fastcgi_param SERVER_SOFTWARE    nginx;
   fastcgi_param REQUEST_URI        $request_uri;
   fastcgi_param DOCUMENT_URI       $document_uri;
   fastcgi_param DOCUMENT_ROOT      $document_root;
   fastcgi_param SERVER_PROTOCOL    $server_protocol;
   fastcgi_param REMOTE_ADDR        $remote_addr;
   fastcgi_param REMOTE_PORT        $remote_port;
   fastcgi_param SERVER_ADDR        $server_addr;
   fastcgi_param SERVER_PORT        $server_port;
   fastcgi_param SERVER_NAME        $server_name;
   fastcgi_param REMOTE_USER        $remote_user;
}

    }

}


#
# Directives to allow use of AWStats as a CGI
#
# Alias /awstatsclasses "/home/ignace/wwwroot/classes/"
# Alias /awstatscss "/home/ignace/wwwroot/css/"
# Alias /awstatsicons "/home/ignace/wwwroot/icon/"
# ScriptAlias /awstats/ "/home/ignace/wwwroot/cgi-bin/"
# 
#
# This is to permit URL access to scripts/files in AWStats directory.
#
# <Directory "/home/ignace/wwwroot">
#     Options None
#     AllowOverride None
#     Order allow,deny
#     Allow from all
# </Directory>
À titre d'info, j'ai perl-cgi installé.

Merci.

Re: [script perl] mon navigateur n'exécute pas les scripts perl.

Publié : mar. 03 nov. 2015, 04:32
par papajoke
Bonjour,
ca doit être cette ligne :

Code : Tout sélectionner

location ~ ^/cgi-bin/.*\.(cgi|pl|py|rb) {
tes scripts (sauf php) ne peuvent être que dans le dossier /cgi-bin/

Re: [script perl] mon navigateur n'exécute pas les scripts perl.

Publié : mar. 03 nov. 2015, 04:52
par ignace72
Bon, ben j'ai un message d'erreur en faisant https://ignace72.eu/cgi-bin/test.cgi

J'ai une erreur 404 « No input file specified. » dans access.log.

Code : Tout sélectionner

127.0.0.1 - - [03/Nov/2015:03:46:28 +0000] "GET /cgi-bin/test.cgi HTTP/1.1" 404 25 "-" "Mozilla/5.0 (Windows NT 6.1; rv:41.0) Gecko/20100101 Firefox/41.0"
Et

dans error.log :

Code : Tout sélectionner

Unable to open primary script: /etc/nginx/cgi-bin.php (Operation not permitted)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /cgi-bin/test.cgi HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "ignace72.eu"
Merci

Re: [script perl] mon navigateur n'exécute pas les scripts perl.

Publié : mar. 03 nov. 2015, 13:53
par papajoke
oui, tout est configuré pour du php,
il faut installer perl-cgi-fast et que la partie "/cgi-bin/" et-ou "*.pl" dans nginx.conf pointe vers fcgi et non vers php-fpm

Re: [script perl] mon navigateur n'exécute pas les scripts perl.

Publié : mar. 03 nov. 2015, 14:04
par ignace72
Bonjour,
perl-cgi est déjà installé, je regarde comment le configurer.
Merci.