Fast installation lamp environment for Linux under Ubuntu and CentOS

Source: Internet
Author: User
Tags gmp install php

Installing the lamp environment under Linux, here are a few ways to quickly install the lamp environment under Ubuntu and CentOS.


first, let's take a look at what the Lamp environment is (excerpt from Baidu Encyclopedia):

Linux+apache+mysql/mariadb+perl/php/python a group of open-source software that is often used to build dynamic Web sites or servers is itself a separate program, but because it is often used together, it has a higher degree of compatibility, Together make up a powerful Web application platform. With the booming of the open source, the three pillars has been developed with the development of Java EE and. NET commercial software, and the software-developed project has a low cost of investment in software and is therefore of concern to the entire IT community. From the website traffic, more than 70% of the traffic is lamp to provide, lamp is the most powerful website solution.

Software components

Linux Linux is free open source software, which means that the source code is available for the operating system. Apache Apache is one of the most popular open source web server software in use. MySQL MySQL is multi-threaded, multi-user SQL database management system. MySQL has been purchased by Oracle Company from January 27, 2010 through Sun. SUN originally acquired MySQL on February 26, 2008. Php,perl or Python PHP is a programming language originally designed to produce dynamic Web sites. PHP is primarily used for server-side application software. Perl and Python are similar.




First, a quick installation method under CentOS is introduced:

Now configure the required components for the system, and upgrade the system.

yum-y Update yum-y Install gcc gcc-c++ autoconf automake libtool libevent libevent-devel GMP Gmp-devel yum-y Install GD gd-devel freetype freetype-devel fontconfig fontconfig-devel libjpeg libjpeg-devel zlib zlib-devel Pcre Pcre-devel Yum-y Install ncurses ncurses-devel libmcrypt Mhash

install MySQL yum-y install MySQL mysql-server mysql-devel

Installing Apache yum-y Install httpd httpd-devel

Install PHPyum-y Install php53*

start Apache and MySQL /etc/init.d/httpd Restart /etc/init.d/mysqld Restart at this point, our lamp environment has been built. Now it's time to test the environment for success and see the configuration information. vi/var/www/html/info.php <?php phpinfo (); ?> upload the/var/www/html/directory to http://yourip/info.php access to view PHP information. is not open the short label mode, so it does not display properly, you can find the Short_open_tag in the Php,ini, and then change his value to on it .

setup httpd and MySQL boot up. chkconfig httpd on chkconfig mysqld on

Supplemental: Location of each configuration file /etc/my.cnf mysql configuration file /etc/httpd/apache configuration file /etc/php.ini PHP configuration file /var/www/html/website Storage directory

Then, below is the quick installation method under Ubuntu:

Install Apache2:

sudo apt-get install apache2

To install the PHP module:

sudo apt-get install php5

Install MySQL

sudo apt-get install Mysql-server

Installing phpMyAdmin

Other module installation:

sudo apt-get install LIBAPACHE2-MOD-PHP5

sudo apt-get install Libapache2-mod-auth-mysql

sudo apt-get install Php5-mysql

sudo apt-get install PHP5-GD

The first two are easy to understand, in order for Apache to parse PHP, you need to use these two modules to find PHP engine. The third is used in PHP to operate the MySQL database, most people have experience in database programming, so this is not much to explain. A fourth GD library.



Here are some things to consider

After just loaded the lamp environment, I tested, found that when browsing the PHP Web page is not displayed, but the PHP web file download down, because the Apache configuration inside a bit of a problem, need to set up the line.

The following is a simple configuration of Apache:

1.apache root directory

After installing apache2, the root directory under/VAR/WWW, you can test it by http://localhost/. Of course, you can also create a new file in this directory test.html to try http://localhost/test.html.

2.PHP parsing problems

After installing the seemingly PHP parsing is a bit of a problem, browse PHP page will be saved, Apache did not parse it into a Web page. The internet is generally said to need to add XXXX in the httpd.conf, for other Linux systems may be true, but Ubuntu is a bit special.

Ubuntu Apache2 is configured under the/etc/apache2 directory. There is a apache2.conf file in this directory that contains all the APACHE2 system configuration information by including other configuration files. PHP parsing part of the configuration in the/etc/apache2/mods-available under the php5.conf and Php5.load, the apache2.conf file is not included in the two files, as long as the inclusion of the OK.

*************************************************

Found in apache2.conf

# Include Module Configuration:

Include/etc/apache2/mods-enabled/*.load

Include/etc/apache2/mods-enabled/*.conf

After which you add

Include/etc/apache2/mods-available/php5.load

include/etc/apache2/mods-available/php5.conf*

************************************************

Another way is to link these two files to the mods-enabled directory:

sudo ln-s/etc/apache2/mods-available/php5.load/etc/apache2/mods-enabled/php5.load

sudo ln-s/etc/apache2/mods-available/php5.conf/etc/apache2/mods-enabled/php5.conf

This is a better approach, without destroying the configuration structure of the apache2 itself.

*************************************************

3. Change the default directory of Apache2 to the current development directory

The default directory for APACHE2 is configured in the/etc/apache2/sites-enabled/00default file.

Locate the DocumentRoot entry in the file, and change the/var/www to your development directory for OK.

Of course, there is another way is not the default directory, just create a link to your directory under Var/www.

For example, your directory is in/home/username/phptest, so you just

sudo ln-s/home/username/phptest/var/www/phptest

This way you can access your working directory through http://localhost/phptest. [note] The link file name cannot contain ".", otherwise apache2 will attempt to parse it as a file and cannot reach the effect of the linked directory.

Personal referrals are made in the latter way, so that multiple working directories can be developed in parallel.

Common commands in configuration restart Apachesudo/etc/init.d/apache2 restart

Establishing a System link sudo ln-s a b


Reference: Baidu Library



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.