Ubuntu under Lamp Environment Configuration tutorial (Linux) _linux

Source: Internet
Author: User
Tags php and mysql import database mysql command line phpmyadmin

It is said to do a good job of lamp is already equivalent to a mid-level PHP program ape level, of course, your PHP will be able to do, and then do a variety of frameworks. In fact, this thing is not mysterious, very simple. Even simpler than windows, all kinds of variables automatically help you do a good job. Your fear is largely the result of your ignorance.

Recommended first through the phpnow1.5.6 in Windows a good PHP environment, and then through the Mysql_gui_tools graphics MySQL, PHP works, the PHP project, MySQL database import Export to Linux run, Linux is purely a running project, not a development.

I. The download, installation and configuration of lamp

After you install Ubuntu, the installation of Ubuntu specifically please see: "Graphic explanation ubuntu 12.04 installation Process" (Click to open the link), plug the network cable, and then follow the following steps to install the remaining amp:

1, Ctrl+alt+t Open the terminal, enter the following instructions:

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


2, press ENTER, input y, waiting for a short time, only 35M things quickly under the good, not the foreign site, is the normal speed download. If there is an error, it is your Ubuntu hardware driver is not ready, the virtual machine is your VMware tools and so do not do a good job, reload after the problem is solved.


3, then is about 15 minutes of waiting, see Speed bar. Directly in the brush screen.


4, Midway requires you to set the password of MySQL, this password remember well. Requirements set two, one is Mysql-server, the other is mysql-client, but also want you to determine the password, a total of four times, the key is in your network engineering connection database password is the same. We all got a root.


5, then continue to wait for its download, installation completed.


6, because most of lamp operation and/var/www directory-related, in order to facilitate, modify the directory permissions for ordinary users to access. In the terminal, continue to enter the following command:

sudo chmod 777/var/www/

After the loss, all sudo command to password, annoying!

7, then also install a component phpMyAdmin, enter the following statement, press Y to install:

sudo apt-get install phpMyAdmin

8, in the installation process will require the choice of Web Server:apache2 or LIGHTTPD, the default selection apache2 click OK. That's A for lamp!


9, the agreement what, see all do not have to look, must be.


10, and then set the phpMyAdmin password, continue to root.


11, then to establish phpMyAdmin and apache2 connection, enable the Apache mod_rewrite module, and restart Apache2 complete configuration, so continue to enter the following statement:

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


12, and then set a good apache2 default code, otherwise garbled. Enter the following instruction at the terminal:

sudo gedit/etc/apache2/apache2.conf


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


14, then enter the download instructions to restart Apache, that is, just configure phpMyAdmin to restart the apache2 server instructions, to here the whole lamp has been built!

Sudo/etc/init.d/apache2 restart


Second, test and Hello World

After the lamp is ready, it is best to restart Ubuntu and do the following test, in fact, do not reboot is not a problem. The most feared is that some of them are due to the lack of reboot caused by the small problems occurred.

1, directly open Ubuntu file system, into the var/www, in the right key-> create a new document-> blank document. Create a new blank document. Later your PHP project will be copied directly to here. can be carried out.


2. Name this blank document as test.php


3, open test.php in the input of the following things, in fact, is a simple PHP connection to the MySQL program:

<?php
$link = mysql_connect ("localhost", "root", "MySQL password");
if (! $link) {
 die (' Could not connect: '. Mysql_error ());
}
else echo "MySQL is properly configured";
Mysql_close ($link);
? >

Used to verify that PHP and MySQL are connected successfully, save exit.


4, finally, open the left test of the Ubuntu Quick Launch bar, open its own wild Fox Zen Browser, in the address bar input http://127.0.0.1/test.php You can see the "MySQL has been properly configured" output. Obviously, if you copy the PHP project a folder to Var/www, then enter http://127.0.0.1/a/in the Address bar.


5, in addition, at this time because MySQL has been installed, at the same time automatically configured, at the Ubuntu terminal, enter the following instructions to enter the MySQL:

Mysql-u root-p


What to do after that, you know. Whether it's creating a user or not, see "MySQL" to modify the root password and create an account with the same permissions as root (click to open the link), or to put your project on the windows to come in, specifically see the "MySQL command line export and Import Database" (Click to open the link), Do what you want to do anyway.

As for the installation of PHP in Ubuntu Ide--aptana, the pro-test found no idea why it was done to get it all wrong. Mysql_gui_tools is also engaged in the same problem.

Therefore, the development, or choose their most comfortable system. Anyway, Windows development and Linux are not writing the same statement, there is no professional unprofessional.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.