centos 源碼包搭建lamp環境

1,若是使用wget命令可能須要安裝wget:yum install wget
php

2,須要安裝gcc gcc-c++工具: yum install -y gcc gcc-c++mysql

可能須要安裝下面的工具:php安裝時請按照本身的須要安裝相應的軟件,配置相應的參數c++

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-develsql

3,下載所需工具包:shell

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

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

4將之前的刪除:yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docsapp

5,分別進行便於安裝:curl

    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致使的錯誤。
一、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擴展:

一、下載 文件 或者 進入 在PHP源碼包中進入ext/pdo_mysql

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

二、解壓文件
tar zxvf PDO_MYSQL-1.0.2.tgz

三、配置和編譯文件
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 編譯的時候注意你本身的安裝目錄在哪裏
三、安裝到PHP配置下

把這個記住,而後打開 php.ini文件,
並添加一行

extension=pdo_mysql.so

相關文章
相關標籤/搜索