Install the LAMP environment with CentOS 6.3 source code

Source: Internet
Author: User
Tags processing text unpack 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". 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/src ls *.tar.gz > ls.list for TAR in `cat ls.list` do tar -zxvf $TAR done

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:

# Yuminstall 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

# 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

<?php phpinfo();?>

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.

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.