First, Lamp introduction
Lamp is a set of free, open-source software used to build dynamic websites, including:
L (Linux): is an open-source operating system;
A (Apache): is an open source web application software;
M (Mysql): is an open source database management system software;
P (Php/perl/python): is an open source tool used to perform web dynamic requests, and PHP is used in this article.
Second, pre-installation work
1, install the most basic compilation tools GCC, gcc-c++
# yum-y Install gcc gcc-c++
2. Empty the iptables rule chain to prevent some services from being inaccessible
# iptables-f
# Iptables-x
# iptables-z
# Service Iptables Save
3. Adjust SELinux to premissive or disable
# Setenforce 0
# sed-i ' s/selinux=enforcing/selinux=permissive/'/etc/selinux/config
Third, compile and install Apache
First install APR, APR-UTIL,APR is a portable runtime, the purpose is to provide a common unified operation function interface for most platforms.
1. Download apr-1.5.1.tar.gz
wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.1.tar.gz
2. Download apr-util-1.5.4.tar.gz
wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
3, compile and install apr-1.5.1.tar.gz, apr-util-1.5.4.tar.gz
(1) Compile and install Apr
# Tar XF apr-1.5.1.tar.gz
# CD apr-1.5.1
#./configure--prefix=/usr/local/apr #指定安装目录为/USR/LOCAL/APR
If the following error occurs:
config.status:executing Libtool Commands
Rm:cannot remove ' Libtoolt ': No such file or directory
Workaround:
Open configure, remove $RM $cfgfile, and run again./configure--PREFIX=/USR/LOCAL/APR
# make; Make install
(2) Compile and install Apr-util
# Tar XF apr-util-1.5.4.tar.gz
# CD apr-util-1.5.4
#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
# make; Make install
(3) Compile and install Apache
Download httpd-2.4.10.tar.gz
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.10.tar.gz
# Tar XF httpd-2.4.10.tar.gz
# CD httpd-2.4.10
#./configure--prefix=/usr/local/apache \
--WITH-APR=/USR/LOCAL/APR \
--with-apr-util=/usr/local/apr-util \
--enable-modules=all \
--enable-cache=static \
--enable-file-cache=static \
--enable-cache-disk=static \
--enable-ssl=static \
--enable-so
Compilation parameter Description:
--enable-modules=all #指定静态编译所有模块
--enable-mods-shared=all #指定动态编译所有模块
--enable-cache=static #指定静态编译该模块
--enable-so #动态加载选项, which means that you can dynamically load your own compiled modules in a configuration file
Note: When the--enable-modules=all and--enable-mods-shared=all two parameters are present, unless
The--enable-[module]=static method is specifically specified as static compilation, otherwise all modules will be dynamically compiled.
If the following error occurs:
Checking for pcre-config ... false
Configure:error:pcre-config for Libpcre not found. PCRE is required and available from http://pcre.org/
Because Apache's rewrite module and HTTP core module use the PCRE regular expression syntax. Two installation packages Pcre and pcre-devel need to be installed. The first installation package provides a compiled version of the library, while the second provides the development phase of the header file and the source of the compiled project
Code.
Workaround:
# yum-y Install Pcre Pcre-devel
or download the pcre-8.34.tar.gz source package to compile the installation
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
If the following error occurs:
Configure:WARNING:OpenSSL version is too old
No
Checking whether to enable Mod_ssl ... Configure:error:mod_ssl have been requested but can not is built due to prerequ ISite Failures
Workaround:
# yum Install Openssl-devel
After all dependencies have been resolved, re-execute the above./configure, the parameters are as above, then
# make; Make install
(4) Verifying Web Services
Execute the following command to start the Web service:
#/usr/local/apache/bin/apachectl Start
# echo "Export path= $PATH:/usr/local/apache/bin" >> ~/.BASHRC #修改PATH变量 to include the Apachectl path into path
# source ~/.BASHRC #重新读取 ~/.BASHRC
# apachectl Restart #成功
You can also start by doing the following:
# CP/USR/LOCAL/APACHE/BIN/APACHECTL/ETC/INIT.D/HTTPD
# chmod +X/ETC/INIT.D/HTTPD
# vim/etc/init.d/httpd #编辑该文件加入高亮显示的两行文件
#!/bin/sh
#
# chkconfig:345 10 90
# description:activates/deactivates Apache Web Server.
# Licensed to the Apache software Foundation (ASF) under one or more
# Service httpd Restart #既可用此方法控制http服务
Verify that the Web service started successfully by executing the following command:
# NETSTAT-TNLP | grep ": 80"
TCP 0 0::: +:::* LISTEN 57802/httpd
Native Access Web service:
# Curl http://127.0.0.1
This completes the Apache compilation installation.
Iv. Compiling and installing MySQL
This installation uses MySQL's Universal binary format package to install mysql-5.5.41-linux2.6-x86_64.tar.gz
Install the Libaio and libaio-devel two packages before installation, Libaio is an asynchronous non-blocking interface under Linux, it provides asynchronous non-blocking way to read and write files, read-write efficiency is high, MySQL relies on these two packages.
# yum Install Libaio Libaio-devel
Install MySQL:
# Tar XF mysql-5.5.41-linux2.6-x86_64.tar.gz-c/usr/local/
# cd/usr/local
# ln-s Mysql-5.5.41-linux2.6-x86_64/mysql
# groupadd-g 306 MySQL #创建mysql组, specify GID as 306
# useradd-r-u 306-g 306 mysql #创建mysql账号, specifying UID also 306
# CD MySQL #切换到mysql目录
# Chown-r Mysql.mysql. #将目录中所有文件的属主属组改为mysql
#./scripts/mysql_install_db--user=mysql #以mysql的身份初始化mysql
# Chown-r Root.mysql. #将目录中所有文件的属主改为root
# chown-r MySQL data/#将数据库目录属主改为mysql
# CP./SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF #拷贝主配置文件到/etc under the name my.cnf
#./bin/mysqld_safe--user=mysql &
# CP./SUPPORT-FILES/MYSQL.SERVER/ETC/INIT.D/MYSQLD #拷贝控制脚本到/ETC/INIT.D
# Service Mysqld Restart #重启mysql
# NETSTAT-TNLP | grep ": 3306" #检查mysql是否启动
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 60458/mysqld
#/usr/local/mysql/bin/mysqladmin-u root password "123456" #创建管理员账号
Installing MySQL is a reference to the Install-binary file in the MySQL source files directory
MySQL installation is complete at this point
V. Compile and install PHP
Installing PHP depends on GD, Libmcrypt, LIBXML2, and GD needs to rely on libpng, JPEG, LIBXPM, FreeType, zlib, fontconfig so
You need to install libpng, JPEG, FreeType, Fontconfig, Zlib, libxpm, and so on, with Yum installed:
# yum-y Install libpng libpng-devel #gd库的png支持 (image display)
# yum-y Install zlib zlib-devel # support Zlib (compression and decompression)
# yum-y Install FreeType freetype-devel #freetype支持 (font)
# yum-y Install JPEG jpge-devel #gd库的jpeg支持 (image display)
# yum Install fontconfig fontconfig-devel #gd库的fontconfig (font-related libraries)
# yum Install libxpm libxpm-devel #gd库的Xpm支持 (image display)
1. Compile and install GD
#./configure--prefix=/usr/local/gd \
--with-png \
--with-freetype \
--with-jpeg \
--with-fontconfig \
--with-xpm
# make; Make install
2, installation LIBXML2
# yum Install libxml2 libxml2-devel #解析XML文档的函数库
3, Installation Libmcrypt
Download libmcrypt-2.5.7.tar.gz
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
# Tar XF libmcrypt-2.5.7.tar.gz
# CD libmcrypt-2.5.7
#./configure--prefix=/usr/local/libmcrypt
# make; Make install
4. Compile and install PHP
(1) Download php-5.6.4.tar.gz
wget Http://cn2.php.net/get/php-5.6.4.tar.gz/from/this/mirror
./configure--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS \
--WITH-CONFIG-FILE-PATH=/ETC \
--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D \
--with-libxml-dir \
--WITH-OPENSSL \
--with-zlib-dir \
--with-pcre-dir \
--WITH-GD \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-xpm-dir \
--with-freetype-dir \
--enable-mbstring \
--with-mcrypt=/usr/local/libmcrypt \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--ENABLE-SOAP \
--enable-sockets \
Some configuration options are described:
--with-apxs2=/usr/local/apache/bin/apxs
The APXS function is to use the LoadModule directive in MOD_SO to load the specified module to Apache, which requires Apache to open the--enable-so module
--with-config-file-path=/etc #配置文件路径, specify php.ini file
--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D #php其它配置文件的存放路径
--with-mysqli=/usr/local/mysql/bin/mysql_config #mysqli文件路径, optimization support
--enable-mbstring #多字节, String support
--enable-sockets #打开套接字的支持
--enable-soap #打开soap协议的支持
# make; Make install
# CP Php.ini-production/etc/php.ini #拷贝配置文件到/etc, named PHP.ini
# MKDIR/ETC/PHP.D #创建php其它配置文件的目录
(2) Change the Apache configuration file so that it can parse the PHP file
# vim/usr/local/apache/conf/httpd.conf
Locate the following line:
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add the following two lines below:
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps
Locate the following line:
DirectoryIndex index.html
Modified to:
DirectoryIndex index.html index.php
Save exit.
To restart the Web service:
# Service httpd Restart
Edit/usr/local/apache/htdocs/index.html, add the following, and rename to index.php
# vim/usr/local/apache/htdocs/index.html
<?php
Phpinfo ();
?>
# mv/usr/local/apache/htdocs/index.html/usr/local/apache/htdocs/index.php
Client authentication, which occurs, is configured successfully.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/57/AB/wKiom1Shg8qCcoFwAAUWVZOASYI734.jpg "title=" {[ N8whfun) SQ (wf@}9 ' x8tj.png "alt=" Wkiom1shg8qccofwaauwvzoasyi734.jpg "/>
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
CENTOS6.5-X86_64 Platform Lamp Configuration