Lamp 安裝(CentOS6.6, php-5.4.39, httpd-2.4.12, mysql-5.6.24)

軟件版本:

pcre-8.36.tar.gz
apr-1.5.1.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.12.tar.bz2php

mysql-5.6.24.tar.gzhtml

libxml2-2.7.8.tar.gz
libpng-1.5.12.tar.gz
freetype-2.4.10.tar.gz
jpegsrc.v7.tar.gz
gd-2.0.35.tar.gz
php-5.4.39.tar.gzmysql

 

百度雲下載地址:http://pan.baidu.com/s/1dDGT9KHsql

步驟概要:

一、apacheapache

二、mysqljson

三、phpvim

四、驗證瀏覽器

 

備註app

全部操做(未特殊說明)都是以:/usr/local/src 爲操做目錄, 且全部軟件包均在此目錄下。dom

 

具體步驟:

安裝apache

軟件包依賴:pcre, apr, apr-util

一、prce 安裝(安裝目錄,以未來安裝httpd 的目錄(/usr/local/services/httpd-2.4.12/)爲基準,而且安裝到plugins目錄下,方便未來同型號機器移植

tar zxf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/usr/local/services/httpd-2.4.12/plugins/pcre-8.36
make

make install

 

二、apr, apr-util 在apache的安裝文檔中有具體操做說明,以下

tar zxf apr-1.5.1.tar.gz -C ./httpd-2.4.12/srclib/
tar zxf apr-util-1.5.4.tar.gz -C ./httpd-2.4.12/srclib/
cd httpd-2.4.12/srclib/
ln -s apr-util-1.5.4/ apr-util
ln -s apr-1.5.1 apr

三、安裝apache

tar zxf httpd-2.4.12.tar.gz
cd httpd-2.4.12
./configure \ --prefix=/usr/local/services/httpd-2.4.12 \ --with-pcre=/usr/local/services/httpd-2.4.12/plugins/pcre-8.36 \ --with-included-apr \ --enable-rewrite=shared \ --enable-so

make

make install

 

安裝mysql

準備條件:cmake, ncurses-devel, bison, 若是未安裝直接yum install xxx

tar zxf mysql-5.6.24.tar.gz

cd mysql-5.6.24 cmake \ -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/services/mysql-5.6.24 \ -DMYSQL_DATADIR:PATH=/data/mysql \ -DEXTRA_CHARSETS=all \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DMYSQL_USER=mysql \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_SSL=yes make make install #添加軟鏈接 ln -s /usr/local/services/mysql-5.6.24/ mysql #添加PATH echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile #修改目錄權限 mkdir -p /data/mysql chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysql #拷貝配置文件 cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf # 添加用戶 groupadd mysql useradd -g mysql mysql #設置my.conf 在[mysqld]中設置 datadir=/data/mysql #初始化 /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql #設置mysql服務 cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chkconfig --add mysqld service mysql start #空密碼登錄mysql mysql #mysql 設置權限,同一個用戶在不一樣機器上的密碼可能不一樣。 grant all privileges on *.* to root@'localhost' identified by '123456'; grant all privileges on *.* to root@'%' identified by '123456'; # root密碼登錄 mysql -uroot -p123456

 

注意:

安裝完成後首次登錄,報錯 Segmentation fault
這是一個bug: https://bugs.launchpad.net/percona-server/+bug/1201123
解決:
一、源碼包裏,編輯文件 cmd-line-utils/libedit/terminal.c, 找到代碼段(869行) char buf[TC_BUFSIZE]; 將其註釋,找到下面的變量(879行) area = buf; ,更改成 area = NULL; 
二、從新編譯便可

安裝php

分爲3步

一、libxml2

二、gd2

三、php

 

安裝libxml2

tar zxf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/libxml2-2.7.8

 

安裝gd

包括:libpng , freetype,  jpeg, gd

安裝libpng

tar zxf libpng-1.5.12.tar.gz
cd libpng-1.5.12 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12

安裝freetype

tar zxf freetype-2.4.10.tar.gz 
cd freetype-2.4.10 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10

 

安裝jpeg

tar zxf jpegsrc.v7.tar.gz 
cd jpeg-7 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/jpeg-7

 

安裝gd

tar zxf gd-2.0.35.tar.gz
cd gd-2.0.35 ./configure \ --prefix=/usr/local/services/php-5.4.39/plugins/gd-2.0.35 \ --with-freetype=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10 \ --with-png=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12 \ --with-jpeg=/usr/local/services/php-5.4.39/plugins/jpeg-7

 

安裝php

./configure \
--prefix=/usr/local/services/php-5.4.39 \
--with-mysql=/usr/local/services/mysql-5.6.24 \
--with-mysqli=/usr/local/services/mysql-5.6.24/bin/mysql_config \
--with-pdo-mysql=/usr/local/services/mysql-5.6.24 \
--with-apxs2=/usr/local/services/httpd-2.4.12/bin/apxs \
--with-libxml-dir=/usr/local/services/php-5.4.39/plugins/libxml2-2.7.8 \
--with-gd=/usr/local/services/php-5.4.39/plugins/gd-2.0.35 \
--with-freetype-dir=/usr/local/services/php-5.4.39/plugins/freetype-2.4.10 \
--with-png-dir=/usr/local/services/php-5.4.39/plugins/libpng-1.5.12 \
--with-jpeg-dir=/usr/local/services/php-5.4.39/plugins/jpeg-7 \
--enable-mbstring \
--enable-maintainer-zts \
--enable-sockets \
--enable-pcntl \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-soap \
--enable-shmop \
--enable-bcmath \
--enable-zip \
--enable-calendar \
--enable-ctype \
--enable-dom \
--enable-filter \
--enable-gd-native-ttf \
--enable-hash \
--enable-json \
--enable-posix \
--enable-shared \
--enable-simplexml \
--enable-static \
--enable-tokenizer \
--enable-xml \
--enable-xmlwriter \
--enable-pdo \
--enable-inline-optimization \
--enable-mysqlnd \
--enable-exif



make

make install

 

編譯遇到錯誤:

In file included from /kk/php-5.4.0/ext/gd/gd.c:103:
/kk/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putc’:

解決(google後, bug: https://bugs.php.net/bug.php?id=55224):

vim /usr/local/services/php-5.4.39/plugins/gd-2.0.35/include/gd_io.h
中(14行) typedef struct gdIOCtx  結構體中添加:void (*data); 修改後以下: typedef struct gdIOCtx { int (*getC) (struct gdIOCtx *); int (*getBuf) (struct gdIOCtx *, void *, int); void (*putC) (struct gdIOCtx *, int); int (*putBuf) (struct gdIOCtx *, const void *, int); /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */ int (*seek) (struct gdIOCtx *, const int); long (*tell) (struct gdIOCtx *); void (*gd_free) (struct gdIOCtx *); void (*data); }

從新編譯,編譯成功

配置與測試

一、建立軟鏈接與添加PATH

ln -s /usr/local/services/php-5.4.39 php
ln -s /usr/local/services/httpd-2.4.12 apache ln -s /usr/local/services/mysql-5.6.24 mysql echo "PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin" >> /etc/profile source profile

 

二、設置php.ini

cp php.ini-development /usr/local/php/lib/php.ini

 

三、配置apache httpd.conf 支持php文件解析

echo "AddType application/x-httpd-php .php" >> /usr/local/apache/conf/httpd.conf

四、構建文件測試

vim /usr/local/apache/htdocs/phpinfo.php
<?php phpinfo();

五、重啓apache

/usr/local/apache/bin/apachectl restart

六、訪問驗證

瀏覽器訪問: http://127.0.0.1/phpinfo.php

顯示以下:

 

 

2015年4月16日 更新支持mysql-pdo

相關文章
相關標籤/搜索