Article Title: install and configure LAMP Using apt. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
This article introduces how to install Apache, Mysql, and PHP using apt-get, and then configure and test the entire process of building LAMP. I hope that as a beginner of Linux, I will come to know about Linux by using the most widely used Production System on Linux.
1. system upgrade before installation
To install the three software in apt-get mode, it is best to run the following command to upgrade your system, I can only install mysql5 + Apache2 + PHP5 after upgrading.
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. Use apt-get to install Apache, Mysql, and PHP
| # 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. Because I did not take this step during the first installation, I think it is the same as that in win, but I do not need to set it first. However, when I log on with the root account without a password under 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 "123456 ″;
'123' is the root password and can be set as needed, but it is best to set a security point.
# Mysql> \ q exit mysql
Mysql configuration file-my. cnf :( path:/etc/mysql/my. cnf)
# Sudo gedit/etc/mysql/my. conf # edit my. conf
Apache2 configuration file-apache2.conf (Path:/etc/apache2/apache2.conf)
# Sudo gedit/etc/apache2.conf # edit apache22.conf
PHP configuration file-php. ini :( path:/etc/php5/apache2/php. ini)
# Sudo gedit/etc/php5/apache2/php. ini # edit php. ini
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'] = "; |
Changed:
| $ Cfg ['servers'] [$ I] ['Password'] = '000000 ′; |
123456 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/ |