安装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
install_jemalloc(){echo-e"\n==========jemallocinstall==========\n"cd${current_dir}/src/basetar-jxvf${ltnmp_jemalloc}.tar.bz2cd${ltnmp_jemalloc}./configuremake&&makeinstallecho"/usr/local/lib">/etc/ld.so.conf.d/jemalloc.confldconfigcd${current_dir}}
cetnos下安装以下软件
yum-yinstallmakecmakeautomakegccgcc-c++gcc-g77flexbisonfilelibtoollibtool-libsautoconfkernel-develpatchwgetlibjpeglibjpeg-devellibpnglibpng-devellibpng10libpng10-develgdgd-devellibxml2libxml2-develzlibzlib-develglib2glib2-develunziptarbzip2bzip2-devellibeventlibevent-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-develreadline-develre2cvimgettextgettext-develgmp-develpspell-devellibcapdiffutilsnet-toolslibc-client-develpsmisclibXpm-develgit-corec-ares-develtcl
下载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-dsomake&&makeinstall
vim /etc/init.d/nginx //写入如下内容
#!/bin/sh#chkconfig:23455525#Description:StartupscriptfornginxwebserveronDebian.Placein/etc/init.dand#run'update-rc.d-fnginxdefaults',orusetheappropriatecommandonyour#distro.ForCentOS/Redhatrun:'chkconfig--addnginx'###BEGININITINFO#Provides:nginx#Required-Start:$all#Required-Stop:$all#Default-Start:2345#Default-Stop:016#Short-Description:startsthenginxwebserver#Description:startsnginxusingstart-stop-daemon###ENDINITINFO#Author:licess#website:http://lnmp.orgPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binNAME=nginxNGINX_BIN=/usr/local/nginx/sbin/$NAMECONFIGFILE=/usr/local/nginx/conf/$NAME.confPIDFILE=/usr/local/nginx/logs/$NAME.pidcase"$1"instart)echo-n"Starting$NAME..."ifnetstat-tnpl|grep-qnginx;thenecho"$NAME(pid`pidof$NAME`)alreadyrunning."exit1fi$NGINX_BIN-c$CONFIGFILEif["$?"!=0];thenecho"failed"exit1elseecho"done"fi;;stop)echo-n"Stoping$NAME..."if!netstat-tnpl|grep-qnginx;thenecho"$NAMEisnotrunning."exit1fi$NGINX_BIN-sstopif["$?"!=0];thenecho"failed.Useforce-quit"exit1elseecho"done"fi;;status)ifnetstat-tnpl|grep-qnginx;thenPID=`pidofnginx`echo"$NAME(pid$PID)isrunning..."elseecho"$NAMEisstopped"exit0fi;;force-quit)echo-n"Terminating$NAME..."if!netstat-tnpl|grep-qnginx;thenecho"$NAMEisnotrunning."exit1fikill`pidof$NAME`if["$?"!=0];thenecho"failed"exit1elseecho"done"fi;;restart)$0stopsleep1$0start;;reload)echo-n"Reloadservice$NAME..."ifnetstat-tnpl|grep-qnginx;then$NGINX_BIN-sreloadecho"done"elseecho"$NAMEisnotrunning,can'treload."exit1fi;;configtest)echo-n"Test$NAMEconfigurefiles..."$NGINX_BIN-t;;*)echo"Usage:$0{start|stop|force-quit|restart|reload|status|configtest}"exit1;;esac
//修改权限chmod755/etc/init.d/nginxchkconfig--addnginx
如果想开机启动,请执行:
chkconfignginxon
配置文件调整
mv/usr/local/nginx/conf/nginx.conf/usr/local/nginx/conf/nginx.conf.bak
vim /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -t
theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisokconfigurationfile/usr/local/nginx/conf/nginx.conftestissuccessful
service nginx start
安装php
wget http://php.net/distributions/php-7.1.13.tar.gz
./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
makeZEND_EXTRA_LIBS='-liconv'makeinstall
http://www.apelearn.com/study_v2/chapter18.html
ln-sf/usr/local/php/bin/php/usr/bin/phpln-sf/usr/local/php/bin/phpize/usr/bin/phpizeln-sf/usr/local/php/bin/pear/usr/bin/pearln-sf/usr/local/php/bin/pecl/usr/bin/peclln-sf/usr/local/php/sbin/php-fpm/usr/bin/php-fpm
cpphp.ini-production/usr/local/php/etc/php.ini
修改php.ini中的一些参数
sed-i's/post_max_size=8M/post_max_size=50M/g'/usr/local/php/etc/php.inised-i's/upload_max_filesize=2M/upload_max_filesize=50M/g'/usr/local/php/etc/php.inised-i's/;date.timezone=/date.timezone=PRC/g'/usr/local/php/etc/php.inised-i's/short_open_tag=Off/short_open_tag=On/g'/usr/local/php/etc/php.inised-i's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g'/usr/local/php/etc/php.inised-i's/;cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g'/usr/local/php/etc/php.inised-i's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g'/usr/local/php/etc/php.inised-i's/max_execution_time=30/max_execution_time=300/g'/usr/local/php/etc/php.inised-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
pearconfig-setphp_ini/usr/local/php/etc/php.inipeclconfig-setphp_ini/usr/local/php/etc/php.ini
修改/usr/local/php/etc/php-fpm.conf
[global]pid=/usr/local/php/var/run/php-fpm.piderror_log=/usr/local/php/var/log/php-fpm.loglog_level=notice[www]listen=/dev/shm/php-cgi.socklisten.backlog=-1listen.allowed_clients=127.0.0.1listen.owner=php-fpmlisten.group=php-fpmlisten.mode=0666user=php-fpmgroup=php-fpmpm=dynamicpm.max_children=10pm.start_servers=2pm.min_spare_servers=1pm.max_spare_servers=6request_terminate_timeout=100request_slowlog_timeout=0slowlog=var/log/slow.log
cp/usr/local/src/php-7.1.13/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
测试是否能重启成功
/usr/local/php/sbin/php-fpm-t
把php与nginx添加到系统环境变量中去
export PATH=$PATH:/usr/local/php/bin
export PATH=$PATH:/usr/local/nginx/sbin
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。