Fast setup of the lamp environment under the Linux Ubuntu and CentOS

Source: Internet
Author: User
Tags gmp install php ini centos mysql database

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

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

Linux+apache+mysql/mariadb+perl/php/python a group of commonly used to build Dynamic Web site or server open source software, itself are separate programs, but because often put together to use, has more and more high compatibility, Together form a powerful Web application platform. With the development of Open-source power, the open source lamp has become tripod with Java EE and. NET commercial software, and the Software development project has low cost in software investment, so it is the focus of the whole IT industry. From the traffic on the website, more than 70% of the traffic is provided by lamp, lamp is the most powerful web site solution.

Software components

Linux Linux is free open source software, which means that the source code is available to the operating system. Apache Apache is one of the most popular open source web server software in use. MySQL MySQL is a multithreaded, multi-user SQL database management system. MySQL has been purchased by Oracle Company from January 27, 2010 via Sun. SUN first 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 of all, the first, CentOS under the rapid installation method:

Now configure the required components for the system, as well as 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

Install Apache yum-y Install httpd httpd-devel

Install PHP yum-y Install php53*

Launch Apache and MYSQL/ETC/INIT.D/HTTPD restart/etc/init.d/mysqld Restart so far, our lamp environment has been built. Now it's time to test whether the environment has been built successfully and to view the configuration information. vi/var/www/html/info.php upload/var/www/html/directory to http://yourip/info.php access to view PHP information. is not open the short label mode, so it is not normal to display, you can find Short_open_tag in the Php,ini, and then change his value to on.

Set up httpd and MySQL boot up. Chkconfig httpd on Chkconfig mysqld on

Add: Each profile location/etc/my.cnf MySQL profile/etc/httpd/apache configuration file/etc/php.ini PHP profile/var/www/html/Web site Storage Directory

Then, the following is a quick installation method under Ubuntu:

Install Apache2:

sudo apt-get install apache2

To install the PHP module:

sudo apt-get install php5

installing MySQL

sudo apt-get install Mysql-server

Install phpMyAdmin

Other modules installed:

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, to the Apache can parse PHP, you need to use these two modules to find PHP engine. The third is used in PHP to manipulate the MySQL database, most people have database programming experience, so this is not much to explain. Fourth GD library.

Here are some caveats

After the installation of lamp environment, I have tested, found in the Browsing PHP Web page did not show, but the PHP web file download down, the reason is the Apache configuration there is a problem, need to set up on the line.

Here is the simple configuration of Apache:

1.apache root directory

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

2.PHP parsing problem

After installation seems to have a PHP resolution is a bit of a problem, browsing the PHP page will be saved, Apache did not resolve it as a Web page. It is generally said that you need to add XXXX to the httpd.conf, which may be true for other Linux systems, but Ubuntu is a bit special.

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

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

Found in the 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 the 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 way, 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 item in the file and change the/var/www to your development directory for OK.

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

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

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

This will allow you to 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 not reach the linked directory effect.

It is recommended 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

Establish system link sudo ln-s a b

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.