CentOS 6.3 Source Installation lamp (linux+apache+mysql+php) environment

Source: Internet
Author: User
Tags what is lamp

First, Introduction

What is lamp

Lamp is a Web application and development environment, is the abbreviation of Linux, Apache, MySQL, Php/perl, each letter represents a component, each component in itself and > 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, readily available and free to use, resulting in these components often together to make

Use. The compatibility of these components is also evolving, and in order to improve collaboration among the different components, some extension functions have been created, and the application situation together becomes
The most popular Web application infrastructure for the time being.

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 customized platform for other components to be shipped
Yes. Other components run on Linux, but not necessarily limited to Linux, or run on Microsoft Windows, Mac OS X, or UNIX.
Located on the second tier, Apache:apache is a Web services platform that provides a mechanism for users to get a Web page. Apache is a powerful, stable Web server that supports off > key tasks, and more than 50% of Web sites on the Internet use it as a Web server.
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, flexibly transporting > supporting dynamic features with text files and simple databases. 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 6.3 (Final)

Apache Runtime: apr-1.4.6.tar.gz

Apr-util-1.5.2.tar.gz (http://apr.apache.org/download.cgi)

Apache version: httpd-2.4.4.tar.gz (http://httpd.apache.org/download.cgi)

Mysql version: mysql-5.6.11.tar.gz (http://dev.mysql.com/downloads/mirror.php?id=412388)

PHP Version: php-5.4.14.tar.gz (http://php.net/downloads.php)

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 was installed to allow PHP5 to support GIF,
PNG and JPEG picture formats, install the latest library files such as zlib, Libpng, FreeType, and JPEGSRC before installing the GD2 library. And the middle will be interspersed with some soft > pieces, the reader can be installed in the order provided in this section.

(Note: The library may have been installed natively, see method rpm-qa | grep library Name
For example, to see if the LIBXML2 Library is installed, command: RPM-QA | grep libxml2
If the relevant library does not exist, you can download the following to the library for compilation or installation, or use Yum to install
For example, for LIBXML2 libraries, use Yum to install:
Yum Search LIBXML2 #查询相关库对应的rpm文件
The output is as follows:

Libxml2.i686:Library providing XML and HTML support Libxml2-devel.i686:libraries, includes, etc. to develop XML and HT ML applications Yum install libxml2.i686 ibxml2-devel.i686 #安装

)
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

Ncurses-5.8.tar.gz

Cmake-2.8.4.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 used during installation, and install it via Yum If you are prompted that the command does not exist: Yum installs gcc and yum install gcc-c++ installation.

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 if the system is installed
The lower version of the environment, if it has been installed, to stop the original service run, or to remove the original environment

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/src
LS *.tar.gz > Ls.list
For TAR cat ls.list in
Do
TAR-ZXVF $TAR
Done

Executing the script tar.sh unpacking

Four, install lamp

1, installation of the various libraries, you can use the Yum method described above installation, if not found relevant to the library, you can download the source code is installed in the following way, take LIBXML2 as an example, other similar

# cd/usr/local/src/libxml2-2.6.30

#./CONFIGURE–PREFIX=/USR/LOCAL/LIBXML2

# Make && make install

2. Installing Apache Runtime

# cd/usr/local/src/apr-1.4.6

#./configure && make && make install

# cd/usr/local/src/apr-util-1.5.2

#./configure && make && make install

Description: After the two libraries are installed, the path defaults to/usr/local/apr/bin, which is used by the subsequent compilation of Apache.

3. Installing Apache

# cd/usr/local/src/httpd-2.2.9

#./configure
–prefix=/usr/local/apache2
–sysconfdir=/etc/httpd
–with-apr=/usr/local/apr/bin
–with-apr-utl=/usr/local/apr/bin
–enable-so
–enable-deflate=shared
–enable-expires=shared
–enable-rewrite=shared
–enable-static-support

# Make && make install

3. Configure Apache

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

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

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

Accessing the Apache server

Adding a self-starter

# echo "/usr/local/apache2/bin/apachectl start"»/etc/rc.d/rc.local

4. Install MySQL

New version of MySQL using the CMake tool to pre-compile configuration, you need to install the CMake tool, can be installed through the source code,
or install by command: Yum install CMake

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

# Cmake-dcmake_install_prefix=/usr/local/mysql-dinstall_datadir=/usr/local/mysql/data

# Make && make install

Continue with the following command

Cd/usr/local/mysql chown-r MySQL.   #将文件的所有属性改为root用户chgrp-R MySQL.    #将组属性改为mysql组./scripts/mysql_install_db--user=mysql   #用mysql用户创建授权表chown-R root.

The following command is optional and copies the MySQL configuration file to/etc

CP  SUPPORT-FILES/MY-DEFAULT.CNF  /etc/my.cnf

Start MySQL

Bin/mysqld_safe--user=mysql &

Start MySQL to see if it's successful

Netstat-tnl|grep 3306

To add the MySQL startup service to the system service

CP Support-files/mysql.server/etc/init.d/mysqld

You can now start MySQL using the following command

Service mysqld Start

Stop MySQL Service

Service Mysqld Stop

Restart MySQL Service

Service mysqld Restart

5. Install PHP

# cd/usr/local/src/5.4.14

#./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-mysqli=/usr/local/mysql/bin/mysql_config
–enable-soap
–enable-mbstring=all
–enable-sockets

# Make && make install

6. Configure PHP

Creating a configuration file

# CP Php.ini-production/usr/local/php/etc/php.ini

Using VIM to edit Apache configuration files

# vim/etc/httpd/httpd.conf

Add this piece of code

AddType application/x-httpd-php. php. phtml

Restart Apache

#/usr/local/apache2/bin/apachectl Restart

7. Testing

Write info.php file to view PHP configuration details

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

Phpinfo ();
?>

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

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.