Differences between revisions 26 and 27
Revision 26 as of 2013-01-12 20:31:53
Size: 5761
Comment: minor fixes
Revision 27 as of 2013-04-27 16:26:27
Size: 5840
Comment: added link to it translation + minor cosmetic fixes
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
~-[[DebianWiki/EditorGuide#traduction|Translation(s)]] : [[LaMp|English]] - [[fr/Lamp|Français]] - [[zh_CN/Lamp|简体中文]]-~ ~-[[DebianWiki/EditorGuide#traduction|Translation(s)]] : English - [[fr/Lamp|Français]] - [[it/LaMp|Italiano]] - [[zh_CN/Lamp|简体中文]]-~
Line 4: Line 4:
= LAMP, Linux Apache Mysql PHP = = LAMP, Linux Apache MySQL PHP =
Line 7: Line 7:
 * .. and Apache can be replaced by lighttpd !  * ... and Apache can be replaced by lighttpd!
Line 18: Line 18:
=== mysql === === MySQL ===
Line 24: Line 24:
Immediately after you have installed the mysql server, you should change its root password:
* This step is unnecessary for Lenny since you will be asked to input mysql root user's password during installation
Immediately after you have installed the MySQL server, you should change its root password:
 * This step is unnecessary for Lenny since you will be asked to input MySQL root user's password during installation
Line 45: Line 45:
Configure Apache module userdir in /etc/apache2/mods-enabled/userdir.conf Configure Apache module userdir in {{{/etc/apache2/mods-enabled/userdir.conf}}}
Line 75: Line 75:
If you get a ''Forbidden'' error when accessing home folder through apache check /home/username has permissions drwxr-xr-x. If the permissions are wrong correct them as such: If you get a ''Forbidden'' error when accessing home folder through Apache check {{{/home/username}}} has permissions drwxr-xr-x. If the permissions are wrong correct them as such:
Line 79: Line 79:
To be able to serve PHP (PHP needs to be installed as per instructions) check /etc/apache2/mods-available/php5.conf is correct: To be able to serve PHP (PHP needs to be installed as per instructions) check that {{{/etc/apache2/mods-available/php5.conf}}} is correct:
Line 98: Line 98:
Place some web content in ~/public_html and see the results at http://localhost/~username Place some web content in {{{~/public_html}}} and see the results at {{{http://localhost/~username}}}
Line 122: Line 122:
=== test php ===
To test the php interface, edit the file /var/www/apache2-default/test.php:
=== Test PHP ===
To test the PHP interface, edit the file {{{/var/www/apache2-default/test.php}}}:
Line 131: Line 131:
Afterwards, point your browser to http://SERVERIP/apache2-default/test.php to start using it. Afterwards, point your browser to {{{http://<SERVERIP>/apache2-default/test.php}}} to start using it.
Line 133: Line 133:
=== phpmyadmin === === phpMyAdmin ===
Line 135: Line 135:
Probably you also want to install phpmyadmin for easy configuration: Probably you also want to install phpMyAdmin for easy configuration:
Line 140: Line 140:
To have access to phpMyAdmin on your website (i.e. http://example.com/phpmyadmin/ ) all you need to do is include the following line in /etc/apache2/apache2.conf (needed only before Squeeze, since 6.0 it will be linked by the package install script to {{{/etc/apache2/conf.d/phpmyadmin.conf -> ../../phpmyadmin/apache.conf}}} automatically): To have access to phpMyAdmin on your website (i.e. {{{http://example.com/phpmyadmin/}}} ) all you need to do is include the following line in {{{/etc/apache2/apache2.conf}}} (needed only before Squeeze, since 6.0 it will be linked by the package install script to {{{/etc/apache2/conf.d/phpmyadmin.conf -> ../../phpmyadmin/apache.conf}}} automatically):
Line 148: Line 148:
Go to http://SERVERIP/phpmyadmin/ to start using it. (use the IP or name of your pc/server or the name instead of SERVERIP. (The localhost IP is always 127.0.0.1)). Go to {{{http://<SERVERIP>/phpmyadmin/}}} to start using it. (Use the IP or name of your PC/server instead of <SERVERIP> (The localhost IP is always 127.0.0.1).)
Line 151: Line 151:
A usual issue with php configuration is to enable mysql. Just edit the file and uncomment the following line (tip: search for mysql) A usual issue with PHP configuration is to enable MySQL. Just edit the file and uncomment the following line (tip: search for mysql)
Line 157: Line 157:
=== MySql : /etc/mysql/my.cnf ===
You can find configuration examples in /usr/share/doc/mysql-server/examples
=== MySQL : /etc/mysql/my.cnf ===
You can find configuration examples in {{{/usr/share/doc/mysql-server/examples}}}

Translation(s) : English - Français - Italiano - ?简体中文


LAMP, Linux Apache MySQL PHP

  • Some people argue that PHP can be replaced with Python or Perl.

  • ... and Apache can be replaced by lighttpd!

Installation

Before starting the installation, make sure your distribution is up to date (the '#' indicates that you should do this as root):

 # aptitude update && aptitude upgrade

MySQL

Next install mysql using the following command:

 # aptitude install mysql-server mysql-client

Immediately after you have installed the MySQL server, you should change its root password:

  • This step is unnecessary for Lenny since you will be asked to input MySQL root user's password during installation

 # /usr/bin/mysqladmin -u root password 'enter-your-good-new-password-here'

You must never use your root account and password when running databases. The root account is a privileged account which should only be used for admin procedures. You will need to create a separate user account to connect to your MySQL databases from a PHP script. You can add users to a MySQL database by using a control panel like phpMyAdmin to easily create or assign database permissions for users.

apache2

The web server can be installed as follows:

 # aptitude install apache2 apache2-doc

Configuring user directories for Apache Web Server

Enable module

# a2enmod userdir

Configure Apache module userdir in /etc/apache2/mods-enabled/userdir.conf as follows:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        <Directory /home/*/public_html>
                AllowOverride All
                Options MultiViews Indexes SymLinksIfOwnerMatch
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                </Limit>
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all
                </LimitExcept>
        </Directory>
</IfModule>

Create directory as user (not as root):

$mkdir /home/$USER/public_html

Change group as root (substitute your username) and restart web server:

# chgrp www-data /home/<username>/public_html
# service apache2 restart

If you get a Forbidden error when accessing home folder through Apache check /home/username has permissions drwxr-xr-x. If the permissions are wrong correct them as such:

# chmod 755 /home/<username>

To be able to serve PHP (PHP needs to be installed as per instructions) check that /etc/apache2/mods-available/php5.conf is correct:

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_value engine Off
    #    </Directory>
    #</IfModule>
</IfModule>

Place some web content in ~/public_html and see the results at http://localhost/~username

The "P" part

Installing the PHP subset of LAMP in Debian is quite simple, you just type this as root in an console (the # is the root prompt symbol):

 # aptitude install php5 php5-mysql libapache2-mod-php5

If you prefer Perl, then you might consider:

 # aptitude install perl libapache2-mod-perl2

If you prefer Python, then you might consider:

 # aptitude install python libapache2-mod-python

Configuration

Apache2 configuration file: /etc/apache2/apache2.conf

You can edit this file when needed, but for most simple applications, this should not be necessary as most stuff is now done using conf.d.

Test PHP

To test the PHP interface, edit the file /var/www/apache2-default/test.php:

 # nano /var/www/apache2-default/test.php

and insert the following code.

<?php phpinfo(); ?>

Afterwards, point your browser to http://<SERVERIP>/apache2-default/test.php to start using it.

phpMyAdmin

Probably you also want to install phpMyAdmin for easy configuration:

 # aptitude install phpmyadmin

To have access to phpMyAdmin on your website (i.e. http://example.com/phpmyadmin/ ) all you need to do is include the following line in /etc/apache2/apache2.conf (needed only before Squeeze, since 6.0 it will be linked by the package install script to /etc/apache2/conf.d/phpmyadmin.conf -> ../../phpmyadmin/apache.conf automatically):

Include /etc/phpmyadmin/apache.conf

Restart Apache:

 # /etc/init.d/apache2 restart

Go to http://<SERVERIP>/phpmyadmin/ to start using it. (Use the IP or name of your PC/server instead of <SERVERIP> (The localhost IP is always 127.0.0.1).)

PHP: /etc/php5/apache2/php.ini

A usual issue with PHP configuration is to enable MySQL. Just edit the file and uncomment the following line (tip: search for mysql)

extension=mysql.so

Note that this should not be needed anymore as conf.d is now used.

MySQL : /etc/mysql/my.cnf

You can find configuration examples in /usr/share/doc/mysql-server/examples

See also

This page is based largely on http://linux.justinhartman.com/Setting_up_a_LAMP_Server.