Próbowałem już różnych sposobów na to jak włączyć pythona 3 do modułu apache2 i zawsze pojawiał się ten sam błąd jak próbowałem wczytać stronę pythona
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Sprawdzałem logi apacha
i tam był komunikat
[Wed May 16 1332.908010 2018] [cgi:error] [pid 8602] [client 127.0.0.1:57528] malformed header from script 'index.py': Bad header: ()
Nawet jak dałem zwykłe hello wordl
Czyli tak
Kod jest taki
#!/usr/bin/python
# Turn on debug mode.
import cgitb
cgitb.enable()
# Print necessary headers.
print("Content-Type: text/html")
print()
# Connect to the database.
import pymysql
conn = pymysql.connect(
db='youtube',
user='root',
passwd='a1234',
host='localhost')
c = conn.cursor()
# Insert some example data.
#c.execute("INSERT INTO numbers VALUES (1, 'One!')")
#c.execute("INSERT INTO numbers VALUES (2, 'Two!')")
#c.execute("INSERT INTO numbers VALUES (3, 'Three!')")
conn.commit()
# Print the contents of the database.
c.execute("SELECT * FROM tematy")
print([(r[0], r[1]) for r in c.fetchall()])
Dodam, że też moduł mysql do pythona nie działa wyświetla się
Wyświetla się w konsoli taki błąd.
File "index.py", line 12, in <module>
import pymysql
ImportError: No module named pymysql
Nawet wykonałem polecenie
pip3 install PyMySQL
no i zwróciło wynik
Requirement already satisfied (use --upgrade to upgrade): pyMySQL in /usr/local/lib/python3.4/dist-packages
Cleaning up...
Mój system to debian 8.4