Ubuntu lamp local environment Configuration

Source: Internet
Author: User

After Ubuntu is installed, you need to get apache, MySQL, and PHP environments.

I tried to compile Apache, PHP, and MySQL by myself, and finally ended in failure. Finally, install the Ubuntu tool lamp directly.

1. Use tasksel to install lamp.

Run the sudo tasksel command on the terminal.

(PS: if the system prompts that tasksel is not installed, use sudo apt-Get install tasksel for installation)

Select the lamp server item in the pop-up interface (use the downward arrow to go to the lamp server item, click the space to select, a "*" will appear before the option), click Enter to install the SDK.

The software will be installed online, so you need to connect to the Internet. After the download is complete, install the amp environment. When installing MySQL, enter the root password (This is the password of the MySQL Root User..

After two inputs, tasksel completes all the remaining operations.

After the installation, open the Firefox browser and enter http: // localhost/to display the Apache welcome information.

2. After lamp is installed, configure it based on your needs.

I. configure a virtual host for Apache

Run sudo gedit/etc/apache2/sites-available/mysite

(PS: note that the file name cannot contain "." and "#"; otherwise, Apache will not load the file)

Generate a mysite file with the following content

 <Virtualhost *:  80  >
Serveradmin webmaster @ localhost

DocumentRoot/var/www/mysite  
Servername Www. mysite . Com

Errorlog $ {apache_log_dir}/error. Log

# Possible values include: Debug , Info , Notice , Warn , Error , Crit ,
# Alert , Emerg.
Loglevel warn

Customlog $ {apache_log_dir}/access. Log combined
<Directory/home/Jeff/www/ 1.5.14 >
Options indexes followsymlinks
AllowOverride none
Order allow , Deny
Allow from all
</Directory>

</Virtualhost>

Save the file.

In editing the/etc/hosts file,

Sudo gedit/etc/hosts

Append In the hosts file

127.0.0.1Www. mysite. Com

Restart Apache now

Sudo/etc/init. d/apache2 restart

Now, add a mysite folder under the/var/WWW directory.

The default/var/WWW directory does not have the write permission. To facilitate the direct modification of the/var/WWW directory permission to 777 (SUDO chmod-r 777/var/www)

Go to the/var/WWW directory and create a folder named mysite.

CD/var/WWW

Mkdir mysite

CD mysite

Create an index. php file under the mysite folder and write the content

Gedit index. php

Input content

<? PHP

Echo 'Hello world! ';

Save.

Enter the http://www.mysite.com in Firefox to see this famous Hello world! .

Ii. Enable SSI for Apache

Apache provides SSI functions. We only need simple enable, and then configure it.

Execute Command

Sudo ln-S/etc/apache2/mod-available/include. Load/etc/apache2/mod-Enabled

Modify configuration file

Sudo gedit/etc/apache2/sites-available/mysite

Modify the content of mysite to the following content:

 <Virtualhost *:  80  >
Serveradmin webmaster @ localhost

DocumentRoot/var/www/mysite
Servername www.mysite.com

Errorlog $ {apache_log_dir}/error. Log

# Possible values include: Debug , Info , Notice , Warn , Error , Crit ,
# Alert , Emerg.
Loglevel warn

Customlog $ {apache_log_dir}/access. Log combined
<Directory/home/Jeff/www/ 1.5.14 >
Options indexes followsymlinks+ Des
AllowOverride none
Order allow , Deny
Allow from all
Addtype text/html. shtml
Addoutputfilter between des. shtml
</Directory>

</Virtualhost>

Restart Apache

Sudo/etc/init. d/apache2 restart

Create a new ssi.shtml file under the/var/www/mysite directory

The content of ssi.html is as follows:

 <  Html  >  
< Head >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
< Title > Test SSI </ Title >
</ Head >
< Body >
<! -- # Echo Var = "date_local" -->
</ Body >
</ Html >

Enter http://www.mysite.com/ssi.shtml in Firefox

If the local time is displayed normally, the SSI has been configured successfully.

Iii. Add curl for PHP.

Execute Command

Sudo apt-Get install curl libcurl3 libcurl3-dev php5-curl

Restart Apache

Sudo/etc/init. d/apache2 restart

Done

Run our company mall on meCodeThere is also a small problem:

When you click a menu, you are prompted to download the PHP file. The final reason is that an error is reported when you click require for some files: 

Warning: Call-time pass-by-reference has been deprecated-argum

.

Modification method::

Open the php. ini file and change allow_call_time_pass_reference to on.

Restart Apache.

Run the mall on meProgramBefore that, you need to import the SQL file (360 + M), which is exported using phpMyAdmin. I want to use mysqlimprot to import

You can always report errors. The last method is:

Enter

Mysql-uroot-P database name <SQL File

(PS: Create a database before import; otherwise, the Import fails)

It takes a long time to enter the root password. When the command prompt appears again, it indicates that the import has been successful.

Refer:

Http://www.linuxidc.com/Linux/2007-11/8828.htm

Http://blog.sina.com.cn/s/blog_4c5fc69501000asw.html

Http://www.myhack58.com/Article/sort099/sort0102/2011/29424.htm

Http://zhidao.baidu.com/question/211359899.html

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.