centos 源码包搭建lamp环境

1,如果使用wget命令可能需要安装wget:yum install wget

2,需要安装gcc gcc-c++工具: yum install -y gcc gcc-c++

可能需要安装下面的工具:php安装时请按照自己的需要安装相应的软件,配置相应的参数

yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel  pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel

3,下载所需工具包:

    1,wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz

    2,wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz

    3,wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.gz

4将以前的删除:yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs

5,分别进行便于安装:

    1,tar zxvf apr-1.5.0.tar.gz  cd apr-1.5.0  ./configure --prefix=/usr/local/apr  make make install

    这里可能出现错误:

    rm: cannot remove `libtoolT': No such file or directory

    解决方法如下:

        打开configure文件

        找到30055(不同的版本可能位置不一样)

        将这行代码注释掉

        # $RM "$cfgfile"

        然后重新编译,问题可以解决

    2,tar zxvf apr-util-1.5.3.tar.gz cd apr-util-1.5.3 ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/bin/apr-1-config   make && make install

    3,tar zxvf pcre-8.34.tar.gz  cd pcre-8.34  ./configure --prefix=/usr/local/pcre  make && make install

6,下载apache软件:wget http://apache.org/dist/httpd/httpd-2.4.9.tar.gz

tar zxvf httpd-2.4.9.tar.gz

cd httpd-2.4.9

编译安装apache :./configure --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 启动

7,如果不成功,可能是因为防火墙原因:

    vi /etc/sysconfig/iptables

    将规则加入,打开80端口:

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

    重启防火墙:service iptables restart | /etc/init.d/iptables restart

8,安装mysql

下载 mysql-5.6.17.tar.gz

    wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz

    

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSIONshell> cmake .
shell> make
shell> make install# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

编译时可能报错:

Curses library not found. Please install appropriate package

yum -y install ncurses-devel

删除当前的mysql文件,重新解压,再cmake .应该就可以了  

如果出现:Warning: Bison executable not found in PATH错误

yum install bison

编译参数解释:
--prefix=/usr/local/mysql/:指定安装位置
--localstatedir=/usr/local/mysql/data:指定数据库文件位置
--without-debug:禁用调用模式
--with-unix-socket-path=/tmp/mysql.sock:指定sock文件位置
--with-client-ldflags=-all-static:
--with-mysqld-ldflags=-all-static:以纯静态方式编译服务端和客户端
--enable-assembler:使用一些字符函数的汇编版本
--with-extra-charsets=gbk,gb2312,utf8 :gbk,gb2312,utf8字符支持
--with-pthread:强制使用pthread库(posix线程库)

9,安装php5.5.10

  下载php5.5.10源码包:

        在编译php之前,先要解决两个问题:centos 6上libmcrypt的安装和可能有些系统找不到libiconv导致的错误。
1、centos 6官方源已经没有libmcrypt的rpm包,我们这里选择编译安装,当然你也可以导入第三方源安装(centos 5略过此步)。

       wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FMCrypt%2F2.6.8%2F&ts=1396149713&use_mirror=jaist

       wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmhash%2Ffiles%2Fmhash%2F0.9.9.9%2F&ts=1396149905&use_mirror=jaist

      wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%2F&ts=1396149970&use_mirror=jaist

   tar xzf mcrypt-2.5.8.tar.gz

   tar zxvf mhash-0.9.9.9.tar.gz

   tar zxvf libmycrypt-2.5.5.tar.gz

   //安装libmcrypt

   cd libmcrypt-2.5.8 

   ./configure --prefix=/usr

   make && make install

  //安装mhash-0.9.9.9.tar.gz

   cd mhahs-0.9.9.9

  ./configure --prefix=/usr

   make && make install

  //安装mcrypt

  cd mcrypt2.5.8

  ./configure

2,解决可能出现的libiconv错误。

 wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.1.tar.gz

tar zxvf libiconfv-1.9.1.tar.gz

cd libiconv-1.9.1

./configure --prefix=/usr/local/libiconv

 make && make install

可能出现:configure: error: xml2-config not found. Please check your libxml2 installation

    重新安装libxml2和libxml2-devel包

    yum install libxml2

    yum install libxml2-devel -y



3,安装php

下载php:

    http://bd1.php.net/get/php-5.5.10.tar.gz/from/this/mirror

    tar zxvf php-5.5.10

    cd php-5.5.10

    ./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-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-gettext --with-mhash --enable-mbstring --with-mcrypt --enable-soap --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --without-pear 

--with-jpeg-dir=/usr/local/jpeg6/ 

   make && make install

   编译参数解释:
--prefix=/usr/local/php:设置安装路径
--with-apxs2=/usr/local/apache/bin/apxs:编译共享的 Apache 2.0 模块
--with-config-file-path=/etc:指定配置文件php.ini地址
--with-config-file-scan-dir=/etc/php.d:指定额外的ini文件目录
--with-openssl:编译OpenSSL支持
--with-zlib:编译zlib支持
--enable-bcmath:启用BC风格精度数学函数
--with-bz2:BZip2支持
--with-curl:CRUL支持
--enable-ftp:FTP支持
--with-gd:GD支持
--enable-gd-native-ttf:启用TrueType字符串函数
--with-gettext:启用GNU gettext支持
--with-mhash:mhash支持
--enable-mbstring:启用支持多字节字符串
--with-mcrypt:编译mcrypt加密支持
--enable-soap:SOAP支持
--enable-zip:启用zip 读/写支持
--with-iconv=/usr/local/libiconv:iconv支持
--with-mysql=/usr/local/mysql:启用mysql支持
--without-pear:不安装PEAR

将源码包中的配置文件复制到/etc下:cp /software/php-5.5.10/php.ini-development /etc/php.ini

在apache2配置文件中添加php的类型解析:vi /usr/local/apache2/conf/httpd.conf   

Addtype application/x-httpd-php .php

重启apache:/usr/local/apache2/bin/apachectl restart

4,安装mysql-pdo扩展:

1、下载 文件 或者 进入 在PHP源码包中进入ext/pdo_mysql

http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

2、解压文件
tar zxvf PDO_MYSQL-1.0.2.tgz

3、配置和编译文件
cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make
make install

注: 我的PHP安装在 : /usr/local/php/ mysql 安装在 : /usr/local/mysql 编译的时候注意你自己的安装目录在哪里
3、安装到PHP配置下

把这个记住,然后打开 php.ini文件,
并添加一行

extension=pdo_mysql.so


   



转载于:https://my.oschina.net/lnmpstudy/blog/214286

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值