CentOS 6.3 under source installation lamp (linux+apache+mysql+php) environment

Source: Internet
Author: User
Tags install php mysql client phpmyadmin what is lamp zend

First, Introduction

What is lamp
Lamp is a Web network application and development environment, is the abbreviation of Linux, Apache, MySQL, Php/perl, each letter represents a component, each component in itself is a very powerful component in the aspect it represents.
The origin of the word lamp originated in the German magazine "C ' t Magazine", where Michael Kunze first set together these projects to create the acronym for Lamp in 1990. These components are not designed to be used together at the outset, but they are open source and readily available and free to use, which leads to the frequent use of these components. The compatibility of these components is also evolving, and in order to improve collaboration among the different components, some extension features have been created, and the application situation together becomes very popular, making it the most prevalent Web application infrastructure.

Components of lamp
The platform consists of four components in a hierarchical structure, each of which provides a key part of the entire architecture:
Linux : Linux is at the bottom and provides the operating system. Its flexibility and customizable features mean it can produce a highly customizable platform for other components to run on. Other components run on Linux, but not necessarily limited to Linux, or run on Microsoft Windows, Mac OS X, or UNIX.
Apache : Apache is located on the second tier, which is a Web services platform that provides a mechanism for users to get web pages. Apache is a powerful, stable, mission-critical Web server that uses it as a Web server for more than 50% of sites on the Internet.
MySQL : MySQL is the most popular open source relational database management system, which is the data storage side of lamp. In a WEB application, all account information, product information, customer information, business data, and other types of information are stored in the database and can be easily queried through the SQL language.
Php/perl : Perl is a flexible language, especially when it comes to working with text features, which makes it easy for Perl to handle the data provided through the CGI interface, with the flexibility to use text files and simple databases to support dynamic features. PHP is a widely used, open-source, multi-purpose scripting language that can be embedded in HTML, especially for Web development. You can use PHP to write dynamic content that accesses the data in the MySQL database and some of the features that Linux provides.

Second, the 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

Three, pre-installation preparation

1. Library File Preparation

Before you install PHP, you should install the latest version library files that PHP5 requires, such as LIBXML2, Libmcrypt, and GD2 libraries. The GD2 library is installed to allow PHP5 to support GIF, PNG, and JPEG picture formats, so you will need to install the latest zlib, libpng, FreeType, and JPEGSRC library files before installing the GD2 library. And the middle will also be interspersed with some software installed, the reader can be installed 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 GCC, gcc-c++ compiler

Use the GCC-V command to check for the existence of the compilation work used during installation

If the system is not installed, use yum install gcc and yum install gcc-c++ installation in the case of system networking

3. Uninstall the default low-version environment

In the current release of the Linux operating system version, if you choose to install all by default, you have installed the lamp environment, but the version is relatively low. We can install another lamp environment and the original coexistence, but this is not necessary, because at the same time can only open a lamp environment. All we need to do before installing, we should first check whether the system has installed a low version of the environment, if it has been installed, stop the original service operation, or the original environment uninstall.

A. Uninstalling Apache

# Rpm-qa | grep httpd

Description: Check if the HTTPD package is installed

# rpm-e Httpd-2.2.3-63.el5.centos--nodeps

Description: Uninstall the package,--nodeps if there is a connection, also force uninstall

# cd/etc/httpd/

# RM-RF *

Description: Delete all of its installation directories and files to the original Apache installation directory

B. Uninstall MySQL

# Rpm-qa | grep MySQL

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

Description: Uninstall MySQL

C. Uninstalling 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

Description: Uninstalling PHP

4. Turn off SELinux and clear the firewall rules

5. Use SSH Shell to upload 13 source packages under Windows to/USR/LOCAL/SRC

6. Unpacking

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

Executing the script tar.sh unpacking

7, the source package *.tar.gz all deleted

Four, install lamp

1, installation LIBXML2

# cd/usr/local/src/libxml2-2.6.30
#./configure--PREFIX=/USR/LOCAL/LIBXML2
# Make && make install

2, Installation Libmcrypt

# cd/usr/local/src/libmcrypt-2.5.8
#./configure--prefix=/usr/local/libmcrypt
# Make && make install

3, installation Zlib

# cd/usr/local/src/zlib-1.2.3
#./configure
# Make && make install

4, installation libpng

# cd/usr/local/src/libpng-1.2.31
#./configure--prefix=/usr/local/libpng
# Make && make install

5, Installation Jpeg6

This package is specially installed and is created automatically if the directory does not exist at the time of installation, but it needs to be created manually when the package is installed.

# Mkdir/usr/local/jpeg6
# Mkdir/usr/local/jpeg6/bin
# Mkdir/usr/local/jpeg6/lib
# Mkdir/usr/local/jpeg6/include
# mkdir-p/usr/local/jpeg6/man/man1

# cd/usr/local/src/jpeg-6b
#./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static
# Make && make install

6, Installation FreeType

# cd/usr/local/src/freetype-2.3.5
#./configure--prefix=/usr/local/freetype
# make
# make Install

7, installation autoconf

# cd/usr/local/src/autoconf-2.61
#./configure
# Make && make install

8. Install 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/jpeg6/\
--with-png=/usr/local/libpng/\
--with-freetype=/usr/local/freetype/

# make

Error occurred:

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 because the GD_PNG.C in the GD library contains png.h in the source file, Png.h is not found to be the cause.

Solve:

In the compilation file.

# VI GD_PNG.C

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

Where/usr/local/libpng/is the libpng installation path.

# make Install

9. Installing Apache

# cd/usr/local/src/httpd-2.2.9
#./configure \
--PREFIX=/USR/LOCAL/APACHE2 \
--SYSCONFDIR=/ETC/HTTPD \
--with-z=/usr/local/zlib \
--WITH-INCLUDED-APR \
--ENABLE-SO \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support
# Make && make install

10. Configure Apache

Launch Apache
#/usr/local/apache2/bin/apachectl Start

Close Apache
#/usr/local/apache2/bin/apachectl Stop

See if Port 80 is turned on
# Netstat-tnl|grep 80

Accessing the Apache server

Adding a self-starter
# echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.local

11. Install MySQL

Add a MySQL Standard group
# Groupadd MySQL

Adding MySQL users to the MySQL group
# useradd-g MySQL MySQL

# cd/usr/local/src/mysql-5.0.41
#./configure \
--prefix=/usr/local/mysql/\
--with-extra-charsets=all

Error occurred:

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: missing ncurses installation package

Solve:

# 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 authorization table with MySQL user, after creation, a VAR directory will be generated in the/usr/local/mysql directory
#/usr/local/mysql/bin/mysql_install_db--user=mysql

Change all properties of a file to the root user
# Chown-r Root/usr/local/mysql

Change all properties of data directory to MySQL user
# Chown-r Mysql/usr/local/mysql/var

Change group properties to MySQL Group
# Chgrp-r Mysql/usr/local/mysql

Start the database
#/usr/local/mysql/bin/mysqld_safe--user=mysql &

See if Port 3306 is turned on
# Netstat-tnl|grep 3306

A simple test
#/usr/local/mysql/bin/mysqladmin Version

View all MySQL Parameters
#/usr/local/mysql/bin/mysqladmin variables

Set up MySQL boot from boot
# 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

No password can be directly logged into the native server
#/usr/local/mysql/bin/mysql-u Root

View MySQL user rights information
Mysql> select * from Mysql.user;

Remove hosts that are not localhost
Mysql> DELETE from mysql.user WHERE host= ' localhost ' and user= ';

Refresh Authorization Table
mysql> FLUSH privileges;

Add a password for the root user
mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' abc123 ');

Go to 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/jpeg6/\
--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

Creating a configuration file
# CP Php.ini-dist/usr/local/php/etc/php.ini

Editing Apache configuration files with VI
# vi/etc/httpd/httpd.conf

Add this piece of 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. Installing the Zend Accelerator

# cd/usr/local/src/zendoptimizer-3.2.6-linux-glibc21-i386/
#./install.sh

17, Installation phpMyAdmin

Copy the directory to the specified location and rename 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, Configuration phpMyAdmin

# vi/usr/local/apache2/htdocs/phpmyadmin/config.inc.php Change Auth_type to HTTP
$cfg [' Servers '] [$i] [' auth_type '] = ' http ';

V. Testing

1, write info.php file, view PHP configuration details

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

<?phpphpinfo ();? >

Access http://10.0.0.154/info.php through a browser to get detailed configuration information for PHP

2, Zend Accelerator information

3. Visit phpMyAdmin

At this point the lamp environment configuration is complete.

CentOS 6.3 under source installation lamp (linux+apache+mysql+php) environment

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.