Install and configure LAMP in Ubuntu12.04

Source: Internet
Author: User
Tags website server
I am a newbie in Linux. I want to install a Ubuntu Linux server and use the LAMP package on this server to run my own website. LAMP kit is "Linux + Apache + Mysql + PHP these four software constitute a set of tools that can run the website software ." Through the installation attempt, I have gained some successful installation and configuration experience. Through this article, I will learn from the attackers of the Linux website server system. Apache2 web page service will be used in the software environment of this website.

I am a beginner in Linux. I want to install a Linux Server of Ubuntu 12.04 and use the LAMP package on this server to run my own website. LAMP kit is "Linux + Apache + Mysql + PHP these four software constitute a set of tools that can run the website software ." Through the installation attempt, I have gained some successful installation and configuration experience. Through this article, I will learn from the attackers of the Linux website server system. In this installation of website software environment, Apache2 web service software, MySQL5 website background database software, and PHP5 interpreter language software will be used. The configured system can also provide FTP services.

1. Install LAMP

  1. 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.

  1. Sudo chmod 777./Var/Www/
2. phpmyadmin Installation

  1. 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

  1. <?Php
  2. $Link = Mysql_connect("Localhost","Root","Mysql password");

  3. If (!$Link)

  4. {

  5. Die('Could not connect :' . Mysql_error());

  6. }

  7. Else Echo "Mysql has been correctly configured";

  8. Mysql_close($Link);

  9. ?>
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.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.