LAMP源码包安装

LAMP源码安装(参考http://www.cnblogs.com/mchina/archive/2012/11/28/2778779.html )

1.软件包

apr-1.4.5.tar.gz

apr-util-1.3.12.tar.gz

pcre-8.32.tar.gz

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.卸载默认的低版本环境

a. 卸载Apache

# rpm -qa | grep httpd


b. 卸载Mysql

# rpm -qa | grep mysql

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


c.卸载php

# rpm -qa | grep mysql

#rpm -e php-common-5.1.6-27.el5_5.3 --nodeps

#rpm -e php-ldap-5.1.6-27.el5_5.3 --nodeps

#rpm -e php-cli-5.1.6-27.el5_5.3 --nodeps

#rpm -e php-5.1.6-27.el5_5.3 --nodeps


3、关闭selinux,清空防火墙规则

关闭selinux

#setenforce 0  

关闭防火墙

#/etc/init.d/iptables stop

4.安装gcc

#gcc -v 查看是否安装

#yum install gcc

#yum install gcc-c++


四、软件安装


1、安装libxml2

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

# ./configure --prefix=/usr/local/libxml2

# make && make install

2、安装libmcrypt

# cd /usr/local/src/libmcrypt-2.5.8

# ./configure --prefix=/usr/local/libmcrypt

# make && make install

3、安装zlib

# cd /usr/local/src/zlib-1.2.3

# ./configure

# make && make install

4、安装libpng

# cd /usr/local/src/libpng-1.2.31

# ./configure --prefix=/usr/local/libpng

# make && make install

5、安装jpeg6

这个软件包安装有些特殊,其它软件包安装时如果目录不存在,会自动创建,但这个软件包安装时需要手动创建。

# 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、安装freetype

# cd /usr/local/src/freetype-2.3.5

# ./configure --prefix=/usr/local/freetype

# make

# make install

7、安装autoconf

# cd /usr/local/src/autoconf-2.61

# ./configure

# make && make install

8、安装GD库

# 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

出现错误:

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

分析:这个问题是因为gd库中的gd_png.c这个源文件中包含png.h时,png.h没有找到导致的。

解决:

在编译文件里

# vi gd_png.c

将include “png.h” 改成 include “/usr/local/libpng/include/png.h"

其中/usr/local/libpng/为libpng安装路径。

# make install


9.安装apr

#./configure --prefix=/usr/local/apr

#make

#make install


10.安装apr-util

#./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

#make

#make install


11.安装pcre

#./configure --prefix=/usr/local/pcre  

#make && make 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\

--with-apr=/usr/local/apr\

--with-apr-util=/usr/local/apr-util\

--with-pcre=/usr/local/pcre

# make && make install


启动Apache

# /usr/local/apache2/bin/apachectl start

关闭Apache

# /usr/local/apache2/bin/apachectl stop

查看80端口是否开启

# netstat -tnl|grep 80


配置开启启动

#cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

#chmod 755 /etc/init.d/httpd

/etc/rc.d/rc.local 中添加一行 /etc/init.d/httpd start

#echo '/etc/init.d/httpd start' >> /etc/rc.d/rc.local


加入服务

编辑/etc/init.d/httpd 加入下面两行:

#vi  /etc/init.d/httpd

# httpd        Startup script for the Apache HTTP Server

# chkconfig: - 85 15

#chkconfig httpd on


六.Mysql配置安装

a.安装

添加一个mysql标准组

# groupadd mysql

添加mysql用户并加到mysql组中

# useradd -g mysql mysql

# cd /usr/local/src/mysql-5.0.41

# ./configure \

--prefix=/usr/local/mysql/ \

--with-extra-charsets=all

可能缺少ncurses安装包报错

安装下

# yum install ncurses-devel


b.配置

创建MySQL数据库服务器的配置文件

# cp support-files/my-medium.cnf /etc/my.cnf

用mysql用户创建授权表,创建成功后,会在/usr/local/mysql目录下生成一个var目录

# /usr/local/mysql/bin/mysql_install_db --user=mysql

将文件的所有属性改为root用户

# chown -R root /usr/local/mysql

将数据目录的所有属性改为mysql用户

# chown -R mysql /usr/local/mysql/var

将组属性改为mysql组

# chgrp -R mysql /usr/local/mysql

启动数据库

# /usr/local/mysql/bin/mysqld_safe --user=mysql &





七.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


创建配置文件

# cp php.ini-dist /usr/local/php/etc/php.ini

使用vi编辑apache配置文件

# vi /etc/httpd/httpd.conf

添加这一条代码

Addtype application/x-httpd-php .php .phtml .phps


#/usr/local/php/etc/php.ini

register_globals = On          这条很重要不然访问php页面的时候提示下载


你可能感兴趣的:(linux,lamp,源码安装)