Installation:
Apt-Get install apache2
Apt-Get install libapache2-mod-python
Settings:
Mod_python
CD/etc/apache2/mod-enabled/
Sudo ln-S ../mod-available/mod_python.load
Modify the apache2 configuration file
CD/etc/apache2/sites-available/
Sudo gedit default
On Line 10 you shoshould have:
Options indexes followsymlinks Multiviews
AllowOverride authconfig
Order allow, deny
Allow from all
# Uncomment this directive is you want to see apache2's
# Default start page (in/apache2-default) when you go/
# Redirectmatch ^/$/apache2-default/
Change it:
Options indexes followsymlinks Multiviews
AllowOverride authconfig
Order allow, deny
Allow from all
Addhandler mod_python. py
Pythonhandler mod_python.publisher
Pythondebug on
# Uncomment this directive is you want to see apache2's
# Default start page (in/apache2-default) when you go/
# Redirectmatch ^/$/apache2-default/
Restart apache2
/Etc/init. d/apache2 restart
Test:
Gedit/var/www/test. py
Content:
Def index (req ):
Return "test successful ";
Supplement:
8.04 install lamp supplement and Python environment Configuration
Lamp (Linux + Apache + MySQL + PERL/PHP/Python) is an open Resource Network Development Platform Based on Linux, Apache, MySQL, and PHP (Python). It is called PHP (Python) prime combination of development. I have previously written an article on building lamp and Wordpress on ubuntu7.04. After I change to 8.04, there are some minor steps, and this time I want to configure the python environment (not Django. All the steps involved in this article are omitted if there are related commands in that article.
According to the above method, download lamp server, we do not need to use text to set the password, the installation to the middle of the system will automatically pop up a dialog box for setting the mysql-server-5.0, this includes the user name and password.
After phpMyAdmin is installed normally, Use http: // localhost to experiment. The it works interface will appear. Enable the mod_rewrite module.
To enable apacheto support .htm. html. php, run the following command to open the file:
sudo gedit /etc/apache2/apache2.conf
Add
Addtype application/X-httpd-PHP. php. htm. html
In addition
Adddefacharcharset UTF-8
It can solve the browsing garbled problem of Firefox. According to the situation, the UTF-8 here can also be replaced by gb2312.
If you want to use WordPress, see a Title = "permanent link
Build your own lamp and Wordpress "rel =" bookmark "on ubuntu7.04"
Href = "../2007/04/29/how-to-lamp-Wordpress/"> build your own lamp and
Other configurations of apache2.conf in WordPress
Python Configuration:
This time, I added lamp support for python by following the steps below:
sudo apt-get install libapache2-mod-python
Install mod-Python and add the following content to the Apache configuration file/etc/apache2/httpd. conf:
Loadmodule python_module/usr/lib/apache2/modules/mod_python.so
The installation path is mod_python. Then use
Sudo apache2ctl restart
Load the mod_python module into Apache.
Now the mod_python module has been activated. The next step is to start it for the python program. Find the sites-available/directory under your Apache configuration Directory, which contains a default file, open it, and find the lines in the root directory of your server. The approximate format is as follows:
Options indexes followsymlinks
AllowOverride none
Order allow, deny
Allow from all
Modify
Addhandler mod_python. py
Pythonhandler mod_python.publisher
Pythondebug on
Options indexes followsymlinks
AllowOverride none
Order allow, deny
Allow from all
Before that, modify the position of cgi-bin in the ScriptAlias line in the file, replace it with the path where the CGI script is stored, and add a line in the file.
Addhandler CGI-script. cgi. py
Restart Apache and the environment is configured. Note that the py script should be placed in the cgi-bin position of the ScriptAlias line.
Last friendly reminder, is in failure, see the document/usr/share/doc/apache2-common/readme. Debian