Install the lamp (Linux + Apache + MySQL + PHP) environment with the source code in centos 6.3

Source: Internet
Author: User
Tags processing text what is lamp

I. 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", Michael
In 1990, 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 in a hierarchical structure. Each layer provides a key part of the entire architecture:
Linux : Linux
is at the bottom layer and provides the 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 are 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, 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 the web application Program , all account information, product information, customer information, business data, and other types of information are stored in the database and can be easily queried using the SQL language.
PHP/perl : Perl is a flexible language, especially when processing text elements, this flexibility makes it easy for Perl to process the data provided through the
CGI interface, and flexibly use text files and simple databases to support dynamic elements. PHP is a widely used multi-purpose scripting language for Source Code . It can be embedded in
HTML, 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,Library file preparation

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 installedUse 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/ShCD/Usr/local/SRCLs*.Tar. GZ>Ls. ListForTarIn'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:MissingNcursesInstallation Package

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 entryCode
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

# Change auth_type to HTTP in VI/usr/local/apache2/htdocs/PHPmyAdmin/config. Inc. php
$ 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

 
<?PHPPhpinfo();?>

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.

 

About lnmp (Linux + nginx + MySQL + PHP)For more information about server environment configuration, see:

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

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.