Differences between revisions 18 and 19
Revision 18 as of 2009-03-16 03:36:32
Size: 3452
Editor: anonymous
Comment: converted to 1.6 markup
Revision 19 as of 2009-05-03 14:51:41
Size: 3431
Editor: FranklinPiat
Comment: drop "libmysqlclient15-dev", since "mysql-client" depend on it.
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
 # aptitude install mysql-server mysql-client libmysqlclient15-dev  # aptitude install mysql-server mysql-client

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:

 # /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

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:

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 or the name 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.