操作系统是Debian7.7 X64,系统是最小化安装。
首先安装基本的系统组件
apt-get install gcc g++ cmake automake libncurses5-dev ntpdate bison chkconfig curl iftop sysstat dstat iotop zlib1g-dev libssl1.0.0 libssl-dev openssl libcurl4-openssl-dev pkg-config libgdbm-dev -y
#安装zlib
tar xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make && make install
cd ..
#安装pcre
tar xzvf pcre-8.36.tar.gz
cd pcre-8.36/
./configure --prefix=/usr/local/pcre
make && make install
cd ..
#安装Apache
tar xzvf httpd-2.4.10-deps.tar.gz
tar xzvf httpd-2.4.10.tar.gz
cd httpd-2.4.10/
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --with-pcre=/usr/local/pcre --with-zlib=/usr/local/zlib
make && make install
cd ..
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
#修改Apache开机脚本,以只支持debian,将这些配置文件写到httpd的开头即可
#!/bin/sh
### BEGIN INIT INFO
# Provides: apache2
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the apache2 daemon
# Description: starts apache2 using start-stop-daemon
### END INIT INFO
chkconfig --add httpd
chkconfig httpd on
#安装mysql
groupadd -g 600 mysql
useradd -g mysql -u 600 -s /usr/sbin/nologin mysql
tar xzvf mysql-5.6.21.tar.gz
cd mysql-5.6.21/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_DEBUG=0
make -j 4
make install
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .
cd scripts/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
#修改my.cnf
vim /usr/local/mysql/my.cnf
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
echo "/usr/local/mysql/lib">> /etc/ld.so.conf
ldconfig
/etc/init.d/mysqld start
echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile
source /etc/profile
#安装freetype
tar xzvf freetype-2.4.9.tar.gz
cd freetype-2.4.9
./configure --prefix=/usr/local/freetype
make && make install
cd ..
#安装libpng
tar xzvf libpng-1.5.10.tar.gz
cd libpng-1.5.10
./configure --prefix=/usr/local/libpng
make && make install
cd ..
#安装jpeg
tar xzvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/usr/local/jpeg9
make && make install
cd ..
#安装gd
tar xzvf 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/jpeg9 --with-gd=shared
#修改文件
vim gd_png.c 修改第十五行如下
#include "/usr/local/libpng/include/png.h" /* includes zlib.h and setjmp.h */
make && make install
cd ..
#安装libiconv
tar xzvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
cd ..
#安装libmcrypt
tar xzvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
cd ..
#安装mhash
tar xzvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr/local/mhash
make && make install
cd ..
#安装curl
tar xzvf curl-7.39.0.tar.gz
cd curl-7.39.0/
./configure --prefix=/usr/local/curl
make && make install
cd ..
#安装libxml2
tar xzvf libxml2-2.8.0.tar.gz
cd libxml2-2.8.0
./configure --prefix=/usr/local/libxml2
make && make install
cd ..
#修改编译错误
vim /usr/local/gd2/include/gd_io.h
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) #增加此行
}
#php
tar xzvf php-5.4.34.tar.gz
cd php-5.4.34/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg9 --with-freetype-dir=/usr/local/freetype --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-mcrypt=/usr/local/libmcrypt --with-mhash=/usr/local/mhash --with-zlib=/usr/local/zlib --with-pcre-dir=/usr/local/pcre --enable-mbstring=cn --enable-sockets --enable-pcntl --with-gdbm --enable-ftp --with-openssl --with-curl=/usr/local/curl
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
#php结合apache
sed -i '/AddType application\/x-gzip .gz .tgz/a\ AddType application\/x-httpd-php .php\n AddType application\/x-httpd-php-source .phps' /usr/local/apache2/conf/httpd.conf
#添加首页支持
sed -i '/DirectoryIndex index.html/c\ DirectoryIndex index.php index.html' /usr/local/apache2/conf/httpd.conf
service httpd -t
service httpd start
cd ..
php测试页
echo "<?php phpinfo(); ?>" >/usr/local/apache2/htdocs/index.php