tengine2+mysql-5.6+php5.5 Linux 服务器环境架构

升级所需要的库

sudo -s
LANG=C
yum install -y wget gcc gcc-c++ openssl* curl curl-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel gd gd2 gd-devel gd2-devel libaio autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel

二、创建目录病下载需要的软件:
创建两个目录分别用于软件源码目录和日志目录,然后下载软件。

mkdir -p /lvtao.net/resource
mkdir -p /lvtao.net/logs
cd /lvtao.net/resource/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
wget http://tengine.taobao.org/download/tengine-2.0.1.tar.gz
wget downloads.skysql.com/archives/mysql-5.6/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
wget http://cn2.php.net/distributions/php-5.5.12.tar.gz
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
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
wget http://pecl.php.net/get/memcache-2.2.7.tgz
wget http://mirrors-au.go-parts.com/mirrors/ImageMagick/ImageMagick-6.8.9-1.tar.gz
wget http://pecl.php.net/get/imagick-3.1.2.tgz

三、安装 tengine
① 安装 pcre

tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make && make install
cd ../

② 安装 tengine

groupadd www
useradd -g www www
tar zxvf tengine-2.0.1.tar.gz
cd tengine-2.0.1
./configure --user=www --group=www --prefix=/lvtao.net/software/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/lvtao.net/resource/pcre-8.35 --with-http_realip_module --with-http_image_filter_module --with-http_concat_module
make
make install
cd ../

③ 配置域名

rm -f /lvtao.net/software/nginx/conf/nginx.conf
vi /lvtao.net/software/nginx/conf/nginx.conf

输入以下内容(文件夹 sites-enabled 是存放虚拟主机配置文件的,位于 mkdir -p /lvtao.net/software/nginx/sites-enabled/ 中)

user  www www;
worker_processes  auto;
 
#error_log  logs/error.log;
error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
pid        logs/nginx.pid;
 
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    access_log off;
    log_not_found off;
    error_log /lvtao.net/logs/nginx-error.log warn;
    # access_log /lvtao.net/logs/nginx-access.log main buffer=16k;
    server_admin admin@bugxm.com;
    server_tag Apache/2.4;
    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;
 
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
 
    client_max_body_size 10M;
    client_body_buffer_size 1m;
    client_body_timeout 15;
    client_header_timeout 15;
    client_header_buffer_size 32k;
    keepalive_timeout 2 2;
    send_timeout 15;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
 
    fastcgi_buffers 256 16k;
    fastcgi_buffer_size 128k;
    fastcgi_connect_timeout 3s;
    fastcgi_send_timeout 120s;
    fastcgi_read_timeout 120s;
    reset_timedout_connection on;
    server_names_hash_bucket_size 100;
 
    server_tokens off;
 
    server {
        listen       80;
        server_name  localhost;
        index index.html index.htm index.php;
        root    /lvtao.net/htdocs/test/;
 
        error_page  404              /404.html;
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        location ~ .*\.(php|php5)?$ {
            #fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
 
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
        {
            expires      30d;
        }
 
        location ~ .*\.(js|css)?$
        {
            expires      1h;
        }
 
        location ~ /\. {
            deny all;
        }
    }
    include ../sites-enabled/*.conf;
}

生成php测试内容,用于安装完成测试用:

mkdir -p /lvtao.net/htdocs/test
chmod +w /lvtao.net/htdocs/test
echo "<?php phpinfo(); ?>" > /lvtao.net/htdocs/test/index.php
chown -R www:www /lvtao.net/htdocs/test

编辑 fastcgi.conf

vi /lvtao.net/software/nginx/conf/fastcgi.conf

为安全考虑,在 fastcgi.conf 底部加上以下代码:

fastcgi_param  PHP_VALUE          "open_basedir=$document_root:/tmp/:/proc/";

④ 将 Tengine 添加到服务

vi /etc/rc.d/init.d/nginx

在该文件中添加以下内容

#!/bin/sh
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/lvtao.net/software/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/lvtao.net/software/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:" | sed ‘s/[^*]*--user=\([^ ]*\).*/\1/g‘ -`
   if [ -z "`grep $user /etc/passwd`" ]; then
       useradd -M -s /bin/nologin $user
   fi
   options=`$nginx -V 2>&1 | grep ‘configure arguments:‘`
   for opt in $options; do
       if [ `echo $opt | grep ‘.*-temp-path‘` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
force_reload() {
    restart
}
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
    status $prog
}
rh_status_q() {
    rh_status >/dev/null 2>&1
}
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

chmod +x /etc/init.d/nginx
ulimit -SHn 65535
service nginx start

注:启动参数支持:{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}

四、安装 mysql

tar zxvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.16-linux-glibc2.5-x86_64 /lvtao.net/software/mysql
groupadd mysql
useradd -g mysql mysql
mkdir -p /lvtao.net/data/mysql/data/
mkdir -p /lvtao.net/data/mysql/binlog/
mkdir -p /lvtao.net/data/mysql/relaylog/
chown -R mysql:mysql /lvtao.net/data/mysql/
 
/lvtao.net/software/mysql/scripts/mysql_install_db --basedir=/lvtao.net/software/mysql --datadir=/lvtao.net/data/mysql/data --user=mysql
 
sed -i "s#/usr/local/mysql#/lvtao.net/software/mysql#g" /lvtao.net/software/mysql/bin/mysqld_safe

编辑配置文件 my.cnf

rm -f /lvtao.net/software/mysql/my.cnf
vi /lvtao.net/software/mysql/my.cnf

在 my.cnf 中输入以下内容

[client]
character-set-server = utf8
port = 3306
socket = /tmp/mysql.sock
 
[mysqld]
server-id = 1
port = 3306
user = mysql
basedir = /lvtao.net/software/mysql
datadir = /lvtao.net/data/mysql/data
socket = /tmp/mysql.sock
log-error = /lvtao.net/data/mysql/mysql_error.log
pid-file = /lvtao.net/data/mysql/mysql.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 
open_files_limit = 10240
back_log = 600
join_buffer_size = 1M
read_rnd_buffer_size = 16M
sort_buffer_size = 1M
thread_cache_size = 300
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /lvtao.net/data/mysql/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /lvtao.net/data/mysql/relaylog/relaylog
relay-log-info-file = /lvtao.net/data/mysql/relaylog/relaylog
relay-log = /lvtao.net/data/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 128M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
 
interactive_timeout = 120
wait_timeout = 120
 
skip-name-resolve
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

将 mysql 添加到服务

vi /etc/rc.d/init.d/mysqld

输入以下内容

#!/bin/sh
basedir=/lvtao.net/software/mysql
datadir=/lvtao.net/data/mysql/data
service_startup_timeout=900
lockdir=‘/var/lock/subsys‘
lock_file_path="$lockdir/mysql"
mysqld_pid_file_path=/lvtao.net/data/mysql/mysql.pid
if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=/usr/local/mysql/bin
  if test -z "$datadir"
  then
    datadir=/usr/local/mysql/data
  fi
  sbindir=/usr/local/mysql/bin
  libexecdir=/usr/local/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi
datadir_set=
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
  . $lsb_functions
else
  log_success_msg()
  {
    echo " SUCCESS! $@"
  }
  log_failure_msg()
  {
    echo " ERROR! $@"
  }
fi
 
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
export PATH
 
mode=$1    # start or stop
 
[ $# -ge 1 ] && shift
 
 
other_args="$*"   # uncommon, but needed when called from an RPM upgrade action
           # Expected: "--skip-networking --skip-grant-tables"
           # They are not checked here, intentionally, as it is the resposibility
           # of the "spec" file author to give correct arguments only.
 
case `echo "testing\c"`,`echo -n testing` in
    *c*,-n*) echo_n=   echo_c=     ;;
    *c*,*)   echo_n=-n echo_c=     ;;
    *)       echo_n=   echo_c=‘\c‘ ;;
esac
 
parse_server_arguments() {
  for arg do
    case "$arg" in
      --basedir=*)  basedir=`echo "$arg" | sed -e ‘s/^[^=]*=//‘`
                    bindir="$basedir/bin"
            if test -z "$datadir_set"; then
              datadir="$basedir/data"
            fi
            sbindir="$basedir/sbin"
            libexecdir="$basedir/libexec"
        ;;
      --datadir=*)  datadir=`echo "$arg" | sed -e ‘s/^[^=]*=//‘`
            datadir_set=1
    ;;
      --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e ‘s/^[^=]*=//‘` ;;
      --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e ‘s/^[^=]*=//‘` ;;
    esac
  done
}
 
wait_for_pid () {
  verb="$1"           # created | removed
  pid="$2"            # process ID of the program operating on the pid-file
  pid_file_path="$3" # path to the PID file.
 
  i=0
  avoid_race_condition="by checking again"
 
  while test $i -ne $service_startup_timeout ; do
 
    case "$verb" in
      ‘created‘)
        # wait for a PID-file to pop into existence.
        test -s "$pid_file_path" && i=‘‘ && break
        ;;
      ‘removed‘)
        # wait for this PID-file to disappear
        test ! -s "$pid_file_path" && i=‘‘ && break
        ;;
      *)
        echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
        exit 1
        ;;
    esac
 
    # if server isn‘t running, then pid-file will never be updated
    if test -n "$pid"; then
      if kill -0 "$pid" 2>/dev/null; then
        :  # the server still runs
      else
        # The server may have exited between the last pid-file check and now.  
        if test -n "$avoid_race_condition"; then
          avoid_race_condition=""
          continue  # Check again.
        fi
 
        # there‘s nothing that will affect the file.
        log_failure_msg "The server quit without updating PID file ($pid_file_path)."
        return 1  # not waiting any more.
      fi
    fi
 
    echo $echo_n ".$echo_c"
    i=`expr $i + 1`
    sleep 1
 
  done
 
  if test -z "$i" ; then
    log_success_msg
    return 0
  else
    log_failure_msg
    return 1
  fi
}
 
# Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
if test -x ./bin/my_print_defaults
then
  print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
  print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
  print_defaults="$bindir/mysql_print_defaults"
else
  # Try to find basedir in /etc/my.cnf
  conf=/etc/my.cnf
  print_defaults=
  if test -r $conf
  then
    subpat=‘^[^=]*basedir[^=]*=\(.*\)$‘
    dirs=`sed -e "/$subpat/!d" -e ‘s//\1/‘ $conf`
    for d in $dirs
    do
      d=`echo $d | sed -e ‘s/[     ]//g‘`
      if test -x "$d/bin/my_print_defaults"
      then
        print_defaults="$d/bin/my_print_defaults"
        break
      fi
      if test -x "$d/bin/mysql_print_defaults"
      then
        print_defaults="$d/bin/mysql_print_defaults"
        break
      fi
    done
  fi
 
  # Hope it‘s in the PATH ... but I doubt it
  test -z "$print_defaults" && print_defaults="my_print_defaults"
fi
 
#
# Read defaults file from ‘basedir‘.   If there is no defaults file there
# check if it‘s in the old (depricated) place (datadir) and read it from there
#
 
extra_args=""
if test -r "$basedir/my.cnf"
then
  extra_args="-e $basedir/my.cnf"
else
  if test -r "$datadir/my.cnf"
  then
    extra_args="-e $datadir/my.cnf"
  fi
fi
 
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
 
#
# Set pid file if not given
#
if test -z "$mysqld_pid_file_path"
then
  mysqld_pid_file_path=$datadir/`hostname`.pid
else
  case "$mysqld_pid_file_path" in
    /* ) ;;
    * )  mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
  esac
fi
 
case "$mode" in
  ‘start‘)
    # Start daemon
 
    # Safeguard (relative paths, core dumps..)
    cd $basedir
 
    echo $echo_n "Starting MySQL"
    if test -x $bindir/mysqld_safe
    then
      # Give extra arguments to mysqld with the my.cnf file. This script
      # may be overwritten at next upgrade.
      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
 
      # Make lock for RedHat / SuSE
      if test -w "$lockdir"
      then
        touch "$lock_file_path"
      fi
 
      exit $return_value
    else
      log_failure_msg "Couldn‘t find MySQL server ($bindir/mysqld_safe)"
    fi
    ;;
 
  ‘stop‘)
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.
 
    if test -s "$mysqld_pid_file_path"
    then
      mysqld_pid=`cat "$mysqld_pid_file_path"`
 
      if (kill -0 $mysqld_pid 2>/dev/null)
      then
        echo $echo_n "Shutting down MySQL"
        kill $mysqld_pid
        # mysqld should remove the pid file when it exits, so wait for it.
        wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
      else
        log_failure_msg "MySQL server process #$mysqld_pid is not running!"
        rm "$mysqld_pid_file_path"
      fi
 
      # Delete lock for RedHat / SuSE
      if test -f "$lock_file_path"
      then
        rm -f "$lock_file_path"
      fi
      exit $return_value
    else
      log_failure_msg "MySQL server PID file could not be found!"
    fi
    ;;
 
  ‘restart‘)
    # Stop the service and regardless of whether it was
    # running or not, start it again.
    if $0 stop  $other_args; then
      $0 start $other_args
    else
      log_failure_msg "Failed to stop running server, so refusing to try to start."
      exit 1
    fi
    ;;
 
  ‘reload‘|‘force-reload‘)
    if test -s "$mysqld_pid_file_path" ; then
      read mysqld_pid <  "$mysqld_pid_file_path"
      kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
      touch "$mysqld_pid_file_path"
    else
      log_failure_msg "MySQL PID file could not be found!"
      exit 1
    fi
    ;;
  ‘status‘)
    # First, check to see if pid file exists
    if test -s "$mysqld_pid_file_path" ; then
      read mysqld_pid < "$mysqld_pid_file_path"
      if kill -0 $mysqld_pid 2>/dev/null ; then
        log_success_msg "MySQL running ($mysqld_pid)"
        exit 0
      else
        log_failure_msg "MySQL is not running, but PID file exists"
        exit 1
      fi
    else
      # Try to find appropriate mysqld process
      mysqld_pid=`pidof $libexecdir/mysqld`
 
      # test if multiple pids exist
      pid_count=`echo $mysqld_pid | wc -w`
      if test $pid_count -gt 1 ; then
        log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
        exit 5
      elif test -z $mysqld_pid ; then
        if test -f "$lock_file_path" ; then
          log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
          exit 2
        fi
        log_failure_msg "MySQL is not running"
        exit 3
      else
        log_failure_msg "MySQL is running but PID file could not be found"
        exit 4
      fi
    fi
    ;;
    *)
      # usage
      basename=`basename "$0"`
      echo "Usage: $basename  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]"
      exit 1
    ;;
esac
 
exit 0

赋予权限

chmod +x /etc/init.d/mysqld
service mysqld start

用root账户登录并作简单的安全设置,键入以下代码后直接回车:

/lvtao.net/software/mysql/bin/mysql -uroot -p

1. 修改 root 密码

UPDATE mysql.user SET Password=password(‘your password here‘) WHERE User=‘root‘;

2. 删除无名用户

DELETE FROM mysql.user WHERE User=‘‘;

3. 删除root远程访问

DELETE FROM mysql.user WHERE User=‘root‘ AND Host NOT IN (‘localhost‘, ‘127.0.0.1‘, ‘::1‘);

4. 删除 “test” 数据库

DROP database test;

5. 立即生效并退出MYSQL命令窗体

FLUSH PRIVILEGES;QUIT;

五、安装 php
① 安装 php 所需的依赖库

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
 
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
 
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make
make install
cd ../

编辑 ld.so.conf:

vi /etc/ld.so.conf

在最下面添加:

/usr/lib
/usr/lib64

然后:

ldconfig

② 安装 php

tar zxvf php-5.5.12.tar.gz
cd php-5.5.12/
export DYLD_LIBRARY_PATH="/lvtao.net/software/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/lvtao.net/software/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
ln -s /lvtao.net/software/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
./configure --prefix=/lvtao.net/software/php --with-config-file-path=/lvtao.net/software/php/etc --with-mysql=/lvtao.net/software/mysql --with-mysqli=/lvtao.net/software/mysql/bin/mysql_config --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-fpm --enable-mbstring --with-mcrypt --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 /lvtao.net/software/php/etc/php.ini
cd ../

③ 安装 php 扩展

tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7/
/lvtao.net/software/php/bin/phpize
./configure --with-php-config=/lvtao.net/software/php/bin/php-config
make
make install
cd ../
 
tar zxvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure
make
make install
cd ../
 
tar zxvf imagick-3.1.2.tgz
cd imagick-3.1.2/
/lvtao.net/software/php/bin/phpize
./configure --with-php-config=/lvtao.net/software/php/bin/php-config
make
make install
cd ../
 
sed -i ‘s#; extension_dir = "./"#extension_dir = "/lvtao.net/software/php/lib/php/extensions/no-debug-zts-20121212/"\nextension = "memcache.so"\n#g‘ /lvtao.net/software/php/etc/php.ini
sed -i "s#;date.timezone =#date.timezone = Asia/Shanghai#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#;cgi.fix_pathinfo=1#cgi.fix_pathinfo=0#g" /lvtao.net/software/php/etc/php.ini
 
sed -i "s#expose_php = On#expose_php = Off#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#;error_log = php_errors.log#error_log=/lvtao.net/logs/php_scripts_error.log#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#allow_url_fopen = On#allow_url_fopen = Off#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#sql.safe_mode=Off#sql.safe_mode=On#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#max_input_time = 60#max_input_time = 30#g" /lvtao.net/software/php/etc/php.ini
sed -i "s#disable_functions =#disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source#g" /lvtao.net/software/php/etc/php.ini

编辑 /lvtao.net/software/php/etc/php.ini 在最底部添加以下内容:

zend_extension=/lvtao.net/software/php/lib/php/extensions/no-debug-zts-20121212/opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

vi /lvtao.net/software/php/etc/php-fpm.conf

输入以下内容

[www]
user = www
group = www
listen = 127.0.0.1:9000
#listen = /tmp/php-cgi.sock
pm = static
pm.max_children = 35
pm.max_requests = 256
pm.process_idle_timeout = 30s
rlimit_files = 65535
env[TMP] = /tmp/
env[TMPDIR] = /tmp/
env[TEMP] = /tmp/
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
php_admin_value[open_basedir] = /lvtao.net/htdocs/:/tmp/:/var/tmp:/proc/
php_admin_value[session.save_path] = /tmp/
php_admin_value[upload_tmp_dir] = /tmp/
slowlog = /lvtao.net/software/php/var/log/$pool.log
request_slowlog_timeout = 3s
php_admin_value[open_basedir] = /lvtao.net/htdocs/:/tmp/:/var/tmp:/proc/

添加 php-fpm 到服务

cp /lvtao.net/resource/php-5.5.12/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
service php-fpm start

开放必要端口

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save

设置开机自动启动服务

vi /etc/rc.local
ulimit -SHn 65535
service php-fpm start
service nginx start
service mysqld start

配置最大文件数,最下面追加

vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。