看到这篇文章有一段时间了,但是一直没有机会把它分享了,现在小编给各位整理一篇CentOS6编译安装Nginx 1.6.2 + PHP 5.5.20 + MySQL 5.6.10环境的例子,希望对大家会带来帮助.
1.系统预先配置
- yum install wget
- yum install pcre
- yum install openssl*
- yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make
- yum -y install gd gd2 gd-devel gd2-devel
- /usr/sbin/groupadd www
- /usr/sbin/useradd -g www www
- ulimit -SHn 65535
- mkdir -p /ia/data/
- cd /ia/data/
- wget http://ftp.exim.llorien.org/pcre/pcre-8.32.tar.gz
- tar -zxvf pcre-8.32.tar.gz
- mkdir tgz
- mv pcre-8.32* tgz/
- mkdir installsoft
- cd installsoft/
- wget http://nginx.org/download/nginx-1.6.2.tar.gz
- tar xzvf nginx-1.6.2.tar.gz
- cd nginx-1.6.2
- ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/ia/data/tgz/pcre-8.32 --with-http_realip_module --with-http_image_filter_module
- make
- make install
- /usr/local/webserver/nginx/sbin/nginx -V
2、安装 MySQL:
- wget http://downloads.mysql.com/archives/mysql-5.6/mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
- tar zxvf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
- mv mysql-5.6.10-linux-glibc2.5-x86_64 /usr/local/webserver/mysql
- /usr/sbin/groupadd mysql
- /usr/sbin/useradd -g mysql mysql
- mkdir -p /Data/data/mysql/data
- yum install libaio
- /usr/local/webserver/mysql/scripts/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/ia/data/mysql/data --user=mysql
- sed -i "s#/usr/local/mysql#/usr/local/webserver/mysql#g" /usr/local/webserver/mysql/bin/mysqld_safe
- GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'localhost' IDENTIFIED BY '12345678';
- GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'127.0.0.1' IDENTIFIED BY '12345678';
- GRANT ALL PRIVILEGES ON *.* TO 'ia_admin'@'%' IDENTIFIED BY '12345678';
3、安装PHP依赖库
- mkdir -p /usr/local/webserver/libs/
- wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
- tar zxvf jpegsrc.v9.tar.gz
- cd jpeg-9/
- ./configure --prefix=/usr/local/webserver/libs --enable-shared --enable-static --prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
- wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz
- tar zxvf libpng-1.6.2.tar.gz
- cd libpng-1.6.2/
- ./configure --prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
- wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz
- tar zxvf freetype-2.4.12.tar.gz
- cd freetype-2.4.12/
- ./configure --prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
- wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz"
- wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz"
- wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz"
- tar zxvf libmcrypt-2.5.8.tar.gz
- cd libmcrypt-2.5.8/
- ./configure --prefix=/usr/local/webserver/libs
- make
- make install
- cd libltdl/
- ./configure --prefix=/usr/local/webserver/libs --enable-ltdl-install
- make
- make install
- cd ../../
- tar zxvf mhash-0.9.9.9.tar.gz
- cd mhash-0.9.9.9/
- ./configure --prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
- vi /etc/ld.so.conf
- //添加:
- /usr/local/webserver/libs/lib
- //然后:
- ldconfig
- tar zxvf mcrypt-2.6.8.tar.gz
- cd mcrypt-2.6.8/
- export LDFLAGS="-L/usr/local/webserver/libs/lib -L/usr/lib"
- export CFLAGS="-I/usr/local/webserver/libs/include -I/usr/include"
- touch malloc.h //Vevb.com
- ./configure --prefix=/usr/local/webserver/libs --with-libmcrypt-prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
4、编译安装PHP 5.5
- wget http://cl1.php.net/get/php-5.5.20.tar.gz/from/this/mirror
- tar zxvf php-5.5.20.tar.gz
- cd php-5.5.20/
- export LIBS="-lm -ltermcap -lresolv"
- export DYLD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
- export LD_LIBRARY_PATH="/usr/local/webserver/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
- ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/usr/local/webserver/libs --with-jpeg-dir=/usr/local/webserver/libs --with-png-dir=/usr/local/webserver/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/usr/local/webserver/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts
- make
- make install
- cp php.ini-development /usr/local/webserver/php/etc/php.ini
- cd ../
- ln -s /usr/local/webserver/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
- mv /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
5、编译安装PHP扩展
- wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
- tar zxvf autoconf-latest.tar.gz
- cd autoconf-2.69/
- ./configure --prefix=/usr/local/webserver/libs
- make
- make install
- cd ../
- wget http://pecl.php.net/get/memcache-2.2.7.tgz
- tar zxvf memcache-2.2.7.tgz
- cd memcache-2.2.7/
- export PHP_AUTOCONF="/usr/local/webserver/libs/bin/autoconf"
- export PHP_AUTOHEADER="/usr/local/webserver/libs/bin/autoheader"
- /usr/local/webserver/php/bin/phpize
- ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
- make
- make install
- cd ../
打开 /usr/local/webserver/php/etc/php.ini 查找 ; extension_dir = "ext",在其后增加一行:
extension = "memcache.so"
新闻热点
疑难解答