一、安装各种软件包
yum -y install wget git vim lrzsz unzip zip gcc make gd-devel bzip2 bzip2-devel libcurl libcurl-devel zlib zlib-devel gcc-c++ libtool
yum -y install openssl openssl-devel curl curl-devel icu libicu libicu-devel libmcrypt-devel libxslt-devel epel-release
yum -y install cmake bison libicu-devel libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel
yum -y install gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel ncurses ncurses-devel
yum -y install autoconf gd-devel freetype freetype-devel
二、源码安装Nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module
make && make install
/usr/sbin/groupadd www 创建Nginx用户组
/usr/sbin/useradd -g www www -s /sbin/nologin 创建Nginx用户并指定用户组
/usr/local/nginx/sbin/nginx 启动nginx
三、源码安装php
cd /usr/local/src
上传已经下载好的PHP源码包到/usr/local/src目录下,我的PHP版本是5.5.36
tar zxvf php-5.5.36.tar.gz
cd php-5.5.36
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-intl --with-xsl
make && make install
cd /usr/local/php/etc
mv php-fpm.conf.default php-fpm.conf 将默认配置文件重命名为php-fpm.conf,内容根据自己的实际情况修改,以下是我的内容,可以先truncate -s 0 php-fpm.conf把内容清空再写入自己想要的内容
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9000
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 9
request_terminate_timeout = 9000
request_slowlog_timeout = 0
slowlog = /var/log/slow.log
别忘了php.ini文件
/usr/local/php/sbin/php-fpm #########启动php
ps -ef |grep php 可以看到php-fpm已经在正常运行了
###########nginx和PHP都安装好了,接下来就是一堆扩展件的安装了###########
一、源码安装memcache
cd /usr/local/src/
wget http://pecl.php.net/get/memcache-3.0.8.tgz
tar -zxvf memcache-3.0.8.tgz
cd memcache-3.0.8
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示memcache共享扩展被安装到了这里
二、源码安装libmemcached,为memcached安装库
cd /usr/local/src/
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached
make && make install
三、源码安装memcached
cd /usr/local/src/
wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar -zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示memcached共享扩展被安装到了这里
四、源码安装phpredis
cd /usr/local/src/
wget http://pecl.php.net/get/redis-2.2.4.tgz
tar -zxvf redis-2.2.4.tgz
cd redis-2.2.4
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示redis共享扩展被安装到了这里
五、源码安装xdebug
cd /usr/local/src/
wget http://xdebug.org/files/xdebug-2.4.0rc4.tgz
tar -zxvf xdebug-2.4.0rc4.tgz
cd xdebug-2.4.0RC4
/usr/local/php/bin/phpize
./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示xdebug共享扩展被安装到了这里
六、动态加载fileinfo
cd /usr/local/src/php-5.5.36/ext/fileinfo/ 进入此目录,注意是php-5.5.36,此目录是安装包的所在目录
/usr/local/php/bin/phpize
./configure --enable-fileinfo --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示fileinfo共享扩展被安装到了这里
七、动态加载mcrypt(和第六步类似)
cd /usr/local/src/php-5.5.36/ext/mcrypt
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
八、源码安装phalcon
cd /usr/local/src
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build/php5/64bits/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ 提示phalcon共享扩展被安装到了这里
九、所有扩展件安装完成后一定要记得启动每个扩展件
vi /usr/local/php/etc/php.ini 打开php.ini文件,在最上面或者最下面加上以下内容
extension=memcache.so
extension=mcrypt.so
extension=memcached.so
extension=redis.so
extension=xdebug.so
extension=fileinfo.so
extension=phalcon.so
php -m 以上内容添加到php.ini文件后,执行php -m可以看到所有扩展件已被PHP加载