一、安装PHP(版本大于等于5.6):
1.安装PHP的依赖包
准备包(依赖包可选择yum或者源码方式安装。):
yum -yinstall gcc gcc-c++ make 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-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch perl-CPAN pcre-devel pcre libxslt libxslt-devel php-mcrypt libmcrypt libmcrypt-devel mcrypt* mhash
源码包:
php下载:http://php.net/downloads.php
1.2.安装
tar -xf php-5.6.38.tar
cd php-5.6.38
./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 --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 --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
make && make install
cp php.ini-development /usr/local/php/etc/php.ini
2.安装nginx
2.1下载安装包
wget http://nginx.org/download/nginx-1.6.3.tar.gz
2.2.手动编译安装nginx
tar -zxf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.3 --with-http_ssl_module --with-http_stub_status_module
make && make install
2.3.创建一个软链接
cd /usr/local/
ln -s nginx-1.6.3 nginx
2.4.修改PATH变量
echo "export PATH=$PATH:/usr/local/nginx/sbin/:/usr/local/php/bin">>/etc/profile
source /etc/profile
2.5.nginx配置文件nginx.conf
user www www;
worker_processes auto;
error_log /data/logs/nginx/error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off;
access_log off;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for "$request_time"';
include vhost/*.conf;
}
3.PHP: memcached
3.1.安装SASL
检测是否有已安装了 SASL 相关环境包,如没有,则执行 yum install cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib
安装 SASL 相关环境。
3.2.安装libmemcached
检测下是否有已安装了 libmemcached 源码包,若没有,则执行以下命令安装 libmemcached 源码包(推荐版本 libmemcached-1.0.18)。
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 --enable-sasl
make
make install
cd ..
3.3.安装memcached
wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
phpize(如果系统中有两套PHP环境,需绝对路径调用该命令/usr/bin/phpize,该路径为使用云数据库Memcache的PHP环境路径)
./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意这个参数)
make
make install
3.4.修改php配置
将上面红色框部分拷贝到制定目录
cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/
vim /usr/local/php/etc/php.ini
# 添加以下配置
[Memcached]
extension=memcached.so
重启php
用php -m检查是否加载了memcached
4.PHP:Mongodb
第一步:下载MongoDB安装包
wget http://pecl.php.net/get/mongo-1.6.16.tgz
具体版本可以到http://pecl.php.net/package/mongo这个网站查找
tar -zxf mongo-1.6.16.tgz
4.1.进入解压目录,运行phpize进行安装准备
cd mongo-1.6.6
/usr/local/php/bin/phpize
4.2.安装编译
上述命令运行完后,在目录下就生成了configure文件
使用./configure命令进行安装配置,然后使用make && make install进行编译安装,命令如下:
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
4.3.编辑php.ini增加下述一行添加mongodb扩展
extension=mongo.so
重启web容器,然后查看phpinfo,看到mongodb的内容就说明安装成功。
1.下载phpredis3.1.2
wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
2.解压后在phpredis3.1.2目录下执行
tar -zxf 3.1.2.tar.gz
3.执行configure
cd phpredis-3.1.2/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
4.安装
make && make install
默认情形下将会在/usr/local/php/lib/php/extensions/debug-non-zts-20131226/目录下生成redis.so文件
将其拷贝到/usr/local/php/lib/php/extensions/
cp /usr/local/php/lib/php/extensions/debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/
5.配置php.ini,在其最后加入
[Redis]
extensions=redis.so
6.重启php 服务
7.检查redis模块是否加载了
php -m |grep redis
ts
make && make install
cp php.ini-development /usr/local/php/etc/php.ini
2.安装nginx
2.1下载安装包
wget http://nginx.org/download/nginx-1.6.3.tar.gz
2.2.手动编译安装nginx
tar -zxf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.3 --with-http_ssl_module --with-http_stub_status_module
make && make install
2.3.创建一个软链接
cd /usr/local/
ln -s nginx-1.6.3 nginx
2.4.修改PATH变量
echo "export PATH=$PATH:/usr/local/nginx/sbin/:/usr/local/php/bin">>/etc/profile
source /etc/profile
2.5.nginx配置文件
nginx.conf
user www www;
worker_processes auto;
error_log /data/logs/nginx/error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off;
access_log off;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for "$request_time"';
include vhost/*.conf;
}
3.PHP: memcached
3.1.安装SASL
检测是否有已安装了 SASL 相关环境包,如没有,则执行 yum install cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib
安装 SASL 相关环境。
3.2.安装libmemcached
检测下是否有已安装了 libmemcached 源码包,若没有,则执行以下命令安装 libmemcached 源码包(推荐版本 libmemcached-1.0.18)。
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 --enable-sasl
make
make install
cd ..
3.3.安装memcached
wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
phpize(如果系统中有两套PHP环境,需绝对路径调用该命令/usr/bin/phpize,该路径为使用云数据库Memcache的PHP环境路径)
./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意这个参数)
make
make install
3.4.修改php配置
将上面红色框部分拷贝到制定目录
cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/
vim /usr/local/php/etc/php.ini
# 添加以下配置
[Memcached]
extension=memcached.so
重启php
用php -m检查是否加载了memcached
4.PHP:Mongodb
第一步:下载MongoDB安装包
wget http://pecl.php.net/get/mongo-1.6.16.tgz
具体版本可以到http://pecl.php.net/package/mongo这个网站查找
tar -zxf mongo-1.6.16.tgz
4.1.进入解压目录,运行phpize进行安装准备
cd mongo-1.6.6
/usr/local/php/bin/phpize
4.2.安装编译
上述命令运行完后,在目录下就生成了configure文件
使用./configure命令进行安装配置,然后使用make && make install进行编译安装,命令如下:
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
4.3.编辑php.ini增加下述一行添加mongodb扩展
extension=mongo.so
重启web容器,然后查看phpinfo,看到mongodb的内容就说明安装成功。
1.下载phpredis3.1.2
wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
2.解压后在phpredis3.1.2目录下执行
tar -zxf 3.1.2.tar.gz
3.执行configure
cd phpredis-3.1.2/
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
4.安装
make && make install
默认情形下将会在/usr/local/php/lib/php/extensions/debug-non-zts-20131226/目录下生成redis.so文件
将其拷贝到/usr/local/php/lib/php/extensions/
cp /usr/local/php/lib/php/extensions/debug-non-zts-20131226/*.so /usr/local/php/lib/php/extensions/
5.配置php.ini,在其最后加入
[Redis]
extensions=redis.so
6.重启php 服务
7.检查redis模块是否加载了
php -m |grep redis