Environment of lamp development (2014.12.7 under Ubuntu)

Source: Internet
Author: User
Tags phpinfo phpmyadmin fully qualified domain name

Build lamp environment under Ubuntu

Before learning PHP scripting language, you must first build and familiar with the development environment, there are many kinds of development environment, such as lamp, WAMP, Mamp and so on. Here I build the lamp environment, that is, Linux, Apache, MySQL, PHP environment. There are many ways to build online, but they are not up-to-date, the construction time is 2014.12.07.

I. Building the Environment
Lenovo Y470
VMWare9.0
Ubuntu 14.04.1 LTS (trusty Tahr): Ubuntu-14.04.1-desktop-i386.iso
Second, install the software
1. Install Apache2:

sudo Install apache2

After the installation is complete, run the following command to restart Apache:sudo/etc/init.d/apache2 Restart, enter in the browser
http://localhost or http://127.0.0.1, you'll see "It works!" Description Apache installation succeeded.

2. Install PHP:

sudo Install PHP5

3. Install MySQL:

sudo Install mysql-serversudoinstall mysql-client

During the installation process, you will be asked to set the MySQL server password and enter it.

4. Installing phpMyAdmin

sudo Install phpMyAdmin

Select Apache2 during installation, click OK, next choose to configure the database and enter the password.

5 Installing the Expansion module

sudo Install // latest version, automatically installed sudo install libapache2-mod-auth-mysqlsudoinstall php5-mysql sudo Install PHP5-GD

6 Adding test modules

sudo chmod 777 /var/www                            // Modify Permissions sudoln -s/usr/share/phpmyadmin/var/www  // establishing a soft connection

Enter Http://localhost/phpmyadmin in the browser, if the database management software appears, indicating success.

Three test pages

1 Enabling the Mod_rewrite module

sudo A2enmod rewrite sudo // or sudo service apache2 restart restart Apache server:

2 set Apache support. htm. html. php

sudo gedit/etc/apache2/apache2.confaddtype application// Add

3 Testing PHP Web pages

 /*  lamp.php   <? php   $link  = mysql_connect  ("localhost", " Root "," password "); //  note Modify your own password  if  (!  $link  )  die  (' Could not connect: '. mysql_error   ());  else  echo  "Mysql configuration is correct!"  mysql_close  ( $link  ? 

Storing the code in/var/www/html/and accessing http://localhost/lamp.php shows that ' Mysql is configured correctly ' means that the configuration is correct.

Four Common Files

Error 1:

Execute command: sudo/etc/init.d/apache2 restart
Error occurred: Apache2:could not reliably determine the server ' s fully qualified domain name, using
127.0.1.1 for ServerName
Workaround:
Open: sudo gedit/etc/apache2/apache2.conf
Add to:
#Server Name
ServerName 127.0.0.1

Error 2:
Execute Command http://domain/phpmyadmin
Error occurred: The requested url/phpmyadmin is not found on this server
Workaround:
Open: sudo gedit/etc/apache2/apache2.conf
Added:include/etc/phpmyadmin/apache.conf
Restart: sudo/etc/init.d/apache2 restart
Execution: Http://domain/phpmyadmin

Error 3:
Execute command: http://localhost/phpinfo.php
Error occurred: garbled
Workaround:
Open: sudo gedit/etc/apache2/apache2.conf
Added:adddefaultcharset UTF-8
Restart: sudo/etc/init.d/apache2 restart
Execution: http://localhost/phpinfo.php

Error 4:

Execute command: http://localhost/test.php

An error occurred: The requested url/phpinfo.php is not found on this server.

Workaround:

1 The above error appears, check the log (/var/log/apache2/error.log, find the purpose of the system lookup
It's/var/www/html.
2 Put your custom files in the /var/www/html

Note: You can also refer to:/etc/apache2/sites-available/dafault.conf, establish a custom virtual server to resolve this issue, the next section will focus on.

Five reference links

1 Ubuntu Build Lamp environment

2 Setting the lamp environment under Ubuntu

Environment of lamp development (2014.12.7 under Ubuntu)

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.