How to Run core python script directly on server(UBUNTU)
1. First of all, you must have apache server installed in your system. If not then download and install it.
2. After that enable the cgi mod with the help of the following command:
sudo a2enmod cgi
3. Change the apache conf file by placing the following code in it:
listen 8090
<VirtualHost *:8090>
DocumentRoot /var/www/html/python
ScriptAlias /cgi-bin/ /var/www/html/python/
<Directory "/var/www/html/python">
AllowOverride All
Options +ExecCGI
Order allow,deny
Allow from all
AddHandler cgi-script .cgi .py
DirectoryIndex index.html index.php index.py
</Directory>
</VirtualHost>
Save the file and exit.
4. Make new file name index.py at /var/www/hmtl/python/ and paste the following code in it:
print "Content-type: text/html\n\n";
print "<center><h1>Welcome to python world.</h1></center>"
5. After setting up all this don't forget to restart the apache server.
sudo service apache2 restart
6. Now check the browser http://127.0.0.1:8090/. You will see a welcome message on the screen that you have placed in the index.py file.
Thats all Folks! Have fun and keep doing Python Programming!
1. First of all, you must have apache server installed in your system. If not then download and install it.
2. After that enable the cgi mod with the help of the following command:
sudo a2enmod cgi
3. Change the apache conf file by placing the following code in it:
listen 8090
<VirtualHost *:8090>
DocumentRoot /var/www/html/python
ScriptAlias /cgi-bin/ /var/www/html/python/
<Directory "/var/www/html/python">
AllowOverride All
Options +ExecCGI
Order allow,deny
Allow from all
AddHandler cgi-script .cgi .py
DirectoryIndex index.html index.php index.py
</Directory>
</VirtualHost>
Save the file and exit.
4. Make new file name index.py at /var/www/hmtl/python/ and paste the following code in it:
print "Content-type: text/html\n\n";
print "<center><h1>Welcome to python world.</h1></center>"
5. After setting up all this don't forget to restart the apache server.
sudo service apache2 restart
6. Now check the browser http://127.0.0.1:8090/. You will see a welcome message on the screen that you have placed in the index.py file.
Thats all Folks! Have fun and keep doing Python Programming!
thnxxx for this info
ReplyDelete