LAMP means Linux + Apache + Mysql + PHP, which enables me to manage my website.

The installed software environment will be used in the Apache2 Web services software, the MySQL5 website back-end database software, as well as PHP5 script interpreted language software, and the system can also be configured to provide FTP services.

1. LAMP installation

sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql

Because most of the operations of LAMP are related to /var/www direction, so it is recommented to modifty the directory as an ordinary user can access.

sudo chmod 777 /var/www/

2. phpmyadmin installation

sudo apt-get install phpmyadmin

During the installation you will be asked to choose Web server: apache2 or lighttpd, you should choose apache2 and press Tab to confirm. Then you will need to enter the Password of the database’s administrative user.
After that, connect the phpmyadmin and apache2, commanly ‘www’ directory is /var/www while ‘phpmyadmin’ is in /usr/share/phpmyadmin directory, so you can use:

sudo ln -s /usr/share/phpmyadmin /var/www

Test phpmyadimin:
enter http://localhost/phpmyadmin in your browser(Firefox is recommented)
Note that the user name is ‘root’ and the password is what you’ve entered just now.

3. Apache settings:
get the mod_rewrite started:

sudo a2enmod rewrite

restart the Apache server:

sudo /etc/init.d/apache2 restart

Note that if you encountered some problems like ‘could not reliably determine the server’s fully qualified domain name’here, you may need to add

# Server Name
ServerName XXXXXX

to your apache2.conf, and you can use command:

gksudo gedit /etc/apache2/apache2.conf

to get access to it

You can make a test to it after the Apache’s restart. Create a new file in the directory / var / www test.php and write the code and save. Enter http://127.0.0.1/test.php or http://localhost/test.php in the address bar, if it shows that ‘mysql has been properly configured’, Apache and mysql are normal. (Remember to restart the Apache server before the test).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
 
    <?php
        $link = mysql_connect("localhost","root","your mysql password");
 
        if (!$link)
 
        {
 
        die('Could not connect: ' . mysql_error());
 
        }
 
        else echo "mysql has been properly configured";
 
        mysql_close($link);
 
        ?>

4.Fix the garbled problem.
For Chinese users, if you encountered garbled problems during the test, you need to modify your apache2.conf. Just add ‘AddDefaultCharset UTF-8’ or ‘AddDefaultCharset gb2312’ to the end of it will be ok.
After that, restart Apache, and refresh the test.php.