安装LNMP环境
準備安裝
[root@centos?~]# cd /usr/local/src/
下載 pcre-8.35.tar.gz到/usr/local/src
[root@centos?~]#wget?
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
下載jemalloc-3.6.0.tar.bz2到/usr/local/src
[root@centos?~]#??wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | install_jemalloc()?{ ????echo?-e?"\n==========jemalloc?install==========\n" ????cd?${current_dir}/src/base ????tar?-jxvf?${ltnmp_jemalloc}.tar.bz2 ????cd?${ltnmp_jemalloc} ????./configure ????make?&&?make?install ????echo?"/usr/local/lib"?>?/etc/ld.so.conf.d/jemalloc.conf ????ldconfig ????cd?${current_dir} } |
cetnos下安裝以下軟件
| 1 | yum?-y?install?make?cmake?automake?gcc?gcc-c++?gcc-g77?flex?bison?file?libtool?libtool-libs?autoconf?kernel-devel?patch?wget?libjpeg?libjpeg-devel?libpng?libpng-devel?libpng10?libpng10-devel?gd?gd-devel?libxml2?libxml2-devel?zlib?zlib-devel?glib2?glib2-devel?unzip?tar?bzip2?bzip2-devel?libevent?libevent-devel?ncurses?ncurses-devel?curl?curl-devel?e2fsprogs?e2fsprogs-devel?krb5?krb5-devel?libidn?libidn-devel?openssl?openssl-devel?readline-devel?re2c?vim?gettext?gettext-devel?gmp-devel?pspell-devel?libcap?diffutils?net-tools?libc-client-devel?psmisc?libXpm-devel?git-core?c-ares-devel?tcl |
下載tengine
http://tengine.taobao.org/download/tengine-2.2.1.tar.gz
useradd -s /sbin/nologin php-fpm
./configure?--user=www?--group=www?--prefix=/usr/local/nginx?--with-http_stub_status_module?--with-http_ssl_module?--with-http_spdy_module?--with-http_gzip_static_module?--with-ipv6?--with-http_sub_module?--with-http_sysguard_module?--with-http_concat_module?--with-jemalloc?--without-dso make?&&?make?installvim? /etc/init.d/nginx? ?//寫入如下內容
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | #!?/bin/sh #?chkconfig:?2345?55?25 #?Description:?Startup?script?for?nginx?webserver?on?Debian.?Place?in?/etc/init.d?and #?run?'update-rc.d?-f?nginx?defaults',?or?use?the?appropriate?command?on?your #?distro.?For?CentOS/Redhat?run:?'chkconfig?--add?nginx' ###?BEGIN?INIT?INFO #?Provides:??????????nginx #?Required-Start:????$all #?Required-Stop:?????$all #?Default-Start:?????2?3?4?5 #?Default-Stop:??????0?1?6 #?Short-Description:?starts?the?nginx?web?server #?Description:???????starts?nginx?using?start-stop-daemon ###?END?INIT?INFO #?Author:???licess #?website:??http://lnmp.org PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=nginx NGINX_BIN=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid case?"$1"?in ????start) ????????echo?-n?"Starting?$NAME...?" ????????if?netstat?-tnpl?|?grep?-q?nginx;then ????????????echo?"$NAME?(pid?`pidof?$NAME`)?already?running." ????????????exit?1 ????????fi ????????$NGINX_BIN?-c?$CONFIGFILE ????????if?[?"$?"?!=?0?]?;?then ????????????echo?"?failed" ????????????exit?1 ????????else ????????????echo?"?done" ????????fi ????????;; ????stop) ????????echo?-n?"Stoping?$NAME...?" ????????if?!?netstat?-tnpl?|?grep?-q?nginx;?then ????????????echo?"$NAME?is?not?running." ????????????exit?1 ????????fi ????????$NGINX_BIN?-s?stop ????????if?[?"$?"?!=?0?]?;?then ????????????echo?"?failed.?Use?force-quit" ????????????exit?1 ????????else ????????????echo?"?done" ????????fi ????????;; ????status) ????????if?netstat?-tnpl?|?grep?-q?nginx;?then ????????????PID=`pidof?nginx` ????????????echo?"$NAME?(pid?$PID)?is?running..." ????????else ????????????echo?"$NAME?is?stopped" ????????????exit?0 ????????fi ????????;; ????force-quit) ????????echo?-n?"Terminating?$NAME...?" ????????if?!?netstat?-tnpl?|?grep?-q?nginx;?then ????????????echo?"$NAME?is?not?running." ????????????exit?1 ????????fi ????????kill?`pidof?$NAME` ????????if?[?"$?"?!=?0?]?;?then ????????????echo?"?failed" ????????????exit?1 ????????else ????????????echo?"?done" ????????fi ????????;; ????restart) ????????$0?stop ????????sleep?1 ????????$0?start ????????;; ????reload) ????????echo?-n?"Reload?service?$NAME...?" ????????if?netstat?-tnpl?|?grep?-q?nginx;?then ????????????$NGINX_BIN?-s?reload ????????????echo?"?done" ????????else ????????????echo?"$NAME?is?not?running,?can't?reload." ????????????exit?1 ????????fi ????????;; ????configtest) ????????echo?-n?"Test?$NAME?configure?files...?" ????????$NGINX_BIN?-t ????????;; ????*) ????????echo?"Usage:?$0?{start|stop|force-quit|restart|reload|status|configtest}" ????????exit?1 ????????;; esac |
| 1 2 3 | //修改權限 chmod?755?/etc/init.d/nginx chkconfig?--add?nginx |
如果想開機啟動,請執行:
chkconfig?nginx?on配置文件調整
| 1 | mv?/usr/local/nginx/conf/nginx.conf?/usr/local/nginx/conf/nginx.conf.bak |
vim /usr/local/nginx/conf/nginx.conf
| 1 | <br data-filtered="filtered"> |
/usr/local/nginx/sbin/nginx -t
| 1 2 | the?configuration?file?/usr/local/nginx/conf/nginx.conf?syntax?is?ok configuration?file?/usr/local/nginx/conf/nginx.conf?test?is?successful |
service nginx start
安裝php
wget? ? http://php.net/distributions/php-7.1.13.tar.gz
| 1 | ./configure?--prefix=/usr/local/php?--with-config-file-path=/usr/local/php/etc?--enable-fpm?--with-fpm-user=www?--with-fpm-group=www?--with-mysqli=mysqlnd?--with-pdo-mysql=mysqlnd?--with-iconv-dir?--with-freetype-dir=/usr/local/freetype?--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-mbstring?--with-mcrypt?--enable-ftp?--with-gd?--enable-gd-native-ttf?--with-openssl?--with-mhash?--enable-pcntl?--enable-sockets?--with-xmlrpc?--enable-zip?--enable-soap?--with-gettext?--enable-opcache |
缺失libmcrypt時安裝
yum install libmcrypt libmcrypt-devel mcrypt mhash
make?ZEND_EXTRA_LIBS='-liconv' make?installhttp://www.apelearn.com/study_v2/chapter18.html
| 1 2 3 4 5 | ln?-sf?/usr/local/php/bin/php?/usr/bin/php ln?-sf?/usr/local/php/bin/phpize?/usr/bin/phpize ln?-sf?/usr/local/php/bin/pear?/usr/bin/pear ln?-sf?/usr/local/php/bin/pecl?/usr/bin/pecl ln?-sf?/usr/local/php/sbin/php-fpm?/usr/bin/php-fpm |
| 1 | cp?php.ini-production?/usr/local/php/etc/php.ini |
修改php.ini中的一些參數
| 1 2 3 4 5 6 7 8 9 | sed?-i?'s/post_max_size?=?8M/post_max_size?=?50M/g'?/usr/local/php/etc/php.ini sed?-i?'s/upload_max_filesize?=?2M/upload_max_filesize?=?50M/g'?/usr/local/php/etc/php.ini sed?-i?'s/;date.timezone?=/date.timezone?=?PRC/g'?/usr/local/php/etc/php.ini sed?-i?'s/short_open_tag?=?Off/short_open_tag?=?On/g'?/usr/local/php/etc/php.ini sed?-i?'s/;?cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g'?/usr/local/php/etc/php.ini sed?-i?'s/;?cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g'?/usr/local/php/etc/php.ini sed?-i?'s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g'?/usr/local/php/etc/php.ini sed?-i?'s/max_execution_time?=?30/max_execution_time?=?300/g'?/usr/local/php/etc/php.ini sed?-i?'s/disable_functions?=.*/disable_functions?=?passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g'?/usr/local/php/etc/php.ini |
| 1 2 | pear?config-set?php_ini?/usr/local/php/etc/php.ini pecl?config-set?php_ini?/usr/local/php/etc/php.ini |
修改/usr/local/php/etc/php-fpm.conf
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [global] pid?=?/usr/local/php/var/run/php-fpm.pid error_log?=?/usr/local/php/var/log/php-fpm.log log_level?=?notice [www] listen?=?/dev/shm/php-cgi.sock listen.backlog?=?-1 listen.allowed_clients?=?127.0.0.1 listen.owner?=?php-fpm listen.group?=?php-fpm listen.mode?=?0666 user?=?php-fpm group?=?php-fpm pm?=?dynamic pm.max_children?=?10 pm.start_servers?=?2 pm.min_spare_servers?=?1 pm.max_spare_servers?=?6 request_terminate_timeout?=?100 request_slowlog_timeout?=?0 slowlog?=?var/log/slow.log |
| 1 | cp?/usr/local/src/php-7.1.13/sapi/fpm/init.d.php-fpm?/etc/init.d/php-fpm |
測試是否能重啟成功
| 1 | /usr/local/php/sbin/php-fpm?-t |
把php與nginx添加到系統環境變量中去
export PATH=$PATH:/usr/local/php/bin
export PATH=$PATH:/usr/local/nginx/sbin
本文轉自 a928154159 51CTO博客,原文鏈接:http://blog.51cto.com/zhibeiwang/2044163
總結
- 上一篇: shell字符串截取总结
- 下一篇: toolbar.netcraft.com