Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 29/09/2018, à 18:49

Black_Mamba

Apache2 - CGI

Bonjour à tous,

Je n'arrive pas à lancer des scripts CGI avec Apache2 depuis un navigateur internet. Je sais qu'il existe pas mal de documentation dessus, mais je pense que celle-ci n'est pas à jour car les dossiers et fichiers de configuration ont changé.

Ma configuration
J'ai tester avec ma tour de pc et mon laptop
Apache 2.4.18 (Ubuntu 16.04)
Apache 2.4.29 (Linux Mint 19 Cinnamon)
Je précise que Mint est basé sur Ubuntu

Avant, il me semble qu'on créé un dossier /var/www/cgi-bin où l'on déposait ses scripts
et qu'il y avait un fichier à configurer qui est soit /etc/apache2/vhosts.d soit /etc/apache2/apache2.conf .

Maintenant, chez moi les fichiers de configurations sont dans /etc/apache2 selon la doc d'Ubuntu

Contenue du fichier /etc/apache2/conf-available/serve-cgi-bin.conf par défaut :

<IfModule mod_alias.c>
	<IfModule mod_cgi.c>
		Define ENABLE_USR_LIB_CGI_BIN
	</IfModule>

	<IfModule mod_cgid.c>
		Define ENABLE_USR_LIB_CGI_BIN
	</IfModule>

	<IfDefine ENABLE_USR_LIB_CGI_BIN>
		ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
		<Directory "/usr/lib/cgi-bin">
			AllowOverride None
			Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
			Require all granted
		</Directory>
	</IfDefine>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Je sais juste qu'il faut un ScriptAlias qui donne des droits et redirige les dossiers.
Je suppose qu'il faut déposer ses scripts dans /usr/lib/cgi-bin
Je créé un fichier bla.cgi :

echo coucou
pwd
date

Sous Debian le nom d’user d’apache est www-data, je fais ces commandes :

chown -R www-data bla.cgi
chmod 750 bla.cgi
/etc/init.d/apache2 restart

Dans mon navigateur je tape : localhost/cgi-bin/bla.cgi
et je tombe sur une page 404 Not found.

En faisant les commandes :

a2enmod cgi
systemctl restart apache2

La page  404 Not found devient "Internal Server Error", j'ai ça seulement sous Mint, sous Ubuntu rien ne change.

J'ai déjà tenter de bidouiller des commandes mystiques mais rien n'y fait.
J'ai ici quelques pistes...
[RESOLU] Apache et cgi-bin
Apache2.4.7 on Ubuntu 14.04 won't execute Python cgi file.

Merci à ceux qui prendront le temps de me lire. wink


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#2 Le 30/09/2018, à 09:04

bruno

Re : Apache2 - CGI

Bonjour,

Je créé un fichier bla.cgi :

echo coucou
pwd
date

Ton script doit renvoyer quelque chose de compréhensible pour le navigateur : du HTML par exemple. Et ce script il doit être interprété par quoi : python, php, bash, … ?

Hors ligne

#3 Le 30/09/2018, à 10:15

grigouille

Re : Apache2 - CGI

Il faut envoyer le Content-Type aussi.


Debian (xfce) 12
HP LaserJet M1132 MFP

Hors ligne

#4 Le 30/09/2018, à 13:25

Black_Mamba

Re : Apache2 - CGI

Voila j'ai rajoute le content-type, le shebang et modifier le fichier bla.cgi->bla.sh

#!/bin/bash
echo 'Content-type: text/html'
echo 'coucou'

J'ai relancer Apache mais rien n'y fait le problème vient pas de la mais plutôt de la configuration je pense, sauf que je vois pas ce que je peux faire de plus hmm


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#5 Le 30/09/2018, à 13:28

bruno

Re : Apache2 - CGI

Les modules apache requis sont bien activés ?

sudo a2enmod cgi
sudo a2enmod alias
susod sytemctl restart apache2

Hors ligne

#6 Le 30/09/2018, à 13:45

Black_Mamba

Re : Apache2 - CGI

oui

modification

root@jordan-177:/usr/lib/cgi-bin# a2enmod cgi
Module cgi already enabled
root@jordan-177:/usr/lib/cgi-bin# a2enmod alias
Module alias already enabled
root@jordan-177:/usr/lib/cgi-bin# systemctl restart apache2

Dernière modification par Black_Mamba (Le 30/09/2018, à 13:59)


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#7 Le 30/09/2018, à 13:55

bruno

Re : Apache2 - CGI

Merci de faire des copier/coller plutôt que de mettre des images.
Donnes-nous la configuration de ton hôte virtuel.

Hors ligne

#8 Le 30/09/2018, à 14:03

Black_Mamba

Re : Apache2 - CGI

Je suis pas sur d'avoir compris la question, je crois que c'est ca :

root@jordan-177:/usr/lib/cgi-bin# cd /etc/apache2/sites-available/
000-default.conf  default-ssl.conf

root@jordan-177:/etc/apache2/sites-available# cat 000-default.conf 
<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
root@jordan-177:/etc/apache2/sites-available# cat 000-default.conf 
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName [url=http://www.example.com]www.example.com[/url]

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
root@jordan-177:/etc/apache2/sites-available# cat 
000-default.conf  default-ssl.conf  
root@jordan-177:/etc/apache2/sites-available# cat default-ssl.conf 
<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

        #   Server Certificate Chain:
        #   Point SSLCertificateChainFile at a file containing the
        #   concatenation of PEM encoded CA certificates which form the
        #   certificate chain for the server certificate. Alternatively
        #   the referenced file can be the same as SSLCertificateFile
        #   when the CA certificates are directly appended to the server
        #   certificate for convinience.
        #SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

        #   Certificate Authority (CA):
        #   Set the CA certificate verification path where to find CA
        #   certificates for client authentication or alternatively one
        #   huge file containing all of them (file must be PEM encoded)
        #   Note: Inside SSLCACertificatePath you need hash symlinks
        #         to point to the certificate files. Use the provided
        #         Makefile to update the hash symlinks after changes.
        #SSLCACertificatePath /etc/ssl/certs/
        #SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

        #   Certificate Revocation Lists (CRL):
        #   Set the CA revocation path where to find CA CRLs for client
        #   authentication or alternatively one huge file containing all
        #   of them (file must be PEM encoded)
        #   Note: Inside SSLCARevocationPath you need hash symlinks
        #         to point to the certificate files. Use the provided
        #         Makefile to update the hash symlinks after changes.
        #SSLCARevocationPath /etc/apache2/ssl.crl/
        #SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

        #   Client Authentication (Type):
        #   Client certificate verification type and depth.  Types are
        #   none, optional, require and optional_no_ca.  Depth is a
        #   number which specifies how deeply to verify the certificate
        #   issuer chain before deciding the certificate is not valid.
        #SSLVerifyClient require
        #SSLVerifyDepth  10

        #   SSL Engine Options:
        #   Set various options for the SSL engine.
        #   o FakeBasicAuth:
        #     Translate the client X.509 into a Basic Authorisation.  This means that
        #     the standard Auth/DBMAuth methods can be used for access control.  The
        #     user name is the `one line' version of the client's X.509 certificate.
        #     Note that no password is obtained from the user. Every entry in the user
        #     file needs this password: `xxj31ZMTZzkVA'.
        #   o ExportCertData:
        #     This exports two additional environment variables: SSL_CLIENT_CERT and
        #     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
        #     server (always existing) and the client (only existing when client
        #     authentication is used). This can be used to import the certificates
        #     into CGI scripts.
        #   o StdEnvVars:
        #     This exports the standard SSL/TLS related `SSL_*' environment variables.
        #     Per default this exportation is switched off for performance reasons,
        #     because the extraction step is an expensive operation and is usually
        #     useless for serving static content. So one usually enables the
        #     exportation for CGI and SSI requests only.
        #   o OptRenegotiate:
        #     This enables optimized SSL connection renegotiation handling when SSL
        #     directives are used in per-directory context.
        #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>

        #   SSL Protocol Adjustments:
        #   The safe and default but still SSL/TLS standard compliant shutdown
        #   approach is that mod_ssl sends the close notify alert but doesn't wait for
        #   the close notify alert from client. When you need a different shutdown
        #   approach you can use one of the following variables:
        #   o ssl-unclean-shutdown:
        #     This forces an unclean shutdown when the connection is closed, i.e. no
        #     SSL close notify alert is send or allowed to received.  This violates
        #     the SSL/TLS standard but is needed for some brain-dead browsers. Use
        #     this when you receive I/O errors because of the standard approach where
        #     mod_ssl sends the close notify alert.
        #   o ssl-accurate-shutdown:
        #     This forces an accurate shutdown when the connection is closed, i.e. a
        #     SSL close notify alert is send and mod_ssl waits for the close notify
        #     alert of the client. This is 100% SSL/TLS standard compliant, but in
        #     practice often causes hanging connections with brain-dead browsers. Use
        #     this only for browsers where you know that their SSL implementation
        #     works correctly.
        #   Notice: Most problems of broken clients are also related to the HTTP
        #   keep-alive facility, so you usually additionally want to disable
        #   keep-alive for those clients, too. Use variable "nokeepalive" for this.
        #   Similarly, one has to force some clients to use HTTP/1.0 to workaround
        #   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
        #   "force-response-1.0" for this.
        # BrowserMatch "MSIE [2-6]" \
        #        nokeepalive ssl-unclean-shutdown \
        #        downgrade-1.0 force-response-1.0

    </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Dernière modification par Black_Mamba (Le 30/09/2018, à 14:04)


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#9 Le 30/09/2018, à 14:07

bruno

Re : Apache2 - CGI

Il te faut configurer au moins un hôte virtuel comme indiqué dans la documentation : https://doc.ubuntu-fr.org/apache2

Hors ligne

#10 Le 30/09/2018, à 14:37

Black_Mamba

Re : Apache2 - CGI

Je vois pas trop ce que je dois mettre dans le fichier conf
J'ai ajoute 2 lignes par rapport a l'exemple et modifier le dossier de destination


root@jordan-177:/var/www/cgi-bin# cat /etc/apache2/sites-available/cgi.conf
<VirtualHost *:80>
	ServerName example.com
	ServerAlias www.example.com
	DocumentRoot "/var/www/cgi-bin"
	<Directory "/var/www/cgi-bin">
		Options +FollowSymLinks
		AllowOverride all
		Require all granted
        
        Options +ExecCGI
        AddHandler cgi-script .cgi
	</Directory>
	ErrorLog /var/log/apache2/error.example.com.log
	CustomLog /var/log/apache2/access.example.com.log combined
root@jordan-177:/var/www/cgi-bin# a2ensite /etc/apache2/sites-available/cgi
ERROR: Site /etc/apache2/sites-available/cgi does not exist!

Dernière modification par Black_Mamba (Le 30/09/2018, à 14:49)


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#11 Le 30/09/2018, à 15:11

bruno

Re : Apache2 - CGI

example.com c'est pour l'exemple…
Soit tu as un vrai nom de domaine, soit tu mets localhost et du désactive l'hôte virtuel par défaut :

sudo a2dissite 000-default.conf

/etc/apache2/sites-available/cgi.conf :

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "/var/www/cgi-bin"
	<Directory "/var/www/cgi-bin">
		Options +ExecCGI +FollowSymLinks
		AllowOverride all
		Require all granted
               AddHandler cgi-script .cgi
	</Directory>
	ErrorLog /var/log/apache2/error.example.com.log
	CustomLog /var/log/apache2/access.example.com.log combined
</VirtualHost *:80>

Et tu actives avec

a2ensite cgi.conf

Les scripts devront être dans /var/www/cgi-bin

Dernière modification par bruno (Le 30/09/2018, à 15:16)

Hors ligne

#12 Le 30/09/2018, à 15:34

grigouille

Re : Apache2 - CGI

Black_Mamba a écrit :

Voila j'ai rajoute le content-type, le shebang et modifier le fichier bla.cgi->bla.sh

#!/bin/bash
echo 'Content-type: text/html'
echo 'coucou'

Essaie ceci

$ cat test.cgi
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<!DOCTYPE html>"
echo "<html lang=\"fr\">"
echo 	"<head>"
echo 		"<meta charset=\"utf-8\" />"
echo 		"<title> Test cgi </title>"
echo 	"</head>"
echo 	"<body>"
echo 	"<p>coucou</p>"
echo 	"</body>"
echo "</html>"

Qui donne :

$ ./test.cgi
Content-type: text/html

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<title> Test cgi </title>
</head>
<body>
<p>coucou</p>
</body>
</html>

Debian (xfce) 12
HP LaserJet M1132 MFP

Hors ligne

#13 Le 30/09/2018, à 16:16

Black_Mamba

Re : Apache2 - CGI

Bruno :
J'ai copier/coller ta config cgi.conf, desactiver 000-default.conf et activer cgi.conf

Mes fichiers sont bien dans var/www/cgi-bin

root@jordan-177:/var/www/cgi-bin# ll
total 20
drwxr-xr-x 2 root     root 4096 Sep 30 14:57 ./
drwxr-xr-x 4 root     root 4096 Sep 25 11:09 ../
-rwxr-xr-x 1 www-data root   77 Sep 30 14:57 bla.cgi*
-rwxr-xr-x 1 www-data root   77 Sep 30 14:28 bla.sh*
-rw-r--r-- 1 root     root   53 Sep 25 19:07 toto.py

Question peut etre bete mais je dois mettre dans mon navigateur localhost/bla.cgi ou localhost/cgi-bin/bla.cgi ?


Je n'arrive plus a redemarre apache2

/etc/init.d/apache2 restart
[....] Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
 failed!

systemctl status apache2.service

root@jordan-177:/var/www/cgi-bin# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Sun 2018-09-30 16:10:39 CEST; 23min ago
  Process: 3085 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

Sep 30 16:10:39 jordan-177 systemd[1]: Starting The Apache HTTP Server...
Sep 30 16:10:39 jordan-177 apachectl[3085]: apache2: Syntax error on line 225 of /etc/apache2/apache2.conf: Syntax error on line 12 of
Sep 30 16:10:39 jordan-177 apachectl[3085]: Action 'start' failed.
Sep 30 16:10:39 jordan-177 apachectl[3085]: The Apache error log may have more information.
Sep 30 16:10:39 jordan-177 systemd[1]: apache2.service: Control process exited, code=exited status=1
Sep 30 16:10:39 jordan-177 systemd[1]: apache2.service: Failed with result 'exit-code'.
Sep 30 16:10:39 jordan-177 systemd[1]: Failed to start The Apache HTTP Server.

journalctl -xe

root@jordan-177:/var/www/cgi-bin# journalctl -xe
Sep 30 16:18:25 jordan-177 systemd[1]: Starting Network Manager Script Dispatcher Service...
-- Subject: Unit NetworkManager-dispatcher.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit NetworkManager-dispatcher.service has begun starting up.
Sep 30 16:18:25 jordan-177 dbus-daemon[927]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Sep 30 16:18:25 jordan-177 systemd[1]: Started Network Manager Script Dispatcher Service.
-- Subject: Unit NetworkManager-dispatcher.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit NetworkManager-dispatcher.service has finished starting up.
-- 
-- The start-up result is RESULT.
Sep 30 16:18:25 jordan-177 nm-dispatcher[3159]: req:1 'dhcp4-change' [wlp2s0]: new request (1 scripts)
Sep 30 16:18:25 jordan-177 nm-dispatcher[3159]: req:1 'dhcp4-change' [wlp2s0]: start running ordered scripts...
Sep 30 16:33:41 jordan-177 pkexec[3194]: pam_unix(polkit-1:session): session opened for user root by (uid=1000)
Sep 30 16:33:41 jordan-177 pkexec[3194]: jordan: Executing command [USER=root] [TTY=unknown] [CWD=/home/jordan] [COMMAND=/usr/lib/x86_
Sep 30 16:33:43 jordan-177 cinnamon-screensaver-pam-helper[3200]: pam_ecryptfs: seteuid error
Sep 30 16:33:43 jordan-177 cinnamon-screensaver-pam-helper[3200]: gkr-pam: the password for the login keyring was invalid.

En faisant  tail -20 /var/log/apache2/error.log , il y a cette ligne qui m'interpelle
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

Dernière modification par Black_Mamba (Le 30/09/2018, à 16:37)


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#14 Le 30/09/2018, à 16:58

bruno

Re : Apache2 - CGI

/etc/apache2/apache2.conf: Syntax error on line 12 of

(la ligne est coupée…

Tu as une erreur de configuration, donne-nous le retour de :

sudo apache2ctl -t

Hors ligne

#15 Le 30/09/2018, à 17:51

Black_Mamba

Re : Apache2 - CGI

jordan@jordan-177:~$ sudo apache2ctl -t
[sudo] password for jordan: 
apache2: Syntax error on line 225 of /etc/apache2/apache2.conf: Syntax error on line 12 of /etc/apache2/sites-enabled/cgi.conf: </VirtualHost> directive missing closing '>'
Action '-t' failed.
The Apache error log may have more information.

ligne 224 et 225 du fichier apache2.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

/etc/apache2/site-enabled/cgi.conf :
la ligne 12 est la derniere ligne

jordan@jordan-177:~$ cat /etc/apache2/sites-enabled/cgi.conf 
<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "/var/www/cgi-bin"
	<Directory "/var/www/cgi-bin">
		Options +ExecCGI +FollowSymLinks
		AllowOverride all
		Require all granted
               AddHandler cgi-script .cgi
	</Directory>
	ErrorLog /var/log/apache2/error.example.com.log
	CustomLog /var/log/apache2/access.example.com.log combined
</VirtualHost *:80>

Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne

#16 Le 30/09/2018, à 18:41

bruno

Re : Apache2 - CGI

Ah tu as fait un copier/coller…
en #11 j'ai fait une erreur, le fichier correct est :

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "/var/www/cgi-bin"
	<Directory "/var/www/cgi-bin">
		Options +ExecCGI +FollowSymLinks
		AllowOverride all
		Require all granted
               AddHandler cgi-script .cgi
	</Directory>
	ErrorLog /var/log/apache2/error.example.com.log
	CustomLog /var/log/apache2/access.example.com.log combined
</VirtualHost>

Hors ligne

#17 Le 30/09/2018, à 19:18

Black_Mamba

Re : Apache2 - CGI

Super ca marche !

Pour le fichier bla.sh : ca souhaite ouvrir/enregistrer le fichier
Je dois encore essayer de remedier a ca

Pour le fichier cgi :  j'ai du copier/coller ceci
(Merci grigouille smile )

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<!DOCTYPE html>"
echo "<html lang=\"fr\">"
echo 	"<head>"
echo 		"<meta charset=\"utf-8\" />"
echo 		"<title> Test cgi </title>"
echo 	"</head>"
echo 	"<body>"
echo 	"<p>coucou</p>"
echo 	"</body>"
echo "</html>"

Merci surtout a toi bruno qui a pris le temps de repondre a chacune des  etapes.

Je vais maintenant m'y essayer, je ferai bien un tuto recapitulatif de la configuration sous Ubuntu par la suite smile


Ubuntu 16.04 LTS 64bits
CARTE MERE : Gigabyte GA-AB350-Gaming 3 Carte mère AMD B350 Socket AM4 | CARTE GRAPHIQUE : Gigabyte AORUS GeForce GTX 1060 XTREME Edition, 6 Go | RAM : Corsair  8GB DDR4 2133Mhz | PROCESSEUR : AMD Ryzen 5 1600 (3.2 GHz)
Étudiant en Bio-informatique | Python, Gentoo, Ubuntu

Hors ligne