# LAMP Applications

## Overview

LAMP installations (Linux + Apache + MySQL + PHP) are a popular setup for Ubuntu servers. There is a plethora of Open Source applications written using the LAMP application stack. Some popular LAMP applications are Wiki's, Content Management Systems, and Management Software such as phpMyAdmin.

One advantage of LAMP is the substantial flexibility for different database, web server, and scripting languages. Popular substitutes for MySQL include Posgresql and SQLite. Python, Perl, and Ruby are also frequently used instead of PHP.

The traditional way to install most LAMP applications is:

- Download an archive containing the application source files.

- Unpack the archive, usually in a directory accessible to a web server.

- Depending on where the source was extracted, configure a web browser to serve the files.

- Configure the application to connect to the database.

- Run a script, or browse to a page of the application, to install the database needed by the application.

- Once the steps above, or similar steps, are completed you are ready to begin using the application.

A disadvantage of using this approach is that the application files are not placed in the file system in a standard way, which can cause confusion as to where the application is installed. Another larger disadvantage is updating the application. When a new version is released, the same process used to install the application is needed to apply updates.

Fortunately, a number of LAMP applications are already packaged for Ubuntu, and are available for installation in the same way as non-LAMP applications. Depending on the application some extra configuration and setup steps may be needed, however.

This section covers howto install and configure the Wiki applications MoinMoin, MediaWiki, and the MySQL management application phpMyAdmin.

A Wiki is a website that allows the visitors to easily add, remove and modify available content easily. The ease of interaction and operation makes Wiki an effective tool for mass collaborative authoring. The term Wiki is also referred to the collaborative software.

## Moin Moin

MoinMoin is a Wiki engine implemented in Python, based on the PikiPiki Wiki engine, and licensed under the GNU GPL.

### Installation

To install MoinMoin, run the following command in the command prompt:

    sudo apt-get install python-moinmoin

You should also install apache2 web server. For installing apache2 web server, please refer to sub-section in section.

### Configuration

For configuring your first Wiki application, please run the following set of commands. Let us assume that you are creating a Wiki named mywiki:

    cd /usr/share/moin
    sudo mkdir mywiki
    sudo cp -R data mywiki
    sudo cp -R underlay mywiki
    sudo cp server/moin.cgi mywiki
    sudo chown -R www-data.www-data mywiki
    sudo chmod -R ug+rwX mywiki
    sudo chmod -R o-rwx mywiki

Now you should configure MoinMoin to find your new Wiki mywiki. To configure MoinMoin, open `/etc/moin/mywiki.py` file and change the following line:

    data_dir = '/org/mywiki/data'

to

    data_dir = '/usr/share/moin/mywiki/data'

Also, below the data_dir option add the data_underlay_dir:

    data_underlay_dir='/usr/share/moin/mywiki/underlay'

If the `/etc/moin/mywiki.py` file does not exists, you should copy `/etc/moin/moinmaster.py` file to `/etc/moin/mywiki.py` file and do the above mentioned change.

If you have named your Wiki as my_wiki_name you should insert a line ("my_wiki_name", r".*") in `/etc/moin/farmconfig.py` file after the line ("mywiki", r".*").

Once you have configured MoinMoin to find your first Wiki application mywiki, you should configure apache2 and make it ready for your Wiki application.

You should add the following lines in `/etc/apache2/sites-available/default` file inside the <VirtualHost *> tag:

    ### moin
      ScriptAlias /mywiki "/usr/share/moin/mywiki/moin.cgi"
      alias /moin_static184 "/usr/share/moin/htdocs"
      <Directory /usr/share/moin/htdocs>
      Order allow,deny
      allow from all
      </Directory>
    ### end moin

Adjust the "moin_static184" in the alias line above, to the moinmoin version installed.

Once you configure the apache2 web server and make it ready for your Wiki application, you should restart it. You can run the following command to restart the apache2 web server:

    sudo /etc/init.d/apache2 restart

### Verification

You can verify the Wiki application and see if it works by pointing your web browser to the following URL:

    http://localhost/mywiki

You can also run the test command by pointing your web browser to the following URL:

    http://localhost/mywiki?action=test

For more details, please refer to the MoinMoin web site.

### References

- For more information see the moinmoin Wiki.

- Also, see the Ubuntu Wiki MoinMoin page.

## MediaWiki

MediaWiki is an web based Wiki software written in the PHP language. It can either use MySQL or PostgreSQL Database Management System.

### Installation

Before installing MediaWiki you should also install Apache2, the PHP5 scripting language and Database a Management System. MySQL or PostgreSQL are the most common, choose one depending on your need. Please refer to those sections in this manual for installation instructions.

To install MediaWiki, run the following command in the command prompt:

    sudo apt-get install mediawiki php5-gd

For additional MediaWiki functionality see the mediawiki-extensions package.

### Configuration

The Apache configuration file `mediawiki.conf` for MediaWiki is installed in `/etc/apache2/conf.d/` directory. You should uncomment the following line in this file to access MediaWiki application.

    # Alias /mediawiki /var/lib/mediawiki

After you uncomment the above line, restart Apache server and access MediaWiki using the following url:

    http://localhost/mediawiki/config/index.php

Please read the Checking environment... section in this page. You should be able to fix many issues by carefully reading this section.

Once the configuration is complete, you should copy the `LocalSettings.php` file to `/etc/mediawiki` directory:

    sudo mv /var/lib/mediawiki/config/LocalSettings.php /etc/mediawiki/

You may also want to edit `/etc/mediawiki/LocalSettings.php` adjusting:

    ini_set( 'memory_limit', '64M' );

### Extensions

The extensions add new features and enhancements for the MediaWiki application. The extensions give wiki administrators and end users the ability to customize MediaWiki to their requirements.

You can download MediaWiki extensions as an archive file or checkout from the Subversion repository. You should copy it to `/var/lib/mediawiki/extensions` directory. You should also add the following line at the end of file: `/etc/mediawiki/LocalSettings.php`.

    require_once "$IP/extensions/ExtentionName/ExtentionName.php";

### References

- For more details, please refer to the MediaWiki web site.

- The MediaWiki Administrators’ Tutorial Guide contains a wealth of information for new MediaWiki administrators.

- Also, the Ubuntu Wiki MediaWiki page is a good resource.

## phpMyAdmin

phpMyAdmin is a LAMP application specifically written for administering MySQL servers. Written in PHP, and accessed through a web browser, phpMyAdmin provides a graphical interface for database administration tasks.

### Installation

Before installing phpMyAdmin you will need access to a MySQL database either on the same host as that phpMyAdmin is installed on, or on a host accessible over the network. For more information see . From a terminal prompt enter:

    sudo apt-get install phpmyadmin

At the prompt choose which web server to be configured for phpMyAdmin. The rest of this section will use Apache2 for the web server.

In a browser go to http://servername/phpmyadmin, replacing serveranme with the server's actual hostname. At the login, page enter root for the username, or another MySQL user if you any setup, and enter the MySQL user's password.

Once logged in you can reset the root password if needed, create users, create/destroy databases and tables, etc.

### Configuration

The configuration files for phpMyAdmin are located in `/etc/phpmyadmin`. The main configuration file is `/etc/phpmyadmin/config.inc.php`. This file contains configuration options that apply globally to phpMyAdmin.

To use phpMyAdmin to administer a MySQL database hosted on another server, adjust the following in `/etc/phpmyadmin/config.inc.php`:

    $cfg['Servers'][$i]['host'] = 'db_server';

Replace db_server with the actual remote database server name or IP address. Also, be sure that the phpMyAdmin host has permissions to access the remote database.

Once configured, log out of phpMyAdmin and back in, and you should be accessing the new server.

The `config.header.inc.php` and `config.footer.inc.php` files are used to add a HTML header and footer to phpMyAdmin.

Another important configuration file is `/etc/phpmyadmin/apache.conf`, this file is symlinked to `/etc/apache2/conf.d/phpmyadmin.conf`, and is used to configure Apache2 to serve the phpMyAdmin site. The file contains directives for loading PHP, directory permissions, etc. For more information on configuring Apache2 see .

### References

- The phpMyAdmin documentation comes installed with the package and can be accessed from the phpMyAdmin Documentation link (a question mark with a box around it) under the phpMyAdmin logo. The official docs can also be access on the phpMyAdmin site.

- Also, Mastering phpMyAdmin is a great resource.

- A third resource is the phpMyAdmin Ubuntu Wiki page.