{"id":25,"date":"2011-08-22T07:13:35","date_gmt":"2011-08-22T07:13:35","guid":{"rendered":"http:\/\/shuran.cn\/?p=25"},"modified":"2012-02-08T04:09:05","modified_gmt":"2012-02-08T04:09:05","slug":"centos-redhat-%e9%85%8d%e7%bd%ae-nginx-%e3%80%81php%e3%80%81php-fpm%e3%80%81mysql%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/www.shuran.cn\/?p=25","title":{"rendered":"centos redhat \u914d\u7f6e nginx \u3001php\u3001php-fpm\u3001mysql\u5b9e\u8df5"},"content":{"rendered":"<p>centos <\/p>\n<p>1\u3001\u4fee\u6539\u7cfb\u7edf\u65f6\u533a<\/p>\n<p>#cp \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime<br \/>\n#reboot<\/p>\n<p>\/etc\/localtime \u662f\u5f53\u524d\u65f6\u533a\u6587\u4ef6<br \/>\n\/usr\/share\/zoneinfo\/ \u662f\u5168\u90e8\u65f6\u533a\u6587\u4ef6\u4f4d\u7f6e\u3002<\/p>\n<p>2\u3001\u4fee\u6539\u65f6\u95f4<\/p>\n<p>#date -s 2010-08-20<\/p>\n<p>#date -s 19:40:52<\/p>\n<p>#hwclock -w<\/p>\n<p>\u5f53\u524d\u65f6\u95f4\u5199\u5165bios\uff0c\u907f\u514d\u91cd\u542f\u5931\u6548\u3002<\/p>\n<p>3\u3001\u65f6\u95f4\u540c\u6b65<\/p>\n<p>#\/usr\/sbin\/ntpdate 210.72.145.44 > \/dev\/null 2>&1<br \/>\n#<br \/>\n#<br \/>\n#<br \/>\n#<br \/>\n4\u3001\u4e0b\u8f7dnginx<br \/>\n#.\/configure --prefix=\/usr\/local\/nginx  --prefix=\/usr\/local\/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-<\/p>\n<p>http_stub_status_module<\/p>\n<p>#<br \/>\n\u914d\u7f6e\u542f\u52a8\u811a\u672c<br \/>\n#!\/bin\/sh<br \/>\n#<br \/>\n# nginx - this script starts and stops the nginx daemin<br \/>\n#<br \/>\n# chkconfig:   234 85 15<br \/>\n# description:  Nginx is an HTTP(S) server, HTTP(S) reverse<br \/>\n#               proxy and IMAP\/POP3 proxy server<br \/>\n# processname: nginx<br \/>\n# config:      \/usr\/local\/nginx\/conf\/nginx.conf<br \/>\n# pidfile:     \/usr\/local\/nginx\/logs\/nginx.pid<\/p>\n<p># Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions<\/p>\n<p># Source networking configuration.<br \/>\n. \/etc\/sysconfig\/network<\/p>\n<p># Check that networking is up.<br \/>\n[ \"$NETWORKING\" = \"no\" ] && exit 0<\/p>\n<p>nginx=\"\/usr\/local\/nginx\/sbin\/nginx\"<br \/>\nprog=$(basename $nginx)<\/p>\n<p>NGINX_CONF_FILE=\"\/usr\/local\/nginx\/conf\/nginx.conf\"<\/p>\n<p>lockfile=\/var\/lock\/subsys\/nginx<\/p>\n<p>start() {<br \/>\n    [ -x $nginx ] || exit 5<br \/>\n    [ -f $NGINX_CONF_FILE ] || exit 6<br \/>\n    echo -n $\"Starting $prog: \"<br \/>\n    daemon $nginx -c $NGINX_CONF_FILE<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] && touch $lockfile<br \/>\n    return $retval<br \/>\n}<\/p>\n<p>stop() {<br \/>\n    echo -n $\"Stopping $prog: \"<br \/>\n    killproc $prog -QUIT<br \/>\n    retval=$?<br \/>\n    echo<br \/>\n    [ $retval -eq 0 ] && rm -f $lockfile<br \/>\n    return $retval<br \/>\n}<\/p>\n<p>restart() {<br \/>\n    configtest || return $?<br \/>\n    stop<br \/>\n    start<br \/>\n}<\/p>\n<p>reload() {<br \/>\n    configtest || return $?<br \/>\n    echo -n $\"Reloading $prog: \"<br \/>\n    killproc $nginx -HUP<br \/>\n    RETVAL=$?<br \/>\n    echo<br \/>\n}<\/p>\n<p>force_reload() {<br \/>\n    restart<br \/>\n}<\/p>\n<p>configtest() {<br \/>\n  $nginx -t -c $NGINX_CONF_FILE<br \/>\n}<\/p>\n<p>rh_status() {<br \/>\n    status $prog<br \/>\n}<\/p>\n<p>rh_status_q() {<br \/>\n    rh_status >\/dev\/null 2>&1<br \/>\n}<\/p>\n<p>case \"$1\" in<br \/>\n    start)<br \/>\n        rh_status_q && exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    stop)<br \/>\n        rh_status_q || exit 0<br \/>\n        $1<br \/>\n        ;;<br \/>\n    restart|configtest)<br \/>\n        $1<br \/>\n        ;;<br \/>\n    reload)<br \/>\n        rh_status_q || exit 7<br \/>\n        $1<br \/>\n        ;;<br \/>\n    force-reload)<br \/>\n        force_reload<br \/>\n        ;;<br \/>\n    status)<br \/>\n        rh_status<br \/>\n        ;;<br \/>\n    condrestart|try-restart)<br \/>\n        rh_status_q || exit 0<br \/>\n            ;;<br \/>\n    *)<br \/>\n        echo $\"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}\"<br \/>\n        exit 2<br \/>\nesac<\/p>\n<p>\u4fdd\u5b58\u4e3anginx;\u7136\u540e\u6267\u884c<\/p>\n<p>chmod +x \/etc\/init.d\/nginx<\/p>\n<p>\/sbin\/chkconfig nginx on<\/p>\n<p>\/sbin\/chkconfig \u2013list nginx<br \/>\nnginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off<\/p>\n<p>\u5b8c\u6210\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e86<br \/>\nservice nginx start<br \/>\nservice nginx stop<br \/>\nservice nginx restart<br \/>\nservice nginx reload<br \/>\n\/etc\/init.d\/nginx start<br \/>\n\/etc\/init.d\/nginx stop<br \/>\n\/etc\/init.d\/nginx restart<br \/>\n\/etc\/init.d\/nginx reload<\/p>\n<p>5\u3001\u5b89\u88c5mysql<br \/>\n#<br \/>\n#\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305<br \/>\n#tar -zxvf \u8fdb\u884c\u89e3\u538b\u7f29<br \/>\n#mv  mysql-5.6.2-m5-linux2.6-x86_64 \/usr\/local\/mysql<br \/>\n# cd \/usr\/local\/mysql<br \/>\n#groupadd mysql<br \/>\n#useradd -g mysql mysql<br \/>\n#chown -R root \/usr\/local\/mysql<br \/>\n# chgrp -R mysql \/usr\/local\/mysql<br \/>\n# chown -R mysql \/usr\/local\/mysql\/data<br \/>\n\u751f\u6210mysql\u7cfb\u7edf\u6570\u636e\u5e93<br \/>\n# \/usr\/local\/mysql\/scripts\/mysql_install_db --user=mysql&<br \/>\n\u751f\u6210my.cnf\u6587\u4ef6<br \/>\n# cp support-files\/my-medium.cnf \/etc\/my.cnf<br \/>\n\u8bbe\u7f6emysql\u670d\u52a1<br \/>\n#cp support-files\/mysql.server \/etc\/init.d\/mysql<br \/>\n#chmod +x \/etc\/init.d\/mysql<br \/>\n#chkconfig mysql on<br \/>\n#chkconfig --list mysql<br \/>\n#service mysql start<\/p>\n<p>6\u3001\u5b89\u88c5php<\/p>\n<p># wget http:\/\/mirrors.sohu.com\/php\/php-5.2.17.tar.gz<br \/>\n#wget http:\/\/php-fpm.org\/downloads\/php-5.2.17-fpm-0.5.14.diff.gz<br \/>\n#wget http:\/\/mirror.yongbok.net\/nongnu\/freetype\/freetype-2.4.6.tar.gz<br \/>\n# tar -zxvf freetype-2.4.6.tar.gz<br \/>\n# cd freetype-2.4.6<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<br \/>\n#wget http:\/\/downloads.sourceforge.net\/project\/libpng\/libpng15\/1.5.4\/libpng-1.5.4.tar.gz<br \/>\n#tar -zxvf libpng-1.5.4.tar.gz<br \/>\n#cd libpng-1.5.4<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<br \/>\n#wget http:\/\/www.ijg.org\/files\/jpegsrc.v8c.tar.gz<br \/>\n#tar -zxvf jpegsrc.v8c.tar.gz<br \/>\n#cd jpeg-8c\/<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<br \/>\n#wget http:\/\/downloads.sourceforge.net\/project\/mcrypt\/Libmcrypt\/2.5.8\/libmcrypt-2.5.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%<\/p>\n<p>2F&ts=1314104860&use_mirror=cdnetworks-kr-1<br \/>\n#tar -zxvf libmcrypt-2.5.8.tar.gz<br \/>\n#cd libmcrypt-2.5.8<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<\/p>\n<p>#wget http:\/\/downloads.sourceforge.net\/project\/mcrypt\/MCrypt\/2.6.8\/mcrypt-2.6.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%<\/p>\n<p>2F&ts=1314104707&use_mirror=cdnetworks-kr-1<br \/>\n#tar -zxvf mcrypt-2.6.8.tar.gz<br \/>\n#cd mcrypt-2.6.8<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<\/p>\n<p>#wget http:\/\/downloads.sourceforge.net\/project\/mhash\/mhash\/0.9.9.9\/mhash-0.9.9.9.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmhash%2Ffiles%2Fmhash%2F0.9.9.9%<\/p>\n<p>2F&ts=1314190360&use_mirror=nchc<br \/>\n#tar -zxvf mhash-0.9.9.9.tar.gz<br \/>\n#cd mhash-0.9.9.9<br \/>\n#.\/configure<br \/>\n#make<br \/>\n#make install<\/p>\n<p>#tar -zxvf php-5.2.17.tar.gz<br \/>\n#gunzip php-5.2.17-fpm-0.5.14.diff.gz<br \/>\n#patch -d php-5.2.17 -p1 < php-5.2.17-fpm-0.5.14.diff\n#cd php-5.2.17\n#.\/configure --prefix=\/usr\/local\/php --with-config-file-path=\/usr\/local\/php\/etc --with-mysql=\/usr\/local\/mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir \n\n--with-zlib --with-libxml-dir --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-\n\noptimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --\n\nenable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable\n\n-suhosin \n#make\n#make install\n#\u4fee\u6539 \/usr\/local\/php\/etc\/php-fpm.conf\u6587\u4ef6\uff0c\u53bb\u6389Nobody \u9644\u8fd1\u7684\u6ce8\u91ca\n#vi \/usr\/local\/php\/etc\/php-fpm.conf\n                        Unix user of processes\n                        <value name=\"user\">nobody<\/value><\/p>\n<p>                        Unix group of processes<br \/>\n                        <value name=\"group\">nobody<\/value><\/p>\n<p>#\u65b0\u5efa\u542f\u52a8\u811a\u672c\u6587\u4ef6<br \/>\n#vi \/etc\/init.d\/php<\/p>\n<p>#! \/bin\/sh<br \/>\n# chkconfig: 2345 20 80<br \/>\n# description: Saves and restores system entropy pool for<br \/>\n# higher quality random number generation.<\/p>\n<p>php_fpm_BIN=\/usr\/local\/php\/bin\/php-cgi<br \/>\nphp_fpm_CONF=\/usr\/local\/php\/etc\/php-fpm.conf<br \/>\nphp_fpm_PID=\/usr\/local\/php\/logs\/php-fpm.pid<\/p>\n<p>php_opts=\"--fpm-config $php_fpm_CONF\"<\/p>\n<p>wait_for_pid () {<br \/>\n\ttry=0<\/p>\n<p>\twhile test $try -lt 35 ; do<\/p>\n<p>\t\tcase \"$1\" in<br \/>\n\t\t\t'created')<br \/>\n\t\t\tif [ -f \"$2\" ] ; then<br \/>\n\t\t\t\ttry=''<br \/>\n\t\t\t\tbreak<br \/>\n\t\t\tfi<br \/>\n\t\t\t;;<\/p>\n<p>\t\t\t'removed')<br \/>\n\t\t\tif [ ! -f \"$2\" ] ; then<br \/>\n\t\t\t\ttry=''<br \/>\n\t\t\t\tbreak<br \/>\n\t\t\tfi<br \/>\n\t\t\t;;<br \/>\n\t\tesac<\/p>\n<p>\t\techo -n .<br \/>\n\t\ttry=`expr $try + 1`<br \/>\n\t\tsleep 1<\/p>\n<p>\tdone<\/p>\n<p>}<\/p>\n<p>case \"$1\" in<br \/>\n\tstart)<br \/>\n\t\techo -n \"Starting php_fpm \"<\/p>\n<p>\t\t$php_fpm_BIN --fpm $php_opts<\/p>\n<p>\t\tif [ \"$?\" != 0 ] ; then<br \/>\n\t\t\techo \" failed\"<br \/>\n\t\t\texit 1<br \/>\n\t\tfi<\/p>\n<p>\t\twait_for_pid created $php_fpm_PID<\/p>\n<p>\t\tif [ -n \"$try\" ] ; then<br \/>\n\t\t\techo \" failed\"<br \/>\n\t\t\texit 1<br \/>\n\t\telse<br \/>\n\t\t\techo \" done\"<br \/>\n\t\tfi<br \/>\n\t;;<\/p>\n<p>\tstop)<br \/>\n\t\techo -n \"Shutting down php_fpm \"<\/p>\n<p>\t\tif [ ! -r $php_fpm_PID ] ; then<br \/>\n\t\t\techo \"warning, no pid file found - php-fpm is not running ?\"<br \/>\n\t\t\texit 1<br \/>\n\t\tfi<\/p>\n<p>\t\tkill -TERM `cat $php_fpm_PID`<\/p>\n<p>\t\twait_for_pid removed $php_fpm_PID<\/p>\n<p>\t\tif [ -n \"$try\" ] ; then<br \/>\n\t\t\techo \" failed\"<br \/>\n\t\t\texit 1<br \/>\n\t\telse<br \/>\n\t\t\techo \" done\"<br \/>\n\t\tfi<br \/>\n\t;;<\/p>\n<p>\tquit)<br \/>\n\t\techo -n \"Gracefully shutting down php_fpm \"<\/p>\n<p>\t\tif [ ! -r $php_fpm_PID ] ; then<br \/>\n\t\t\techo \"warning, no pid file found - php-fpm is not running ?\"<br \/>\n\t\t\texit 1<br \/>\n\t\tfi<\/p>\n<p>\t\tkill -QUIT `cat $php_fpm_PID`<\/p>\n<p>\t\twait_for_pid removed $php_fpm_PID<\/p>\n<p>\t\tif [ -n \"$try\" ] ; then<br \/>\n\t\t\techo \" failed\"<br \/>\n\t\t\texit 1<br \/>\n\t\telse<br \/>\n\t\t\techo \" done\"<br \/>\n\t\tfi<br \/>\n\t;;<\/p>\n<p>\trestart)<br \/>\n\t\t$0 stop<br \/>\n\t\t$0 start<br \/>\n\t;;<\/p>\n<p>\treload)<\/p>\n<p>\t\techo -n \"Reload service php-fpm \"<\/p>\n<p>\t\tif [ ! -r $php_fpm_PID ] ; then<br \/>\n\t\t\techo \"warning, no pid file found - php-fpm is not running ?\"<br \/>\n\t\t\texit 1<br \/>\n\t\tfi<\/p>\n<p>\t\tkill -USR2 `cat $php_fpm_PID`<\/p>\n<p>\t\techo \" done\"<br \/>\n\t;;<\/p>\n<p>\tlogrotate)<\/p>\n<p>\t\techo -n \"Re-opening php-fpm log file \"<\/p>\n<p>\t\tif [ ! -r $php_fpm_PID ] ; then<br \/>\n\t\t\techo \"warning, no pid file found - php-fpm is not running ?\"<br \/>\n\t\t\texit 1<br \/>\n\t\tfi<\/p>\n<p>\t\tkill -USR1 `cat $php_fpm_PID`<\/p>\n<p>\t\techo \" done\"<br \/>\n\t;;<\/p>\n<p>\t*)<br \/>\n\t\techo \"Usage: $0 {start|stop|quit|restart|reload|logrotate}\"<br \/>\n\t\texit 1<br \/>\n\t;;<\/p>\n<p>esac<\/p>\n<p>#chmod +x php<br \/>\n#chkconfig \/etc\/init.d\/php on<br \/>\n#service php start<br \/>\n#<br \/>\n#<br \/>\n#-----------------------------------------------------------------------------------------------------------------------------------------<br \/>\n#\u5b89\u88c5\u8fc7\u7a0b\u5b8c\u6210\u3002<br \/>\n#\u6d4b\u8bd5html\u4ee5\u53caphp<br \/>\n#\u7f16\u8f91nginx\u914d\u7f6e\u6587\u4ef6<br \/>\n#vi \/usr\/local\/ngin\/conf\/nginx.conf<br \/>\n gzip  on;<\/p>\n<p>    server {<br \/>\n        listen       80;<br \/>\n        server_name 192.168.1.251 ;<\/p>\n<p>        #charset koi8-r;<\/p>\n<p>        #access_log  logs\/host.access.log  main;<\/p>\n<p>        location \/ {<br \/>\n            root   \/web;<br \/>\n            index  index.html index.htm;<br \/>\n        }<\/p>\n<p>.......<br \/>\n  location ~ .php$ {<br \/>\n           root           \/web;<br \/>\n           fastcgi_pass   127.0.0.1:9000;<br \/>\n           fastcgi_index  index.php;<br \/>\n           fastcgi_param  SCRIPT_FILENAME  \/web$fastcgi_script_name;<br \/>\n           include        fastcgi_params;<br \/>\n       }<br \/>\n\u9000\u51fa\u4fdd\u5b58<\/p>\n<p>#service nginx restart<\/p>\n","protected":false},"excerpt":{"rendered":"<p>centos 1\u3001\u4fee\u6539\u7cfb\u7edf\u65f6\u533a #cp \/usr\/share\/zoneinfo\/Asia\/Shanghai \/\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.shuran.cn\/?p=25\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":2,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}