搭建 lamp环境【apache2.4.12 + php5.5.12 + mysql5.6.13】

centos 6.6

1. Apache/2.4.12
2. php 5.5.12
3. mysql 5.6.13

# --------------------------------------------------------------------------------
# prepare

# 1. install g++
yum list gcc-c++
yum install gcc-c++.x86_64

# 2. install ncurses
yum list ncurses-devel
yum install ncurses-devel.x86_64

# 3. install httpd-devel
yum list httpd-devel
yum install httpd-devel.x86_64

# 4. install libXpm-devel.x86_64 [for php] 
#    install php if (error: X11/xpm.h: No such file or directory)  http://www.th7.cn/Program/php/201406/213224.shtml
yum list libXpm-devel
yum install libXpm-devel.x86_64

# 5. install cmake
cd /usr/local/src && wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -zxvf cmake-2.8.10.2.tar.gz && cd cmake-2.8.10.2 && ./bootstrap && gmake install && cd -

# 6. install libtool
cd /usr/local/src && wget http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
tar zxvf libtool-2.2.6a.tar.gz && cd libtool-2.2.6 && ./configure && make && make install
# almost view the blog http://www.cnblogs.com/mophee/archive/2013/03/19/2969456.html

# 7. install sz rz
yum install lrzsz

#
# --------------------------------------------------------------------------------
# 1. download apache's ref apache mysql php
cd /usr/local/src
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
wget http://down1.chinaunix.net/distfiles/zlib-1.2.3.tar.gz
wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.12.tar.gz

# 2. extend package and install apache ref
tar zxvf apr-1.4.5.tar.gz && cd apr-1.4.5 && ./configure --prefix=/usr/local/apr && make && make install && cd -
tar zxvf apr-util-1.3.12.tar.gz && cd apr-util-1.3.12 && ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install && cd -
unzip -o pcre-8.10.zip && cd pcre-8.10 && ./configure --prefix=/usr/local/pcre && make && make install && cd -
tar zxvf zlib-1.2.3.tar.gz && cd zlib-1.2.3 && CFLAGS="-O3 -fPIC" ./configure && make && make install && cd -

# 3. install apache 
tar zxvf httpd-2.4.12.tar.gz && mv httpd-2.4.12 apache2
mkdir -p /usr/local/lamp/apache2
cd /usr/local/src/apache2 
./configure --prefix=/usr/local/lamp/apache2 --sysconfdir=/usr/local/lamp/apache2/conf --with-z=/usr/local/zlib --disable-userdir --enable-so --enable-rewrite=shared --enable-deflate=shared --enable-expires=shared --enable-static-support  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 
./configure \
--prefix=/usr/local/lamp/apache2 \           apache安装路径
--sysconfdir=/usr/local/lamp/apache2/conf \  httpd配置文件路径
--with-z=/usr/local/zlib \                  依赖的zlib
--with-included-apr \                       使用捆绑apr的副本(可以不装)
--disable-userdir \                         请求的映象到用户特定的目录
--enable-so \                               以动态共享对象编译(必须安装)
--enable-rewrite=shared \                   基于规则的url操控
--enable-deflate=shared \                   缩小传输编码的支持
--enable-expires=shared \                   期满头控制
--enable-static-support  \                  建立一个静态链接版本的支持
--with-apr=/usr/local/apr \                 依赖的apr
--with-apr-util=/usr/local/apr-util \       依赖的apr-util
--with-pcre=/usr/local/pcre                 依赖的pcre
make && make install
vim /usr/local/lamp/apache2/conf/httpd.conf
# 4. edit conf like
- #ServerName www.example.com:80
+ ServerName www.example.com:80
-
+ AddType application/x-httpd-php .php

# 5. start and test apache
cd /usr/local/lamp/apache2/bin && ./apachectl start
curl localhost
# show this for success 
# <html><body><h1>It works!</h1></body></html>
# almost view the blog http://blog.163.com/wb_zhaoyuwei/blog/static/183075439201341511589479/

#
# --------------------------------------------------------------------------------
# install mysql, >=mysql5.5 must cmake
# 1. download mysql 
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz
# 2. add user and group
groupadd gmysql
useradd -g gmysql umysql
# ./configure --prefix=/usr/local/lamp/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-assembler --disable-shared --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-staticm --with-embedded-server --with-innodb --with-extra-charsets=gbk,gb2312,big5 --without-debug CFLAGS=-O3 -mcpu=pentium4 CXXFLAGS=-O3 -march=pentium4 -felide-constructors -fno-exceptions -fno-rtti CXX=gcc
# 3. install mysql
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/lamp/mysql \
-DSYSCONFDIR=/usr/local/lamp/mysql/conf \
-DMYSQL_DATADIR=/usr/local/lamp/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=umysql \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_SSL=bundled
make && make install
cd /usr/local/lamp/mysql && chown -R root:gmysql . && chown -R umysql:gmysql data
# 4. default conf
cd /usr/local/lamp/mysql && cp ./support-files/my-default.cnf /etc/my.cnf
# init authority table
cd /usr/local/lamp/mysql && ./scripts/mysql_install_db --user=umysql
cd /usr/local/lamp/mysql && ln -s ./bin/mysql /usr/bin
# 5. start mysqld with 'umysql'
cd /usr/local/lamp/mysql && su umysql && ./bin/mysqld
# almost view the blog http://www.cnblogs.com/xiaoit/p/3994092.html
# 6. update root password to 123456, default is blank
./bin/mysql
mysql> update mysql.user set password=password('123456') where User="root" and Host="localhost";
mysql> flush privileges; 


#
#--------------------------------------------------------------------------------
# download php's ref and php
wget http://down1.chinaunix.net/distfiles/jpegsrc.v6b.tar.gz
wget http://down1.chinaunix.net/distfiles/libpng-1.5.13.tar.xz
wget http://ftp.yzu.edu.tw/nongnu//freetype/freetype-old/freetype-2.3.12.tar.gz
wget http://down1.chinaunix.net/distfiles/gettext-0.17.tar.gz
wget http://down1.chinaunix.net/distfiles/libxml2-2.7.4.tar.gz
wget http://down1.chinaunix.net/distfiles/gdbm-1.9.1.tar.gz
wget http://down1.chinaunix.net/distfiles/libiconv-1.14.tar.gz
#wget http://down1.chinaunix.net/distfiles/gd-2.0.33.tar.gz   #can't
wget https://codeload.github.com/libgd/libgd/tar.gz/gd-2.1.1  #must
#wget http://cn2.php.net/distributions/php-5.6.9.tar.gz     # too new to match apache2
wget http://cn2.php.net/distributions/php-5.5.12.tar.gz     #

# install php's ref
tar -zvxf jpegsrc.v6b.tar.gz && cd jpeg-6b 
cp /usr/local/share/libtool/config/config.sub ./ && cp /usr/local/share/libtool/config/config.guess ./
mkdir -p /usr/local/jpeg6/include && mkdir -p /usr/local/jpeg6/lib && mkdir -p /usr/local/jpeg6/bin && mkdir -p /usr/local/jpeg6/man/man1
./configure -prefix=/usr/local/jpeg6/ --enable-shared -enable-static && make && make install && make install-lib && cd -
tar -xvJf libpng-1.5.13.tar.xz && cd libpng-1.5.13 && ./configure -prefix=/usr/local/libpng && make && make install && cd -
tar -zvxf freetype-2.3.12.tar.gz && cd freetype-2.3.12 && ./configure -prefix=/usr/local/freetype && make && make install && cd -
tar -zvxf gettext-0.17.tar.gz && cd  gettext-0.17 && ./configure -prefix=/usr/local/gettext --enable-shared && make && make install && cd -
tar -zvxf libxml2-2.7.4.tar.gz && cd libxml2-2.7.4 && ./configure -prefix=/usr/local/libxml2 --enable-shared && make && make install && cd -
tar -zvxf gdbm-1.9.1.tar.gz && cd gdbm-1.9.1 && ./configure -prefix=/usr/local/gdbm --enable-shared && make && make install && cd -
tar -zvxf libiconv-1.14.tar.gz && cd libiconv-1.14 && ./configure -prefix=/usr/local/libiconv && make && make install && cd -
#tar -zvxf gd-2.0.33.tar.gz && cd gd-2.0.33 && ./configure -prefix=/usr/local/gd2 -with-zlib=/usr/local/zlib --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg6 --with-freetype=/usr/local/freetype && make && make install && cd -
mv gd-2.1.1 gd-2.1.1.tar.gz && tar zxvf gd-2.1.1.tar.gz && cd libgd-gd-2.1.1 && cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/libgd2 && make && make install && cd -
# install jpeg6 if (libtool:Command not found) see the blog http://www.2cto.com/os/201403/289110.html (cp config.sub config.guess ./jpeg-6b)
# install gd2 if (error: ZLib not installed) see the blog http://blog.csdn.net/sebarsunny/article/details/6123179 (./configure without the '-prefix')
# install gd2 if (error: png.h: No such file or directory) vim Makefile serach include ,and add -I/usr/local/libpng/include at the end line.
# install gd2 must vision >= libgd.so.2.1.0 
# summary install gd2, use '--with-gd' replace '--with-gd=/usr/local/libgd2' 
## export LDFLAGS="-L/usr/local/zlib/lib"   not test yet
## export CPPFLAGS="-I/usr/local/zlib/include" not test yet

# install php
tar –zvxf php-5.5.12.tar.gz && cd php-5.5.12
./configure \
-prefix=/usr/local/lamp/php \
-with-apxs2=/usr/local/lamp/apache2/bin/apxs \
-with-jpeg-dir=/usr/local/jpeg6 \
--with-gettext \
-enable-mbstring \
-with-libxml-dir=/usr/local/libxml2 \
-with-png-dir=/usr/local/libpng \
-with-zlib-dir=/usr/local/zlib \
#--with-gd=/usr/local/libgd2 \
--with-gd \
--with-freetype-dir=/usr/local/freetype \
-enable-trace-vars \
--with-mysql=/usr/local/lamp/mysql \
-with-gdbm-dir=/usr/local/gdbm \
--enable-wddx  \
--with-iconv \
-enable-sockets \
-disable-ipv6
make && make install
# install php if (error: X11/xpm.h: No such file or directory)  see prepare:4.
# install php if (undefined symbol: unixd_config)   see the blog http://blog.sina.com.cn/s/blog_5f66526e0100jac7.html
cp php.ini-dist /usr/local/php/lib/php.ini

#
#--------------------------------------------------------------------------------

你可能感兴趣的:(apache,mysql,PHP,lamp,cmake)