CentOS6.9+php5.6.31[PHP-FPM]+nginx-1.6.0+rsync+SVN自动更新脚本


配置环境:

[root@iZ8vbeu0qk8k8cwav32t59Z ~]# cat /etc/redhat-release 
CentOS release 6.9 (Final)
[root@iZ8vbeu0qk8k8cwav32t59Z ~]# uname -a
Linux iZ8vbeu0qk8k8cwav32t59Z 2.6.32-754.14.2.el6.x86_64 #1 SMP Tue May 1419:35:42 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

 需要安装的软件包:
cmake-2.8.11.2.tar.gz
pcre-8.35.tar.gz
libmcrypt-2.5.8.tar.gz
tiff-4.0.3.tar.gz
freetype-2.5.3.tar.gz
zlib-1.2.8.tar.gz
libpng-1.6.12.tar.gz
t1lib-5.1.2.tar.gz
yasm-1.2.0.tar.gz
libvpx-v1.3.0.tar.bz2
jpegsrc.v9a.tar.gz
libgd-2.1.0.tar.gz
nginx-1.6.0.tar.gz
php-5.6.31.tar.gz
yar-1.2.5.tgz
msgpack-0.5.7.tgz
rsync-3.1.2.tar.gz


下载安装包:
wget https://www.linuxprobe.com/Software/freetype-2.5.3.tar.gz
wget https://www.linuxprobe.com/Software/jpegsrc.v9a.tar.gz
wget https://www.linuxprobe.com/Software/libgd-2.1.0.tar.gz
wget https://www.linuxprobe.com/Software/libmcrypt-2.5.8.tar.gz
wget https://www.linuxprobe.com/Software/libpng-1.6.12.tar.gz
wget https://www.linuxprobe.com/Software/libvpx-v1.3.0.tar.bz2
wget https://www.linuxprobe.com/Software/nginx-1.6.0.tar.gz
wget https://www.linuxprobe.com/Software/openssl-1.0.1h.tar.gz
wget https://www.linuxprobe.com/Software/php-5.5.14.tar.gz
wget https://www.linuxprobe.com/Software/pcre-8.35.tar.gz
wget https://www.linuxprobe.com/Software/t1lib-5.1.2.tar.gz
wget https://www.linuxprobe.com/Software/tiff-4.0.3.tar.gz
wget https://www.linuxprobe.com/Software/yasm-1.2.0.tar.gz
安装CMAKE
cd /usr/local/src
wget https://www.linuxprobe.com/Software/cmake-2.8.11.2.tar.gz
tar xzvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2/
./configure
make && make install


cd /usr/local/src
tar xzvf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre && make && make install
cd /usr/local/src
tar xzvf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config --prefix=/usr/local/openssl  &&make && makeinstall


tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install




tar zxvf tiff-4.0.3.tar.gz
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared && make &&make install


tar zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype --enable-shared && make&& make install




cd /usr/local/src
wget https://www.linuxprobe.com/Software/zlib-1.2.8.tar.gz
tar xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib && make && make install
export LDFLAGS="-L/usr/local/zlib/lib"
export CPPFLAGS="-I/usr/local/zlib/include"


cd /usr/local/src
tar zxvf libpng-1.6.12.tar.gz
cd libpng-1.6.12
./configure --prefix=/usr/local/libpng --enable-shared && make&& make install


yum install texlive-latex  texlive-metaposttexlive-collection-fontsrecommended
tar zxvf t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared && make&& make install


yum install -y apr* autoconf automake bison bzip2 bzip2* compat* cpp curlcurl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gccgcc-c++ gd gettext gettext-devel glibc kernel kernel-headers keyutilskeyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg*libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp opensslopenssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnett1lib t1lib* nasm nasm* wget zlib-devel


cd /usr/local/src
tar zxvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure && make && make install


tar xjvf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9 &&make && make install


tar zxvf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --prefix=/usr/local/jpeg --enable-shared && make &&make install


cd /usr/local/src
tar zxvf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure --prefix=/usr/local/libgd --enable-shared--with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng--with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype--with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx&& make && make install




useradd www -s /sbin/nologin


tar xzvf nginx-1.6.0.tar.gz
cd nginx-1.6.0/
./configure --prefix=/usr/local/nginx --without-http_memcached_module--user=www --group=www --with-http_stub_status_module --with-http_ssl_module--with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h--with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
make && make install


ln -s /usr/local/nginx/sbin/nginx  /usr/local/sbin/nginx


vim /etc/rc.d/init.d/nginx
#!/bin/bash
# nginx - this script starts and stops the nginx daemon
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# 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="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/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 755 /etc/rc.d/init.d/nginx
/etc/rc.d/init.d/nginx restart
chkconfig nginx on
curl 127.0.0.1




yum -y install lrzsz lsof


cd /usr/local/src


tar xzvf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/usr/local/php5.6--with-config-file-path=/usr/local/php5.6/etc--with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-iconv--enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm--enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap--without-pear --with-gettext --enable-session --with-mcrypt --with-curl--enable-ctype
make && make install
ln -s /usr/local/php5.6/bin/php-config /usr/local/sbin/php-config
ln -s /usr/local/php5.6/bin/phpize  /usr/local/sbin/phpize


rm -rf /etc/php.ini


cd /usr/local/src/php-5.6.31
cp php.ini-production /usr/local/php5.6/etc/php.ini
ln -s /usr/local/php5.6/etc/php.ini /etc/php.ini       
cp /usr/local/php5.6/etc/php-fpm.conf.default/usr/local/php5.6/etc/php-fpm.conf
ln -s /usr/local/php5.6/etc/php-fpm.conf /etc/php-fpm.conf


cd /usr/local/src/php-5.6.31
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod 755 /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
service php-fpm status
service php-fpm start
service php-fpm status
service php-fpm stop
service php-fpm status


cd /usr/local/nginx/conf/
vim /usr/local/nginx/conf/nginx.conf


user  www www;
worker_processes  1;


#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;


    #log_format  main  '$remote_addr - $remote_user[$time_local] "$request" '
    #                 '$status $body_bytes_sent "$http_referer" '
    #                 '"$http_user_agent" "$http_x_forwarded_for"';


    #access_log  logs/access.log  main;


    sendfile        on;
    #tcp_nopush     on;


    #keepalive_timeout  0;
    keepalive_timeout  65;


    #gzip  on;


    #server {
    #    listen       80;
    #    server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


   #     location / {
   #         root   html;
   #         index  index.htmlindex.htm index.php;
   #     }


        #error_page  404             /404.html;


        # redirect server error pages to the static page/50x.html
        #
   #     error_page   500 502 503 504 /50x.html;
   #     location = /50x.html {
   #         root   html;
   #     }


        # proxy the PHP scripts to Apache listening on127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}


        # pass the PHP scripts to FastCGI server listeningon 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root          html;
        #    fastcgi_pass  127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include       fastcgi_params;
        #}


        # deny access to .htaccess files, if Apache'sdocument root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    #}




    # another virtual host using mix of IP-, name-, and port-basedconfiguration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias another.alias;


    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}




    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;


    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;


    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;


    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;


    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    include vhosts/*.conf;


}


mkdir vhosts
cd vhosts/
vim aliexpress_80.conf
server {
        listen       80;
        server_name  localhost;
        location / {
            root /www/web/api_aliexpress_web;
            index  index.html index.htmindex.php;
                if (!-e$request_filename) {               
                   rewrite  ^(.*)$  /index.php?s=$1  last;
                    break;
                    }


        }
        location ~ \.php$ {
            root /www/web/api_aliexpress_web;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include       fastcgi_params;
        }


}
service nginx reload


mkdir -p /www/web
mkdir -p /www/web/aliexpress


crontab -e
date
/usr/sbin/ntpdate -u 195.13.1.153
vim /etc/php.ini
service php-fpm restart


tar xzvf msgpack-0.5.7.tgz
cd msgpack-0.5.7
phpize
./configure --prefix=/usr/local/msgpack
make && make install


tar xzvf yar-1.2.5.tgz
cd yar-1.2.5
phpize
./configure --prefix=/usr/local/yar && make && make install
vim /usr/local/php5.6/etc/php.ini
service php-fpm restart
php -m | grep yar


cd /usr/local/src
tar xzvf rsync-3.1.2.tar.gz
cd rsync-3.1.2
./configure --prefix=/usr/local/rsync && make && make install
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
mkdir -p /etc/rsyncd/
cd /etc/rsyncd
vim rsyncd.conf
uid = 0
gid = 0
max connections = 4
read only = true
#hosts allow = 202.207.177.180
hosts allow = 127.0.0.1,192.168.66.12,192.168.66.17
transfer logging = true
log format = %h %o %f %l %b 
log file = /var/log/rsyncd.log
slp refresh = 300
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock




[aliexpress]
path = /www/web/api_aliexpress_master
comment = Mirror to Hk server
read only = false
list = false
auth users = rsync_user
secrets file = /etc/rsyncd/rsync.server.password


[api_image_web]
path = /www/web/api_aliexpress_web
comment = Mirror to Hk server
read only = false
list = false
auth users = rsync_user
secrets file = /etc/rsyncd/rsync.server.password


[root@iZ8vbeu0qk8k8cwav32t59Z rsyncd]# cat rsync.client.password
rsync_123456
[root@iZ8vbeu0qk8k8cwav32t59Z rsyncd]# cat rsync.server.password
rsync_user:rsync_123456
[root@iZ8vbeu0qk8k8cwav32t59Z rsyncd]# ll
total 12
-rw------- 1 root root  13 May 31 11:40 rsync.client.password
-rw-r--r-- 1 root root 725 May 31 11:42 rsyncd.conf
-rw------- 1 root root  24 May 31 11:40 rsync.server.password






vim /etc/init.d/rsyncd
#!/bin/bash
#rsyncd This shell script takes care of starting and stopping standalone rsync.
#chkconfig: - 99 50
#description:rsync is a file transport daemon
#processname:rsync
#config:/etc/rsyncd.conf
#Source function library
. /etc/rc.d/init.d/functions
RETVAL=0
prog="rsync"
rsync="/usr/local/rsync/bin/rsync"
pid="/var/run/rsyncd.pid"
lock="/var/run/rsync.lock"
CFILE="/etc/rsyncd/rsyncd.conf"


start() {
            #Start daemons.
            [ -x $rsync ] || \
                       { echo "FATAL:No such programme"; exit 4;        }
            [ -f $CFILE ] || \
                       { echo "FATAL:config file does not exist"; exit 6;  }
            echo -n $"Starting $progdaemon..."
            $rsync --daemon --config=$CFILE
            RETVAL=$?
            echo -n "OK!!!"
            echo
            return $RETVAL
}
stop() {
            #Stop daemons
            echo -n $"Stopping$prog:..."
            kill -9 `cat /var/run/rsyncd.pid`
            RETVAL=$?
            echo
            [ $RETVAL -eq 0 ] && rm -f$pid && rm -f $lock
            echo -n "OK!!!"
            echo
            return $RETVAL
}


status(){
            if [ -f $pid  ];then
                       echo "Rsync is running,pid(`cat $pid`)"
            else
                       echo "Rsync is not running"
            fi




}


#call the function we defined
case "$1" in
start)
            start
            ;;
stop)
            stop
            ;;
restart|reload)
            stop
            start
            RETVAL=$?
            ;;
status)
            status
        RETVAL=$?
            ;;
*)
            echo $"Usage:$0{start|stop|restart|reload|status}"
            exit 2  
esac
exit $RETVAL
chmod 755 /etc/init.d/rsyncd


SVN
自动更新脚本:
#!/bin/bash


#svn
同步api
svn up /www/web/api_aliexpress_master
chown www.www -R /www/web/api_aliexpress_master
chmod 755 -R /www/web/api_aliexpress_master


#rsync
/usr/local/rsync/bin/rsync -avz rsync_user@127.0.0.1::aliexpress/www/web/api_aliexpress_web --password-file=/etc/rsyncd/rsync.client.password--exclude=Upload --exclude=cli.php --exclude=index.php--exclude=Application/Runtime --exclude=Application/Common/Conf --exclude=Application/Home/Conf --exclude=.svn  --delete


#
删除Runtime文件
#rm /www/web/api_web/Application/Runtime -rf

 


分割线
打赏
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS