Install the lamp environment in ubuntu

Source: Internet
Author: User
Tags fully qualified domain name
1. install 1. first install the SSHsudoapt-getinstallssh2. install MySQL (although the latest version is 5.1, but only installed version 5.0) sudoapt-getinstallmysql-server-5.03. install Apachesudoapt-getinstallapache24. install PHPs...

I. Installation
1. first install SSH
Sudo apt-get install ssh
2. install MySQL (although the latest version is 5.1, only MySQL 5.0 can be installed)
Sudo apt-get install mysql-server-5.0
3. install Apache
Sudo apt-get install apache2
4. install PHP
Sudo apt-get install php5 libapache2-mod-php5
5. restart Apache
Sudo/etc/init. d/apache2 restart
6. install phpMyAdmin
Sudo apt-get install phpmyadmin
Another method: install LAMP
Select edit in the new software package manager -- mark the software package with the task group
In the displayed window, select lamp server and then confirm
In the main window, click the application button of red/Palladium
Well, the next step is to wait until the new version is automatically downloaded and installed.
You will be prompted to enter the mysql root user password.
II. test
1. test Apache
Enter http: // localhost/to check whether the words It works appear.
2. test MySQL
Input: sudo netstat-tap | grep mysql
You can see rows similar to the following:
Tcp 0 0 localhost. localdomain: mysql *: * LISTEN-
If the server cannot run properly, run the following command to start it: sudo/etc/init. d/mysql restart
3. test PHP
The root directory of Ubuntu Apache is located in/var/www.
Add a test file test. php file to the file.
Phpinfo ();
?>
Enter http: // localhost/test. php again in the browser. if the php information page is displayed, the PHP installation is successful.

III. configuration

1> apache configuration file path/etc/apache2/apache2.conf
2> php. ini path/etc/php5/apache2/php5.ini
3> mysql configuration file path/etc/mysql/my. cnf
4> phpmyadmin configuration file path/etc/phpmyadmin/apache. conf
5> website root directory/var/www

1. configure PHP5

There is nothing to say about it. the default time zone is shown below as needed.
; Default. timezone = PRC (remove the semicolon above to represent China)

2. configure mysql

Sudo gedit/etc/mysql/my. cnf
Note that only local access to the database is allowed by default.
Bind-address 127.0.0.1
This statement only allows local access. for example, if you need access from other machines, comment out this sentence #.

3. configure phpmyadmin

Phpmyadmin is not installed under/var/www by default, but under/usr/share/phpmyadmin. you can copy phpmyadmin or create a link on the Internet, then copy the link (not tried ). I personally think it is not necessary to copy it. If you do not copy the previous configuration, you do not need to change the next configuration.
Then run:
Sudo gedit/etc/phpmyadmin/apache. conf
Change the path of the following two names to/var/www/phpmyadmin
Alias/phpmyadmin/usr/share/phpmyadmin

4. modify the Apache website root directory DocumentRoot in ubuntu
In the/etc/apache2/sites-enabled/directory, you can see a 000-default
Open such a sentence
DocumentRoot/var/www
Change path
Restart the Apache2 service.
Operator: common commands

1. restart apahce
Sudo/etc/init. d/apache2 restart
2. restart mysql
Sudo/etc/init. d/mysql restart

Now, the LAMP environment is configured successfully.

Installing LAMP in ubuntu has always been smooth.
Select "edit" and "mark the software package with the task group" in the new plan"
Select "lamp server"
Wait .......
Download .......
Prompt for mysql password
Generally, it is okay to set it in the ubuntu Chinese wiki.
Later, the system was reinstalled and LAMP was configured again. The problem occurred frequently .... Maybe it's because the previous configuration is not cleaned up.
During this holiday, I finally set up a local server. I found some tutorials in China are different from those in other countries by referring to ubuntu official help. I will summarize these differences:
1. preparations
If LAMP is not installed in the system, run
Code:
Sudo apt-get update

If LAMP has been installed in the system before, ensure that apache2, php5, and mysql in the system are completely deleted. search php5, apache2, respectively in the new software package manager, mysql deletes the installed software package and dependency package.
You can also use the command line
Code:
Sudo apt-get remove-purge apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl unzip libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql- server mysql-server-5.0 php5-common php5-mysql
Sudo rm-R/etc/php5

Run:
Code:
Sudo apt-get autoremove
Sudo apt-get autoclean

2. install LAMP
You can select lamp server in the new version or install it step by step.
Code:
Sudo apt-get install apache2
Sudo apt-get install php5
Sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

3. troubleshooting
1. apache2: cocould not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Code:
Sudo gedit/etc/apache2/conf. d/fqdn

Add:
Code:
ServerName localhost

Save and exit. run the following command:
Code:
Echo "ServerName localhost" | sudo tee/etc/apache2/conf. d/fqdn

Terminal display:
Code:
ServerName localhost

Indicates that the setting is successful.
2. set other folders to the local server.
In apache2, the default folder is/var/www.
This folder is owned by a super user and cannot be written by normal users. you can modify the permissions of this folder.
Code:
Sudo chmod-R 777/var/www

You can also reset a folder:
Code:
Sudo cp/etc/apache2/sites-available/default/etc/apache2/sites-available/mysite

Edit configuration file
Code:
Sudo gedit/etc/apache2/sites-available/mysite

Modify the DocumentRoot in the configuration file to the new location you need, such as/home/username/www/
Replace
Save and exit
Run:
Code:
Sudo a2dissite default & sudo a2ensite mysite

Restart apache2
Code:
Sudo/etc/init. d/apache2 restart

Enter http: // localhost in the browser
3. the php file cannot be parsed. the browser prompts you to download the php file to be opened.
Run:
Code:
Sudo apt-get install libapache2-mod-php5
Sudo a2enmod php5

Code:
This module does not exist!

Then you need to completely delete the libapache2-mod-php5, and then reinstall it
Code:
Sudo apt-get remove-purge libapache2-mod-php5
Sudo apt-get install libapache2-mod-php5

Restart apache2
Code:
Sudo/etc/init. d/apache2 restart

Clear the browser cache and enter http: localhost
4. install phpmyadmin
We recommend that you do not install it from the source.
Download the software package from the phpmyadmin website and decompress it to the local directory/var/www/phpmyadmin (/home/user/www/phpmyadmin)
Run the following command on the terminal:
Code:
Sudo cp/var/www/phpmyadmin/config. sample. inc. php/var/www/phpmyadmin/config. inc. php
Sudo gedit/var/www/phpmyadmin/config. inc. php

Find blowfish_secret and fill in any letter
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker ';
$ Cfg ['servers'] [$ I] ['host'] = 'localhost ';
$ Cfg ['servers'] [$ I] ['connect _ type'] = 'tcp ';
$ Cfg ['servers'] [$ I] ['compus'] = 'false ';
$ Cfg ['servers'] [$ I] ['extension'] = 'mysql ';
Save and exit
Install php5-mcrypt
Code:
Sudo apt-get install php5-mcrypt

Edit the php configuration file
Code:
Sudo gedit/etc/php5/apache2/php. ini

Add
Code:
Extension = php5-mcrypt.so

Save and restart apache2
Enter http://www.2cto.com/phpmyadmin in your browser

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.