Linux下Nginx+Mysql+PHP的编译安装过程

 分类: Server

Linux软件安装方式有很多,为了保证服务器运行的稳定性,很多人会采用编译软件安装源代码的方式来安装软件;下面我来把Godaddy VPS上的编译过程贴一下,包括安装过过程和遇到的一些问题,以及解决的办法等。需要说明的是,mysql的高级版本需要用cmake来编译

yum install gcc gcc-c++ make
wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.32.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
wget http://nginx.org/download/nginx-1.4.1.tar.gz
wget http://us1.php.net/distributions/php-5.5.0.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz -4
wget http://zlib.net/zlib-1.2.8.tar.gz -4
wget http://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz -4
wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.2/libpng-1.6.2.tar.gz -4
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.0.tar.gz -4
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz -4
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz -4

全部解压
yum install ncurses-devel
编译cmake
configure make make install
编译mysql:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make make install
cp ./support-files/my-huge.cnf /etc/my.cnf
./scripts/mysql_install_db –user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
配置远程管理,设置密码等

编译nginx
1.编译pcre库
2,编译zlib库
3,编译nginx
./configure –prefix=/usr/local/nginx –user=nginx –group=nginx –with-pcre=/usr/local/src/pcre-8.33

编译php
1,编译 libmcrypt
2,编译freetype (第一次编译失败,需要libpng)
3,编译libpng
4,再次编译freetype
还是找不到libpng 用命令export PATH=$PATH:/usr/local/libpng/bin
5,编译libjpeg
./configure –prefix=/usr/local/jpeg –enable-shared
6,libxml2已经安装,curl已经安装
7,编译安装libmcrypt
8,编译安装libiconv
9,编译php,错误,显示没有安装libxml2
./configure –prefix=/usr/local/php –enable-fpm –enable-mbstring=all –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-ftp –enable-gd-native-ttf –enable-session –with-gd –with-iconv –with-zlib –enable-xml –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-sockets
10,编译安装libxml2
wget http://xmlsoft.org/sources/libxml2-2.8.0.tar.gz -4
编译chenggong
11,重新编译php
./configure –prefix=/usr/local/php –enable-fpm –enable-mbstring=all –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-ftp –enable-gd-native-ttf –enable-session –with-gd –with-iconv –with-zlib –enable-xml –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-sockets –with-libxml-dir=/usr/local/libxml –without-pear
make && make install
cp php.ini-production /usr/local/php/lib/php.ini
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
12,需要安装apc加速器,编译提示没有安装autoconf
13,下载编译安装autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz -4
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
出现这个错误,需要编译安装 m4: wget http://ftp.gnu.org/gnu/m4/m4-1.4.tar.gz -4
14,继续编译APC
安装编译后还是提示这个错误export PHP_AUTOCONF=/usr/local/autoconf/bin/autoconf export PHP_AUTOHEADER=/usr/local/autoconf/bin/autoheader 成功
make出现错误 /usr/local/src/APC-3.1.9/apc_zend.c:62: error: ‘zend_execute_data’ has no member named ‘Ts’
换低版本APC安装 同样错误
yum install pcre-devel 没用
15,安装低版本php看看能不能解决 php5.4 完美解决

16,nginx服务的安装
17,安装memcached
18,必须先安装libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz -4
./configure –prefix=/usr/local/libevent make && make install
19,下载安装memcached
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz -4
./configure –prefix=/usr/local/memcached –with-libevent=/usr/local/libevent make && make install
20,下载安装php扩展 memcache
./configure –with-php-config=/usr/local/php/bin/php-config

发表回复