Install the LAMP (Linux + Apache + Mysql + Php) environment in CentOS6.3

Source: Internet
Author: User
Tags processing text what is lamp
Install the LAMP (Linux + Apache + Mysql + Php) environment in CentOS6.3. Introduction

What is LAMP?
LAMP is a Web application and development environment. it is short for Linux, Apache, MySQL, Php/Perl. each letter represents a component, each component is a very powerful component represented by it.
The term LAMP first came from the German Magazine "c't Magazine". in 1990, Michael Kunze first combined these projects to create the abbreviation of LAMP. These components are not designed to be used together at the beginning. However, these software is open-source and can be conveniently obtained and used for free at any time, as a result, these components are often used together. The compatibility of these components is also constantly improved. to improve the collaboration between different components, some extended functions have been created, and the application scenario becomes very general, therefore, it has become the most popular web application infrastructure.

LAMP components
The platform consists of four components and consists of a hierarchical structure. each layer provides a key part of the entire architecture:
Linux: Linux is at the bottom layer and provides an operating system. Its flexibility and customizable features mean that it can generate a highly customized platform for other components to run on it. Other components run on Linux, but not limited to Linux. They can also run on Microsoft Windows, Mac OS X, or UNIX.
Apache: Apache is located on the second layer. it is a Web service platform that provides a mechanism for users to obtain Web pages. Apache is a powerful, stable, and Web server that supports key tasks. over 50% of websites on the Internet use Apache as their Web servers.
MySQL: MySQL is the most popular open-source relational database management system and the data storage end of LAMP. In Web applications, all account information, product information, customer information, business data, and other types of information are stored in the database, which can be easily queried using the SQL language.
PHP/Perl: Perl is a flexible language, especially when processing text elements, which makes it easy for Perl to process data provided through CGI interfaces, flexible use of text files and simple databases to support dynamic elements. PHP is a widely used open-source multi-purpose scripting language. it can be embedded in HTML and is especially suitable for web development. You can use PHP to write dynamic content that can access MySQL database data and some features provided by Linux.

II. system environment

System platform: CentOS release 5.8 (Final)

Apache version: httpd-2.2.9.tar.gz

Mysql version: mysql-5.0.41.tar.gz

Php version: php-5.2.6.tar.gz

3. preparations before installation

1. prepare database files

Before installing PHP, install the latest library files required by PHP5, such as libxml2, libmcrypt, and GD2. To enable PHP5 to support GIF, PNG, and JPEG image formats, install the latest library files such as zlib, libpng, freetype, and javassrc before installing the GD2 Library. Some software will be installed in the middle. you can install the software in the order provided in this section.

Autoconf-2.61.tar.gz

Freetype-2.3.5.tar.gz

Gd-2.0.35.tar.gz

Jpegsrc.v6b.tar.gz

Libmcrypt-2.5.8.tar.gz

Libpng-1.2.31.tar.gz

Libxml2-2.6.30.tar.gz

Zlib-1.2.3.tar.gz

ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz

PhpMyAdmin-3.0.0-rc1-all-languages.tar.gz

2. install the gcc and gcc-c ++ compiler

Run the gcc-v command to check whether the compilation work used during installation exists.

If the system is not installed, use yum install gcc and yum install gcc-c ++ to install

3. uninstall the default low-version Environment

In the current Linux operating system version, if you choose to install all by default, the LAMP environment has been installed, but the version is relatively low. We can install another LAMP environment and the original environment, but this is not necessary because only one LAMP environment can be enabled at the same time. Before installation, check whether the system has installed a low-version environment. if the system has already installed the environment, stop running the original service, or uninstall the original environment.

A. uninstall Apache

# Rpm-qa | grep httpd

Note: Check whether the httpd software package is installed.

# Rpm-e httpd-2.2.3-63.el5.centos -- nodeps

Note: uninstall the software package. if nodeps is associated, uninstall it forcibly.

# Cd/etc/httpd/

# Rm-rf *

Note: delete all the installation directories and files under the original apache installation directory.

B. uninstall Mysql

# Rpm-qa | grep mysql

# Rpm-e mysql-5.0.77-4.el5_4.2 -- nodeps

Instructions: uninstall mysql

C. uninstall Php

# Rpm-qa | grep php

# Rpm-e php-common-5.1.6-27.el5 -- nodeps

# Rpm-e php-ldap-5.1.6-27.el5 -- nodeps

# Rpm-e php-cli-5.1.6-27.el5 -- nodeps

# Rpm-e php-5.1.6-27.el5 -- nodeps

Instructions: uninstall PHP

4. disable selinux and clear firewall rules.

5. Use ssh shell to upload 13 source code packages in windows to/usr/local/src

6. unpack

Write a shell script tar. sh to unpack the package.

#!/bin/sh  cd /usr/local/srcls *.tar.gz > ls.list        for TAR in `cat ls.list`  dotar -zxvf $TARdone

Run the script tar. sh to unpack the package.

7. delete all source code packages * .tar.gz

4. install LAMP

1. install libxml2

# Cd/usr/local/src/libxml2-2.6.30
#./Configure -- prefix =/usr/local/libxml2
# Make & make install

2. install libmcrypt

# Cd/usr/local/src/libmcrypt-2.5.8
#./Configure -- prefix =/usr/local/libmcrypt
# Make & make install

3. install zlib

# Cd/usr/local/src/zlib-1.2.3
#./Configure
# Make & make install

4. install libpng

# Cd/usr/local/src/libpng-1.2.31
#./Configure -- prefix =/usr/local/libpng
# Make & make install

5. install iis6

The installation of this software package is somewhat special. if the directory does not exist during installation of other software packages, it will be automatically created, but this software package needs to be manually created during installation.

# Mkdir/usr/local/limit 6
# Mkdir/usr/local/partition 6/bin
# Mkdir/usr/local/IPv6/lib
# Mkdir/usr/local/latest 6/include
# Mkdir-p/usr/local/users 6/man/man1

# Cd/usr/local/src/jpeg-6b
#./Configure -- prefix =/usr/local/defaults 6/-- enable-shared -- enable-static
# Make & make install

6. install freetype

# Cd/usr/local/src/freetype-2.3.5
#./Configure -- prefix =/usr/local/freetype
# Make
# Make install

7. install autoconf

# Cd/usr/local/src/autoconf-2.61
#./Configure
# Make & make install

8. install the GD Library

# Cd/usr/local/src/gd-2.0.35
#./Configure \
-- Prefix =/usr/local/gd2 /\
Enable-m4_pattern_allow \
-- With-zlib =/usr/local/zlib /\
-- With-jpeg =/usr/local/defaults 6 /\
-- With-png =/usr/local/libpng /\
-- With-freetype =/usr/local/freetype/

# Make

Error:

Make [2]: *** [gd_png.lo] Error 1
Make [2]: Leaving directory '/usr/local/src/gd-2.0.35'
Make [1]: *** [all-recursive] Error 1
Make [1]: Leaving directory '/usr/local/src/gd-2.0.35'
Make: *** [all] Error 2

Analysis: This problem is caused by the failure to find png. h when the source file gd_png.c in the gd Library contains png. h.

Solution:

In the compilation file

# Vi gd_png.c

Change include "png. h" to include "/usr/local/libpng/include/png. h"

/Usr/local/libpng/is the installation path of libpng.

# Make install

9. install Apache

# Cd/usr/local/src/httpd-2.2.9
#./Configure \
-- Prefix =/usr/local/apache2 \
-- Sysconfdir =/etc/httpd \
-- With-z =/usr/local/zlib \
-- With-defined Ded-apr \
-- Enable-so \
-- Enable-deflate = shared \
-- Enable-expires = shared \
-- Enable-rewrite = shared \
-- Enable-static-support
# Make & make install

10. configure Apache

Start Apache
#/Usr/local/apache2/bin/apachectl start

Disable Apache
#/Usr/local/apache2/bin/apachectl stop

Check whether port 80 is enabled
# Netstat-tnl | grep 80

Access Apache server

Add auto-start
# Echo "/usr/local/apache2/bin/apachectl start">/etc/rc. d/rc. local

11. install Mysql

Add a mysql Standard Group
# Groupadd mysql

Add a mysql user to the mysql Group
# Useradd-g mysql

# Cd/usr/local/src/mysql-5.0.41
#./Configure \
-- Prefix =/usr/local/mysql /\
-- With-extra-charsets = all

Error:

Checking for tgetent in-lncurses... no
Checking for tgetent in-lcurses... no
Checking for tgetent in-ltermcap... no
Checking for tgetent in-ltinfo... no
Checking for termcap functions library... configure: error: No curses/termcap library found

Analysis: The ncurses installation package is missing

Solution:

# Yum install ncurses-devel

# Make & make install

12. configure Mysql

Create a configuration file for the MySQL database server
# Cp support-files/my-medium.cnf/etc/my. cnf

Create an authorization table with the mysql User. after the table is created successfully, a var directory is generated under the/usr/local/mysql directory.
#/Usr/local/mysql/bin/mysql_install_db -- user = mysql

Change all attributes of the file to the root user.
# Chown-R root/usr/local/mysql

Change all attributes of the data directory to mysql users.
# Chown-R mysql/usr/local/mysql/var

Change group attribute to mysql Group
# Chgrp-R mysql/usr/local/mysql

START database
#/Usr/local/mysql/bin/mysqld_safe -- user = mysql &

Check whether Port 3306 is enabled
# Netstat-tnl | grep 3306

Simple test
#/Usr/local/mysql/bin/mysqladmin version

View all mysql parameters
#/Usr/local/mysql/bin/mysqladmin variables

Set Mysql to start automatically
# Cp/usr/local/src/mysql-5.0.41/support-files/mysql. server/etc/rc. d/init. d/mysqld
# Chown root. root/etc/rc. d/init. d/mysqld
# Chmod 755/etc/rc. d/init. d/mysqld
# Chkconfig -- add mysqld
# Chkconfig -- list mysqld
# Chkconfig -- levels 245 mysqld off

13. Mysql security settings

You can directly log on to the server without a password.
#/Usr/local/mysql/bin/mysql-u root

View mysql User permission information
Mysql> select * from mysql. user;

Delete hosts that are not localhost
Mysql> delete from mysql. user WHERE Host = 'localhost' AND User = '';

Refresh authorization table
Mysql> flush privileges;

Add password for root user
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('abc123 ');

Enter the Mysql client again
#/Usr/local/mysql/bin/mysql-u root-h localhost-p

Close MySQL database
#/Usr/local/mysql/bin/mysqladmin-u root-p shutdown

14. install PHP

# Cd/usr/local/src/php-5.2.6
#./Configure \
-- Prefix =/usr/local/php \
-- With-config-file-path =/usr/local/php/etc \
-- With-apxs2 =/usr/local/apache2/bin/apxs \
-- With-mysql =/usr/local/mysql /\
-- With-libxml-dir =/usr/local/libxml2 /\
-- With-png-dir =/usr/local/libpng /\
-- With-jpeg-dir =/usr/local/defaults 6 /\
-- With-freetype-dir =/usr/local/freetype /\
-- With-gd =/usr/local/gd2 /\
-- With-zlib-dir =/usr/local/zlib /\
-- With-mcrypt =/usr/local/libmcrypt /\
-- With-mysqli =/usr/local/mysql/bin/mysql_config \
-- Enable-soap \
-- Enable-mbstring = all \
-- Enable-sockets
# Make & make install

15. configure PHP

Create a configuration file
# Cp php. ini-dist/usr/local/php/etc/php. ini

Use vi to edit the apache configuration file
# Vi/etc/httpd. conf

Add this code
Addtype application/x-httpd-php. php. phtml

Restart Apache
#/Usr/local/apache2/bin/apachectl restart

The above installation steps can be written as a shell script, detailed reference http://files.cnblogs.com/mchina/lamp.rar

16. install Zend accelerator

# Cd/usr/local/src/ZendOptimizer-3.2.6-linux-glibc21-i386/
#./Install. sh

17. install phpMyAdmin

Copy the directory to the specified location and change it to phpmyadmin.

# Cp-a phpMyAdmin-3.0.0-rc1-all-languages/usr/local/apache2/htdocs/phpmyadmin

# Cd/usr/local/apache2/htdocs/phpmyadmin/

# Cp config. sample. inc. php config. inc. php

18. configure phpMyAdmin

# Vi/usr/local/apache2/htdocs/phpmyadmin/config. inc. php

Change auth_type to http

$cfg['Servers'][$i]['auth_type'] = 'http';

V. test

1. Compile the info. php file to view the php configuration details.

# Vi/usr/local/apache2/htdocs/info. php

 

Access http: // 10.0.0.154/info. php in a browser to obtain detailed php configuration information.

2. Zend accelerator information

3. access phpMyAdmin

Now the LAMP environment has been configured.

For more information about LNMP (linux + nginx + mysql + php) server environment configuration, see:

Http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.html

David Camp

For technical exchange, add the QQ group:

System O & M technology: 296513821

Business cooperation, please contact the author QQ: 562866602 my number: mchina_tang to write to me: mchina_tang@qq.com my address: Jiangsu · Suzhou

We always Believe that sharing is a virtue | We Believe, Great People Share Knowledge...

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.