1. Install Lamp
- Sudo apt-Get install apache2 mysql-server mysql-client PhP5 php5-gd
Php5-mysql
Most lamp operations are related to the/var/WWW directory. For convenience, modify the directory permission to be accessible by common users.
- Sudo chmod 777/var/www/
2. phpMyAdmin Installation
- Sudo apt-Get install phpMyAdmin
During the installation process, You must select Web server: apache2 or Lighttpd, select apache2, press the tab key, and click OK. Then, you are required to enter the MySQL Database Password of the database's administrative user.
Then, establish a connection between phpMyAdmin and apache2. Take my example: the WWW directory is in the/var/WWW directory, and the phpMyAdmin directory is in the/usr/share/phpMyAdmin directory. Therefore, run the following command: connect sudo ln-S/usr/share/PHPmyAdmin/var/www.
PhpMyAdmin test: Open http: // localhost/phpMyAdmin in the address bar of the browser.
3. Apache configuration
(1) Enable mod_rewrite module
Terminal command: sudo a2enmod rewrite
(2) restart the Apache server: sudo/etc/init. d/apache2 restart
After Apache is restarted, you can test it and create a file test under the/var/WWW directory. PHP, write code: Save, enter http: // 127.0.0.1/test in the address bar. PHP or http: // localhost/test. PHP. If MySQL is correctly configured, both Apache and MySQL are normal. (Remember to restart the Apache server before testing ).
Test. php
- <? PHP
- $ Link = mysql_connect ("localhost", "root", "MySQL password ");
- If (! $ Link)
- {
- Die ('could not connect: '. mysql_error ());
- }
- Else echo "MySQL has been correctly configured ";
- Mysql_close ($ link );
- ?>
4. php Chinese garbled characters in the browser
If Chinese characters are garbled during the test. php test in the Firefox browser, the default language settings are incorrect. The solution is as follows:
Open the Apache configuration file: Udo gedit/etc/apache2/apache2.conf, add: adddefaultcharset UTF-8 at the end, if still garbled, then switch the UTF-8 to gb2312.
Restart Apache: sudo/etc/init. d/apache2 restart and refresh test. php.