Install and configure LAMP in ubuntu 12.04

Source: Internet
Author: User

Install and configure LAMP in ubuntu 12.04. install www.2cto.com 1. sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql due to LAMP most operations related to the/var/www directory, for convenience, modify the permission of this directory to be accessible by normal users. 1. sudo chmod 777/var/www/2. phpmyadmin install www.2cto.com 1. during the installation process, sudo apt-get install phpmyadmin requires you to 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 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 1. <? Php 2. $ link = mysql_connect ("localhost", "root", "mysql password"); 3. www.2cto.com 4. if (! $ Link) 5. 6. {7. 8. die ('could not connect :'. mysql_error (); 9. 10 .} 11. 12. else echo "Mysql has been correctly configured"; 13. 14. mysql_close ($ link); 15. 16.?> 4. PHP garbled characters in the browser. Open test in the FireFox browser. if Chinese characters are garbled during php testing, the default language setting problem occurs. The solution is as follows: Open the apache configuration file udo gedit/etc/apache2/apache2.conf, and add the following to the end: addDefaultCharset UTF-8, if still garbled, and then switch the UTF-8 to gb2312. Restart Apache: sudo/etc/init. d/apache2 restart and refresh test. php Chinese Garbled text without the author ustc_dylan

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.