NGINX 1.7.4 PHP5.4.33 安装

在编译安装nginx、mysql、和php时依赖的包提前安装:

yum install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel  zlib zlib-devel glibc glibc-devel glib2 glib2-devel   
 

一、安装Nginx

从官网下载最新版的 nginx

wget http://nginx.org/download/nginx-1.7.4.tar.gz  

解压nginx压缩包  tar -zxvf nginx-1.7.4.tar.gz     

进入nginx安装目录  cd   nginx-1.7.4

./configure  $默认安装在/usr/local/nginx     指定--prefix=/www/server/nginx  安装此目录

make  

make install    

如果没有报错,顺利完成后,最好看一下nginx的安装目录

如果出现“[emerg] 10464#0: unknown directive "ssl" in /usr/local/nginx-0.6.32/conf/nginx.conf:74”则说明没有将ssl模块编译进nginx,在configure的时候加上“--with-http_ssl_module”即可^^

nginx.conf  配置文件

error_log  /www/logs/nginx_error.log crit;
pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  65535;

http   
{
    include       mime.types;     
    default_type  application/octet-stream;       
    charset  utf-8;
    server_names_hash_bucket_size 128;     
    client_header_buffer_size 32k;    
    large_client_header_buffers 4 32k;    
    client_max_body_size 30m;   
    sendfile on;    
    tcp_nopush     on;     
    keepalive_timeout 60;   
    tcp_nodelay on;   
    server_tokens off;  
    client_body_buffer_size 512k;   
    proxy_connect_timeout   5;   
    proxy_send_timeout      60;   
    proxy_read_timeout      5;   
    proxy_buffer_size       16k;   
    proxy_buffers           4 64k;   
    proxy_busy_buffers_size 128k;   
    proxy_temp_file_write_size 128k;   
    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 128k;     
    gzip_vary on;      
    server
    {
        listen       80;
        server_name  localhost;
        index index.html index.htm index.php;
        root  /www/htdocs;
        fastcgi_intercept_errors on;
        error_page 404 403 /html/404.htm;
        location ~ \.php$
        {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        } 
    } 
    include vhosts/*.conf;      
}   

/etc/init.d/nginx 启动文件

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by ruijie. at 2014.02.26
# if you find any errors on this scripts,please contact ruijie.
# and send mail to ruijie at gmail dot com.
#            ruijie.qiao@gmail.com
nginxd=/www/server/nginx/sbin/nginx
nginx_config=/www/server/nginx/conf/nginx.conf
nginx_pid=/www/server/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
    if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
        echo "nginx already running...."
        exit 1
    fi
        
    echo -n $"Starting $prog!"
    $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/nginx
    return $RETVAL
}


# Stop nginx daemons functions.
stop() {
    echo -n $"Stopping $prog!"
    $nginxd -s stop
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/nginx
}


# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog!"
    #kill -HUP `cat ${nginx_pid}`
    $nginxd -s reload
    RETVAL=$?
    echo
}

# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|help}"
        exit 1
esac
exit $RETVAL



二、安装PHP5.4.33


1、安装libpng
[root@localhost opt]# tar -zxvf libpng-1.2.18.tar.gz
[root@localhost opt]# cd libpng-1.2.18
[root@localhost libpng-1.2.18]# ./configure --prefix = /www/server/phpextend/libpng/
[root@localhost libpng-1.2.18]# make 
[root@localhost libpng-1.2.18]# make install
 
2、安装zlib
[root@localhost opt]# tar -zxvf  zlib-1.2.3.tar.gz 
[root@localhost opt]# cd zlib-1.2.3
[root@localhost zlib-1.2.3] ./configure --prefix = /www/server/phpextend/zlib/  --shared
[root@localhost zlib-1.2.3]# make 
[root@localhost zlib-1.2.3]# make install
 
3、安装freetype
[root@localhost opt]# tar -zxvf freetype-2.4.8.tar.gz 
[root@localhost opt]# cd freetype-2.4.8
[root@localhost freetype-2.4.8]# ./configure  --prefix = /www/server/phpextend/freetype
[root@localhost freetype-2.4.8]# make
[root@localhost freetype-2.4.8]# make install
 
4、安装jpeg支持
[root@localhost opt]# tar -zxvf jpegsrc.v6b.tar.gz   
[root@localhost opt]# cd jpeg-6b/
[root@localhost jpeg-6b]# ./configure --prefix=  /www/server/phpextend/jpeg6  --enable-shared
[root@localhost jpeg-6b]# make 
[root@localhost jpeg-6b]# make install
注意:这里configure一定要带--enable-shared参数,不然,不会生成共享库

上边安装的都是gd库的支持性的插件,下边开始安装gd库。
 
5、安装gd库
[root@localhost opt]# tar -zxvf gd-2.0.35.tar.gz 
[root@localhost opt]# cd gd-2.0.35
[root@localhost gd-2.0.35]# ./configure --prefix=  /www/server/phpextend/gd   --with-zlib= /www/server/phpextend/zlib/   --with-png= /www/server/phpextend/libpng  --with-freetype= /www/server/phpextend/freetype/  --with- jpeg=/www/server/phpextend/jpeg6/
//这里需要指定安装的gd库需要的各个插件的安装目录,若安装时没有指定目录,就使用--with参数。

安装GD可能出现的错误:
当make 时出现 
configure.ac:64: error: possibly undefined macro: AM_ICONV
下载gettext-devel库然后安装上就行了:
[root@localhost gd-2.0.35]# yum install gettext-devel -y 
[root@localhost gd-2.0.35]# make
[root@localhost gd-2.0.35]# make install
这样gd库就安装完毕了,

安装PHP5

[root@localhost opt]# tar -zxvf php-5.4.33.tar.gz 
[root@localhost opt]# cd php-5.4.33

./configure --prefix=/www/server/php --with-config-file-path=/www/server/php/etc  --enable-fastcgi --with-mysqli=/www/server/mysql/bin/mysql_config --with-mysql=/www/server/mysql  --with-iconv-dir --with-freetype-dir=/www/server/phpextend/freetype --with-jpeg-dir=/www/server/phpextend/jpeg6 --with-png-dir=/www/server/phpextend/libpng --with-mhash= --with-gd=/www/server/phpextend/gd --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --without-pear --enable-cli --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

make  

make install


PHP + GD 安装完成


安装php5.6.12. pdo_mysql报错教训经验总结

如果报 php_mysql.c:999: undefined reference to `_mysqlnd_init'


./configure --prefix=/www/server/php5.6 --with-config-file-path=/www/server/php5.6/etc --with-mysql=/usr/local/server/mysql --with-mysqli=/usr/local/server/mysql/bin/mysql_config --with-xpm-dir --enable-mysqlnd --with-iconv-dir=/usr/local --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 --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-freetype-dir --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap 


一定要带--enable-mysqlnd


php-fpm 配置文件


[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = error
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
daemonize = yes
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 40
request_terminate_timeout = 60
request_slowlog_timeout = 20
slowlog = /www/logs/$pool.phpslow.log
rlimit_files = 65535
rlimit_core = 0
chroot =
chdir =
catch_workers_output = yes
php_flag[display_errors] = on


php-fpm 启动文件

#! /bin/sh
### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO

prefix=/www/server/php
exec_prefix=${prefix}

php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid

php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"

wait_for_pid () {
try=0

while test $try -lt 35 ; do

case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac


echo -n .
try=`expr $try + 1`
sleep 1
done
}

case "$1" in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN --daemonize $php_opts

if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi

wait_for_pid created $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

stop)
echo -n "Gracefully shutting down php-fpm "


if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi

kill -QUIT `cat $php_fpm_PID`

wait_for_pid removed $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;

status)
if [ ! -r $php_fpm_PID ] ; then
echo "php-fpm is stopped"
exit 0
fi

PID=`cat $php_fpm_PID`
if ps -p $PID | grep -q $PID; then
echo "php-fpm (pid $PID) is running..."
else
echo "php-fpm dead but pid file exists"
fi
;;

force-quit)
echo -n "Terminating php-fpm "

if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi

kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

restart)
$0 stop
$0 start
;;

reload)

echo -n "Reload service php-fpm "

if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;

*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"
exit 1
;;


esac


编译安装pdo_mysql

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so' - libmysqlclient.so.18: cannot open shared object file: No such file or directory in Unknown on line 0
解决方法:
2、 /usr/local/php-5.2.14/bin/phpize
3、 ./configure --with-php-config=/usr/local/php-5.2.14/bin/php-config
4、 make
5、 make install
 
如果还有如下错误
1、libmysqlclient.so.18: cannot open shared object file: No such file or directory in Unknown on line 0
 
解决方法:
 
ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/
重启nginx


编译安装phpredis

下载地址:https://github.com/phpredis/phpredis    https://pecl.php.net/package/redis

cd /usr/local/src #进入软件包存放目录

tar zxvf phpredis-2.2.4.tar.gz #解压

cd phpredis-2.2.4 #进入安装目录

/usr/local/php/bin/phpize #用phpize生成configure配置文件

./configure --with-php-config=/usr/local/php/bin/php-config  #配置

make  #编译

make install  #安装

安装完成之后,出现下面的安装路径

/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

2、配置php支持

vi /usr/local/php/etc/php.ini  #编辑配置文件,在最后一行添加以下内容

添加

extension="redis.so"

:wq! #保存退出

3  重启服务

sudo service nginx restart

sudo /etc/init.d/php-fpm restart


编译安装amqp


到这里下载rabbitmq-c的v0.2版:https://github.com/alanxz/rabbitmq-c/tags


第一步:
# 下载 rabbitmq-c library
mkdir rabbitmq-c
cd rabbitmq-c
wget https://github.com/alanxz/rabbitmq-c/tarball/0.2
tar zxvf 0.2
# 删除压缩包
rm -rf 0.2
cd alanxz-rabbitmq-c-f8f4fc7

# 下载最新版的codegen配件
wget https://github.com/rabbitmq/rabbitmq-codegen/tarball/master
tar zxvf master
mv rabbitmq-rabbitmq-codegen-7597914 codegen
# 删除压缩包
rm -rf master

# 配置、编译、安装
autoreconf -i

备:如果autoreconf -i -f时提示说缺少 libtoolize

解决方法:# yum install libtool



./configure
make
sudo make install

第二步:
安装php的amqp扩展:
wget http://pecl.php.net/get/amqp-1.0.7.tgz
tar -zxvf amqp-1.0.7.tgz 
cd amqp-1.0.7
/usr/local/starcast/php/bin/php
./configure --with-php-config=/usr/local/starcast/php/bin/php-config --with-amqp
make 
sudo make install
#直接在php.ini中添加生成的amqp.so
vim  /usr/local/starcast/php/lib/php.ini 
# 加入一行 extension = amqp.so


gearman扩展安装


https://pecl.php.net/package/gearman

/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config

configure: error: Please install libgearman

yum install libgearman-devel.i686 libgearman.i686 后,此问题解决,却出现另外一问题:

libgearman version 0.21 or later required

从错误信息来看,是libgearman-devel 的版本低于0.21所至

所以  yum install  libgearman-devel 升级版本一下
如果报未找到版本错误,请看下 /etc/yum.repos.d/epel.repo

configure: error: could not find boost
yum install -y boost boost-devel
 
 
 
 
 
 
 
 
 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值