[Linux] configure the LAMP environment in Ubuntu

Source: Internet
Author: User
Tags php and mysql import database mysql export database

[Linux] configure the LAMP environment in Ubuntu

It is said that a good job of LAMP, that is, Linux + Apache + Mysql + php, is already equivalent to an intermediate php program level. Of course, you need to have a good job of php, and then you need to do a good job of various frameworks. In fact, this is not mysterious, it is very simple. It is even simpler than Windows, and various variables will automatically help you. Your fear mainly comes from your ignorance.

We recommend that you first build a php environment in one click on Windows through phpnow1.5.6, then write the php project in the graphical Mysql using Mysql_Gui_Tools, and import and export the php project and Mysql database to Linux for running, linux is purely a running project without development.

1. Download, install and configure LAMP

After you install Ubuntu, see [Linux] Ubuntu 12.04 download and installation (click to open the link) to plug in the network cable, follow these steps to install the remaining AMP:

1. Press Ctrl + Alt + T to open the terminal and enter the following command:

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


 

2. Press enter and enter Y. Wait a short time before the 35 m items are ready soon. It is normal to download the items at the network speed instead of from a foreign site. If an error occurs, it means that your Ubuntu hardware driver is not properly configured, the virtual machine is that your VMware Tools and so on are not well done, and the problem is solved after reinstallation.

3. Wait about 15 minutes later. Check the network speed. Directly on the screen.

4. You are required to set the mysql password in the middle. Remember this password. You must set two parameters: mysql-server and mysql-client. You must also confirm the password four times in total, the key is that your network project can connect to the database with the same password. All of them are rooted.

5. Wait until the download and installation are complete.

6. Most LAMP operations are related to the/var/www directory. For convenience, modify the directory permission to be accessible by common users. Enter the following command on the terminal:

sudo chmod 777 /var/www/
After the password is entered, all sudo commands require a password!

7. Install the phpmyadmin component. Enter the following statement and press Y to install the component:

sudo apt-get install phpmyadmin

8. During the installation process, You must select Web server: apache2 or lighttpd. By default, select apache2 and press OK. LAMP's!

9. You don't need to look at the agreement or anything. It must be.

10. Set the phpmyadmin password and continue to root.

11. Establish a connection between phpmyadmin and apache2, enable the Apache mod_rewrite module, and restart Apache2 to complete the configuration. Therefore, enter the following statement:

sudo ln -s /usr/share/phpmyadmin /var/wwwsudo a2enmod rewritesudo /etc/init.d/apache2 restart

12. Set the default apache2 encoding later. Otherwise, garbled characters will occur. Enter the following command on the terminal:

sudo gedit /etc/apache2/apache2.conf

13. In the pop-up text editing window, pull to the last line and enter the following adddefacharcharset UTF-8 to save and exit. In fact,/etc/apache2/apache2.conf is the configuration file of Apache2!

14. Then enter the download command to restart Apache, that is, the command for configuring phpmyadmin to restart the apache2 server. Here the entire LAMP is ready!

 

sudo /etc/init.d/apache2 restart

2. Testing and Hello World

After LAMP is complete, restart Ubuntu and perform the following tests. In fact, there is no problem if you do not restart Ubuntu. Some of them are most afraid of minor problems caused by no restart.

1. directly open the Ubuntu file system, go to var/www, right-click it, and choose create new document> blank document. Create a blank document. In the future, your php project will be directly copied here. You can run the command.

2. Name this blank document test. php.

3. Open test. php and enter the following in it, which is actually a simple php connection to the Mysql program:

 

 
It is used to check whether the connection between php and Mysql is successful and save and exit.

 

4. Finally, open the Ubuntu Quick Start bar in the left test, open the built-in wild fox Zen browser, and enter http: // 127.0.0.1/test in the address bar. php shows the output of "Mysql has been correctly configured. Apparently, if you copy the folder of php Project a to var/www, enter http: // 127.0.0.1/a/in the address bar /..

5. In addition, because Mysql has been installed and is automatically configured, enter the following command on the Ubuntu terminal to enter mysql:

 

mysql -u root -p

 

What to do later, you know. Whether creating a user or not, see [Mysql] modifying the root password and creating an account with the same permissions as root (click to open the link ), you can also import your project on Windows. For details, see [Mysql] MySQL export database and import database (click to open the link). Do whatever you want.

As for the php IDE-Aptana installed in Ubuntu, I did not know why it was hard to come up. Mysql_GUI_tools has such problems.

Therefore, we should select the most appropriate system for development. Anyway, Windows development and Linux do not write the same statement, and there is no professional or not professional.

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.