大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
安装php
在衡阳等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计、成都做网站 网站设计制作定制网站设计,公司网站建设,企业网站建设,高端网站设计,营销型网站建设,外贸网站制作,衡阳网站建设费用合理。
安装依赖包
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel –y
安装epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel mcytpt mhash libxslt-devel
安装libiconv
tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/usr/lcoal/libiconv
Make && make install
解压安装包
tar -zxvf php-5.6.20.tar.gz
配置编译安装
cd php-5.6.20
./configure \
–prefix=/usr/local/php-5.6.20 \
–with-config-file-path=/usr/local/php-5.6.20/etc \
–with-fpm-user=nginx \
–with-fpm-group=nginx \
–with-bz2 \
–with-curl \
–with-gd \
–with-mcrypt \
–with-openssl \
–with-mhash \
–with-jpeg-dir \
–with-png-dir \
–with-freetype-dir \
–with-iconv-dir=/usr/local/libiconv \
–with-gettext \
–with-libxml-dir=/usr/local \
–with-zlib \
–with-xsl \
–with-pdo-MySQL=mysqlnd \
–with-mysql=mysqlnd \
–with-mysqli=mysqlnd \
–with-libdir=lib64 \
–enable-dom \
–enable-xml \
–enable-fpm \
–enable-bcmath \
–enable-ftp \
–enable-sockets \
–disable-ipv6 \
–enable-mbregex \
–enable-mbstring \
–enable-calendar \
–enable-gd-native-ttf \
–enable-static \
make
make install
cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cd /usr/local/php/
mkdir log
编辑配置文件
pid = /var/log/php-fpm.pid
error_log = log/php-fpm.log
log_level = error
rlimit_files = 32768
events.mechanism = epoll
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 1024
pm.start_servers = 16
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.process_idle_timeout = 15s;
pm.max_requests = 2048
slowlog = log/$pool.log.slow
request_slowlog_timeout = 10
创建启动停止脚本:
vim /etc/init.d/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=/usr/local/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”
;;
configtest)
$php_fpm_BIN -t
;;
*)
echo “Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}”
exit 1
;;
esac
赋予权限
chmod +x /etc/init.d/php-fpm
启动
[root@zabbix-server php-5.6.20]# service php-fpm start
Starting php-fpm done
[root@zabbix-server php-5.6.20]# netstat -anpt |grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 16070/php-fpm
配置nginx 支持php
打开配置文件在server区块加入下面内容(这里是虚拟主机,网站根目录也在cj下面)
server {
listen 80;
server_name www.cj.com cj.com;
charset utf-8;
#access_log logs/access_cj.log main;
access_log logs/access_cj.log;
location / {
root html/cj;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/cj$fastcgi_script_name;
include fastcgi_params;
}
}