CentOS 6.3 Under the source code installation lamp (linux+apache+mysql+php) operating environment steps _linux

Source: Internet
Author: User
Tags install php mkdir mysql client mysql version unpack 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 word lamp originated in the German magazine "C ' t Magazine", and Michael Kunze first assembled the items together in 1990 to create lamp abbreviations. These components are not designed to be used together, but they are open source, readily available and free to use, which leads to the common use of these components. The compatibility of these components is also being perfected, and in order to improve collaboration between different components, some extensions have been created, and the application situation becomes very common and thus becomes the most popular Web application infrastructure today.

Lamp's Components
The platform consists of four components that are layered and each layer provides a key part of the entire architecture:
Linux : Linux is at the bottom and provides the operating system. Its flexibility and customizable nature means it can produce a highly customizable platform for other components to run on. Other components run on Linux but are not necessarily limited to Linux or run on Microsoft Windows, Mac OS X, or UNIX.
Apache : Apache is on the second floor, a Web service platform that provides the mechanism for users to get a Web page. Apache is a powerful, stable, mission-critical Web server that is used as a Web server by more than 50% of Web sites on the Internet.
MySQL : MySQL is the most popular open source relational database management system, is the lamp data storage side. 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 in SQL language.
Php/perl : Perl is a flexible language, especially when dealing with textual elements, which makes it easy for Perl to handle the data provided through the CGI interface, flexibly using text files and simple databases to support dynamic elements. PHP is a widely used, open source, multipurpose 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

Iii. Pre-Installation Preparation

1, the Library document preparation

Before you install PHP, you should first install the latest version of the 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 must install the latest zlib, libpng, FreeType, and JPEGSRC library files before installing the GD2 library. And the middle will be interspersed with some software, readers 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 compile work that is used during installation

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

3, uninstall the default low version of the environment

In the current version of the Linux operating system, if you choose to install it all by default, the lamp environment is installed, but the versions are relatively low. We can install a lamp environment with the original, but this is not necessary, because at the same time can only open a lamp environment. We want to install before, we should 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 off.

A. Uninstall Apache

# Rpm-qa | grep httpd

Description: Check to see if the HTTPD package is installed

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

Description: Uninstall package,--nodeps if there is a joint relationship, also forced uninstall

# cd/etc/httpd/

# RM-RF *

Description: In the original Apache installation directory, all of its installation directories and files are deleted

B. Uninstall MySQL

# Rpm-qa | grep MySQL

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

Description: 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

Description: Uninstall PHP

4, close SELinux, clear firewall rules

5, use the SSH shell to upload windows under the 13 source package to/USR/LOCAL/SRC

6, Solution Package

Write a shell script tar.sh for the unpack.

#!/bin/sh cd/usr/local/srcls *.tar.gz > ls.list for tar in ' cat ls.list ' DOTAR-ZXVF $TARdone

Execute the Script tar.sh unpack

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 installation is special, other packages installed when the directory does not exist, will be automatically created, but this package installation needs to be manually created.

# 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 when the source file, png.h not find the cause.

Solve:

In the compiled file

# VI GD_PNG.C

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

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

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

Turn off Apache
#/usr/local/apache2/bin/apachectl Stop

To see if port 80 is open
# Netstat-tnl|grep 80

Accessing the Apache server

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

11, install MySQL

Add a MySQL Standard group
# Groupadd MySQL

Add MySQL user to 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 MySQL database server configuration file
# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

Create authorization table with MySQL user, after successful creation, will generate a var directory under the/usr/local/mysql directory
#/usr/local/mysql/bin/mysql_install_db--user=mysql

Change all properties of a file to root
# 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 &

To see if Port 3306 is open
# 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
# 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 to log on to the local server directly
#/usr/local/mysql/bin/mysql-u Root

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

Remove a localhost host
Mysql> DELETE from mysql.user WHERE host= ' localhost ' and user= ';

Refresh Authorization Table
mysql> FLUSH privileges;

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

Enter 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

Using VI to edit Apache configuration files
# 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. Install 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. Configure phpMyAdmin

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

Change Auth_type to HTTP

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

Five, test

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 the browser to get detailed configuration information for PHP

2, Zend Accelerator information

3. Visit phpMyAdmin

The lamp environment has been configured to complete.

For LNMP (linux+nginx+mysql+php) Server environment configuration, please refer to: http://www.jb51.net/article/52419.htm

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.