Configure the LAMP environment in Ubuntu

Source: Internet
Author: User
My experience is: after MYSQL is successfully installed, you must first set a password for it. This step is indispensable. (In the beginning, the installation fails due to greed.) This article only represents my personal opinions and experiences, and may be one-sided and incorrect. Please criticize and correct it, if you have any questions, let's discuss them !! 1. to use apt-get for installation, it is best, or you must first run the following command to upgrade your system. Instead, you can install mysql5 + Apache2 + PHP5 only after the upgrade. I run before the upgrade

My experience is: after MYSQL is successfully installed, you must first set a password for it. This step is indispensable. (In the beginning, the installation fails due to the lazy figure)
This article only represents my personal opinions and experiences. It may be one-sided and incorrect. Please criticize and correct the article and discuss it with you if you have any questions !!

1. to use apt-get for installation, it is best, or you must first run the following command to upgrade your system. Instead, you can install mysql5 + Apache2 + PHP5 only after the upgrade.
It is useless to run sudo apt-get install apache2 php5 mysql-server before the upgrade. If the source you are looking for is poor or your network is unstable, you may not be able to upgrade it. In this case, you may not be able to install some software using apt-get.
Sudo apt-get update
Sudo apt-get dist-upgrade

2. installation:
Sudo apt-get install mysql-server
Install mysql5
Sudo apt-get install apache2
Install apache2
Sudo apt-get install php5
Install php5
Sudo apt-get install php5-mysql
Install the mysql module of php
Sudo apt-get install php5-gd
Install the GD library
When running the above command, you can pay attention to the libapache2-mod-auth-mysql (installation of apache2 may be installed on) and libapache2-mod-php5, if you see installed on it, no need to install it separately.

3. Configuration:

The MYSQL we just installed has only one default root user, and there is no password. At this time, we must set a password for MYSQL. I personally think it is necessary. This is because I did not take this step during the first installation. I think it is the same as that in win, but you do not need to set it first. However, when I log in with the root account without a password at http: // 127.0.0.1/phpmyadmin, it will not succeed!
Terminal input:
Mysql-u root
Mysql> grant all privileges on *. * TO root @ localhost identified by "www.linuxidc.com ";
'Www .linuxidc.com 'is the root password and can be set freely, but it is best to set a security point.
Mysql> \ q exit mysql

Mysql configuration file-my. cnf :( path:/etc/mysql/my. cnf)
Run the command: sudo gedit/etc/mysql/my. cnf to edit it.

Apache2 configuration file-apache2.conf (Path:/etc/apache2/apache2.conf)
Run sudo gedit/etc/apache2.conf to edit

PHP configuration file-php. ini :( path:/etc/php5/apache2/php. ini)
Run the command: sudo gedit/etc/php5/apache2/php. ini to edit it.

At this time, these three files do not need to be edited. For security reasons and optimization, you must edit them. For more details, visit other materials !!

4. Install phpmyadmin
Sudo apt-get install phpmyadmin
After the installation is complete, you can test: http: // 127.0.0.1/phpmyadmin. When the page is displayed, do not log on. Wait until you change the PHPMYADMIN configuration file (config. inc. php.
Terminal input: sudo gedit/etc/phpmyadmin/config. inc. php
Find $ cfg ['servers'] [$ I] ['Password'] = '';
Change to: $ cfg ['servers'] [$ I] ['Password'] = 'www .linuxidc.com ';
'Www .linuxidc.com 'is the mysql password just set.

5. At this time, it is best to restart the computer. (someone said this on the Internet, because this is the second installation.) Open the browser http: // localhost/phpmyadmin/
Enter the root user name, enter the new password, and then execute
We can see the amiable phpmyadmin appearance under win.

Summary:
Operation Command of apache2:
Start: sudo/etc/init. d/apache2 start
Restart: sudo/etc/init. d/apache2 restart
Close: sudo/etc/init. d/apache2 stop
Default home directory of apache2:/var/www/

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.