redhat enterprise 6.2 LAMP 搭建
1.挂载光盘镜像 /dev/cdrom /mnt
2.配置本地yum源,vi /etc/yum.repos.d/rhel-source.repo
3.安装编译包必被的编译器 gcc gcc-c++ perl-core make
4.把所有编译安装包拷贝到linux下的目录,个人习惯移动到/usr/local/src 下
5.用tar zxvf命令解压缩安装包
6.用rpm -qa|grep 命令检查是否安装过 apache php mysql,如果有;用rpm -e * --nodeps命令卸载。
7.安装版本库文件,需要按照一定的顺序,libxml2 libmcrypt
>1,安装libxml2
>2,libmycrypt
>3,zlib
>4,libpng erro:zlib not install[到zlib目录下面执行make clean ./configure]
>5,jpeg 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
./configure \
--prefix=/usr/local/jpeg6 \
--enable-shared \ //建立共享库使用的GUN的libtool
--enable-static //建立静态库使用的GUN的libtool
>6,freetype
>7,autoconf ./configure
>8,gd
./configure \
--prefix=/usr/local/gd2 \
--with-zlib=/usr/local/zlib \
--with-jpeg=/usr/local/jpeg6 \
--with-png=/usr/local/libpng \
--with-freetype=/usr/local/freetype
如果报错:
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/tmp/gd-2.0.35'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/gd-2.0.35'
make: *** [all] Error 2
解决方案:
vi gd_png.c
找到#include "png.h"改成#include "/usr/local/libpng/include/png.h"
8.安装apache
./configure \
--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \ apach配置文件存放位置
--with-z=/usr/local/zlib \ zlib库文件位置
--with-include-apr \
捆绑ARP/APR-Util的副本
--enable-so \
以动态共享对象编译
--enable-deflate=shared \ 缩小传输编码支持
--enable-expires=shared \ 期满头控制
--enable-rewrite=shared \ 基于规则的url控制
--enable-static-support 建立静态链接版本的支持
echo "/usr/local/apache2/bin/apachectl start">>/etc/rc.d/rc.locall //添加自动启动脚本
9.安装Mysql
groupadd mysql
//新建mysql标准组
useradd -g mysql mysql //添加用户名为mysql的用户到mysql组
./configure \
--prefix=/usr/local/mysql \
--with-extra-charsets=all
如果报错[erro] configure: error: No curses/termcap library found //缺少ncurses安装包
解决办法:yum list|grep ncurses
yum install ncurses-devel
make && make install
cp support-files/my-medium.cnf /etc/my.cnf //创建mysql数据库服务器的配置文件
bin/mysql_install_db --user=mysql // //创建授权表
chown -R root . //将文件的所有属性改为root用户
chown -R mysql var //将数据目录的所有属性改为mysql用户
chgrp -R mysql . //将组属性改为mysql组
mysql
delete from mysql.user where host!='localhost' //删除非本地的数据库账户
set password for 'root'@'localhost'=password('mysql') //设置root账户的数据库密码为mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql & //启动数据库
netstat -tnl|grep 3306 //查看3306端口是否开启
echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &">>/etc/rc.d/rc.local
10.安装php
./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-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 /etc/httpd/httpd.conf //使用vi编辑apache配置文件
Addtype application/x-httpd-php .php .phtml //添加PHP文件支持