1、系统:CentOS最小化安装;升级软件补丁,内核和系统版本不升级;关闭SELinux和防火墙。系统安装可参考
IT运维网 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明CentO […]
1、安装EPEL源-阿里云
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup #如本地不存在EPEL请忽略
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup #如本地不存在EPEL请忽略
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --2018-05-08 20:46:24-- http://mirrors.aliyun.com/repo/epel-7.repo Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 218.98.9.96, 218.98.9.101, 218.98.9.98, ... Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|218.98.9.96|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1084 (1.1K) [application/octet-stream] Saving to: ‘/etc/yum.repos.d/epel.repo’ 100%[==================================================================================================================>] 1,084 --.-K/s in 0s 2018-03-06 20:46:24 (142 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [1084/1084]
2、安装PHP基础库和扩展库
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libpng-devel libcurl-devel libxslt-devel freetype-devel gd-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libicu-devel -y
[root@localhost ~]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libpng-devel libcurl-devel libxslt-devel freetype-devel gd-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libicu-devel -y Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): epel/x86_64/group_gz | 266 kB 00:00:00 (2/3): epel/x86_64/updateinfo | 919 kB 00:00:00 (3/3): epel/x86_64/primary_db | 6.4 MB 00:00:00 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Package zlib-devel-1.2.7-17.el7.x86_64 already installed and latest version Package 1:openssl-devel-1.0.2k-8.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package freetype-devel.x86_64 0:2.4.11-15.el7 will be installed ---> Package gd-devel.x86_64 0:2.0.35-26.el7 will be installed --> Processing Dependency: gd = 2.0.35-26.el7 for package: gd-devel-2.0.35-26.el7.x86_64 --> Processing Dependency: libXpm-devel for package: gd-devel-2.0.35-26.el7.x86_64 --> Processing Dependency: libX11-devel for package: gd-devel-2.0.35-26.el7.x86_64 --> Processing Dependency: fontconfig-devel for package: gd-devel-2.0.35-26.el7.x86_64 --> Processing Dependency: libgd.so.2()(64bit) for package: gd-devel-2.0.35-26.el7.x86_64 ---> Package libcurl-devel.x86_64 0:7.29.0-42.el7_4.1 will be installed epel/x86_64/filelists_db | 10 MB 00:00:01 updates/7/x86_64/filelists_db | 4.2 MB 00:00:00 ---> Package libicu-devel.x86_64 0:50.1.2-15.el7 will be installed ---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 will be installed ......此处省略...... ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================ Installing: freetype-devel x86_64 2.4.11-15.el7 base 356 k gd-devel x86_64 2.0.35-26.el7 base 79 k ......此处省略...... xorg-x11-proto-devel noarch 7.7-20.el7 base 284 k xz-devel x86_64 5.2.2-1.el7 base 46 k Transaction Summary ============================================================================================================================================================ Install 11 Packages (+26 Dependent packages) Total download size: 8.1 M Installed size: 32 M Downloading packages: (1/37): expat-devel-2.1.0-10.el7_3.x86_64.rpm | 57 kB 00:00:00 (2/37): fontconfig-2.10.95-11.el7.x86_64.rpm | 229 kB 00:00:00 ......此处省略...... (36/37): xorg-x11-proto-devel-7.7-20.el7.noarch.rpm | 284 kB 00:00:00 (37/37): xz-devel-5.2.2-1.el7.x86_64.rpm | 46 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 3.2 MB/s | 8.1 MB 00:00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libXau-1.0.8-2.1.el7.x86_64 1/37 Installing : libxcb-1.12-1.el7.x86_64 2/37 ......此处省略...... Verifying : libgpg-error-devel-1.12-3.el7.x86_64 36/37 Verifying : libXau-devel-1.0.8-2.1.el7.x86_64 37/37 Installed: freetype-devel.x86_64 0:2.4.11-15.el7 gd-devel.x86_64 0:2.0.35-26.el7 libcurl-devel.x86_64 0:7.29.0-42.el7_4.1 libicu-devel.x86_64 0:50.1.2-15.el7 libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 libmcrypt-devel.x86_64 0:2.5.8-13.el7 libpng-devel.x86_64 2:1.5.13-7.el7_2 libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 libxslt-devel.x86_64 0:1.1.28-5.el7 mcrypt.x86_64 0:2.6.8-11.el7 mhash-devel.x86_64 0:0.9.9.9-10.el7 Dependency Installed: expat-devel.x86_64 0:2.1.0-10.el7_3 fontconfig.x86_64 0:2.10.95-11.el7 fontconfig-devel.x86_64 0:2.10.95-11.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 gd.x86_64 0:2.0.35-26.el7 libICE.x86_64 0:1.0.9-9.el7 libSM.x86_64 0:1.2.2-2.el7 libX11.x86_64 0:1.6.5-1.el7 libX11-common.noarch 0:1.6.5-1.el7 libX11-devel.x86_64 0:1.6.5-1.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXau-devel.x86_64 0:1.0.8-2.1.el7 libXext.x86_64 0:1.3.3-3.el7 libXpm.x86_64 0:3.5.12-1.el7 libXpm-devel.x86_64 0:3.5.12-1.el7 libXt.x86_64 0:1.1.5-3.el7 libgcrypt-devel.x86_64 0:1.5.3-14.el7 libgpg-error-devel.x86_64 0:1.12-3.el7 libmcrypt.x86_64 0:2.5.8-13.el7 libpng.x86_64 2:1.5.13-7.el7_2 libxcb.x86_64 0:1.12-1.el7 libxcb-devel.x86_64 0:1.12-1.el7 lyx-fonts.noarch 0:2.2.3-1.el7 mhash.x86_64 0:0.9.9.9-10.el7 xorg-x11-proto-devel.noarch 0:7.7-20.el7 xz-devel.x86_64 0:5.2.2-1.el7 Complete!
3、安装libiconv:下载地址(https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz),下载后存放至/usr/src目录,解压libiconv程序并进入目录编译安装
cd /usr/src/
tar -zxf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure –prefix=/usr/local/libiconv
make && make install
[root@localhost ~]# cd /usr/src/ [root@localhost src]# tar -zxf libiconv-1.15.tar.gz [root@localhost src]# cd libiconv-1.15 [root@localhost libiconv-1.15]# ./configure --prefix=/usr/local/libiconv checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes ......此处省略...... checking whether usleep is declared without a macro... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile ......此处省略...... configure: creating ./config.status config.status: creating Makefile config.status: executing libtool commands [root@localhost libiconv-1.15]# make && make install builddir="`pwd`"; cd libcharset && make all && make install-lib libdir="$builddir/lib" includedir="$builddir/lib" make[1]: Entering directory `/usr/src/libiconv-1.15/libcharset' ......此处省略...... case "linux-gnu" in \ hpux*) gcc -g -O2 `if test -n ''; then /usr/local/libiconv/bin; fi` iconv.o ../srclib/libicrt.a -L/usr/local/libiconv/lib -liconv `if test -n ''; then echo " -Wl,+b -Wl,/usr/local/libiconv/lib"; fi` -o iconv;; \ *) /bin/sh ../libtool --mode=link gcc -g -O2 `if test -n ''; then /usr/local/libiconv/bin; fi` iconv.o ../srclib/libicrt.a /usr/local/libiconv/lib/libiconv.la -o iconv;; \ esac libtool: link: gcc -g -O2 iconv.o -o iconv ../srclib/libicrt.a /usr/local/libiconv/lib/libiconv.so -Wl,-rpath -Wl,/usr/local/libiconv/lib -Wl,-rpath -Wl,/usr/local/libiconv/lib /bin/sh ../libtool --mode=install /usr/bin/install -c iconv /usr/local/libiconv/bin/iconv libtool: install: /usr/bin/install -c iconv /usr/local/libiconv/bin/iconv make[1]: Leaving directory `/usr/src/libiconv-1.15/src' if [ ! -d /usr/local/libiconv/include ] ; then /bin/sh ./build-aux/mkinstalldirs /usr/local/libiconv/include ; fi /usr/bin/install -c -m 644 include/iconv.h.inst /usr/local/libiconv/include/iconv.h cd po && make install prefix='/usr/local/libiconv' exec_prefix='/usr/local/libiconv' datarootdir='/usr/local/libiconv/share' datadir='/usr/local/libiconv/share' make[1]: Entering directory `/usr/src/libiconv-1.15/po' installing af.gmo as /usr/local/libiconv/share/locale/af/LC_MESSAGES/libiconv.mo installing bg.gmo as /usr/local/libiconv/share/locale/bg/LC_MESSAGES/libiconv.mo ......此处省略...... installing zh_CN.gmo as /usr/local/libiconv/share/locale/zh_CN/LC_MESSAGES/libiconv.mo installing zh_TW.gmo as /usr/local/libiconv/share/locale/zh_TW/LC_MESSAGES/libiconv.mo if test "libiconv" = "gettext-tools"; then \ /usr/bin/mkdir -p /usr/local/libiconv/share/gettext/po; \ for file in Makefile.in.in remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot Makevars.template; do \ /usr/bin/install -c -m 644 ./$file \ /usr/local/libiconv/share/gettext/po/$file; \ done; \ for file in Makevars; do \ rm -f /usr/local/libiconv/share/gettext/po/$file; \ done; \ else \ : ; \ fi make[1]: Leaving directory `/usr/src/libiconv-1.15/po' cd man && make install prefix='/usr/local/libiconv' exec_prefix='/usr/local/libiconv' datarootdir='/usr/local/libiconv/share' datadir='/usr/local/libiconv/share' mandir='/usr/local/libiconv/share/man' make[1]: Entering directory `/usr/src/libiconv-1.15/man' ......此处省略...... builddir="`pwd`"; cd . && for f in *.html ; do (cd "$builddir"; echo /usr/bin/install -c -m 644 ./$f /usr/local/libiconv/share/doc//$f ; /usr/bin/install -c -m 644 ./$f /usr/local/libiconv/share/doc//$f) ; done /usr/bin/install -c -m 644 ./iconv.1.html /usr/local/libiconv/share/doc//iconv.1.html /usr/bin/install -c -m 644 ./iconv.3.html /usr/local/libiconv/share/doc//iconv.3.html /usr/bin/install -c -m 644 ./iconv_close.3.html /usr/local/libiconv/share/doc//iconv_close.3.html /usr/bin/install -c -m 644 ./iconvctl.3.html /usr/local/libiconv/share/doc//iconvctl.3.html /usr/bin/install -c -m 644 ./iconv_open.3.html /usr/local/libiconv/share/doc//iconv_open.3.html /usr/bin/install -c -m 644 ./iconv_open_into.3.html /usr/local/libiconv/share/doc//iconv_open_into.3.html make[1]: Leaving directory `/usr/src/libiconv-1.15/man'
4、解压PHP程序并进入目录编译安装
cd /usr/src/
tar -zxf php-5.6.36.tar.gz
cd php-5.6.36
./configure \
–prefix=/usr/local/php-5.6.36 \
–enable-fpm \
–with-fpm-user=www \
–with-fpm-group=www \
–with-mysql=/usr/local/mysql \
–with-mysqli=mysqlnd \
–with-pdo-mysql=mysqlnd \
–with-iconv-dir=/usr/local/libiconv \
–with-freetype-dir \
–with-jpeg-dir \
–with-png-dir \
–with-zlib \
–with-libxml-dir=/usr \
–enable-xml \
–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 \
–disable-fileinfo \
–enable-opcache \
–enable-intl \
–enable-short-tags \
–with-xsl
[root@localhost ~]# cd /usr/src/ [root@localhost src]# tar -zxf php-5.6.36.tar.gz [root@localhost src]# cd php-5.6.36 [root@localhost php-5.6.36]# ./configure \ > --prefix=/usr/local/php-5.6.36 \ > --enable-fpm \ > --with-fpm-user=www \ > --with-fpm-group=www \ > --with-mysql=/usr/local/mysql \ > --with-mysqli=mysqlnd \ > --with-pdo-mysql=mysqlnd \ > --with-iconv-dir=/usr/local/libiconv \ > --with-freetype-dir \ > --with-jpeg-dir \ > --with-png-dir \ > --with-zlib \ > --with-libxml-dir=/usr \ > --enable-xml \ > --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 \ > --disable-fileinfo \ > --enable-opcache \ > --enable-intl \ > --enable-short-tags \ > --with-xsl checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E ......此处省略...... checking whether to build shared libraries... yes checking whether to build static libraries... yes creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC checking if g++ PIC flag -fPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so (cached) (cached) checking how to hardcode library paths into programs... immediate Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands
5、开始编译及安装
[root@localhost php-5.6.36]# make && make install /bin/sh /usr/src/php-5.6.36/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/opcache/ -I/usr/src/php-5.6.36/ext/opcache/ -DPHP_ATOM_INC -I/usr/src/php-5.6.36/include -I/usr/src/php-5.6.36/main -I/usr/src/php-5.6.36 -I/usr/src/php-5.6.36/ext/date/lib -I/usr/src/php-5.6.36/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/src/php-5.6.36/ext/mbstring/oniguruma -I/usr/src/php-5.6.36/ext/mbstring/libmbfl -I/usr/src/php-5.6.36/ext/mbstring/libmbfl/mbfl -I/usr/local/mysql/include -I/usr/src/php-5.6.36/ext/sqlite3/libsqlite -I/usr/src/php-5.6.36/ext/zip/lib -I/usr/src/php-5.6.36/TSRM -I/usr/src/php-5.6.36/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /usr/src/php-5.6.36/ext/opcache/ZendAccelerator.c -o ext/opcache/ZendAccelerator.lo /usr/src/php-5.6.36/ext/opcache/ZendAccelerator.c: In function ‘accel_use_shm_interned_strings’: /usr/src/php-5.6.36/ext/opcache/ZendAccelerator.c:397:28: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] CG(interned_empty_string) = accel_new_interned_string("", sizeof(""), 0 TSRMLS_CC); ^ ......此处省略...... /bin/sh /usr/src/php-5.6.36/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/standard/ -I/usr/src/php-5.6.36/ext/standard/ -DPHP_ATOM_INC -I/usr/src/php-5.6.36/include -I/usr/src/php-5.6.36/main -I/usr/src/php-5.6.36 -I/usr/src/php-5.6.36/ext/date/lib -I/usr/src/php-5.6.36/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/src/php-5.6.36/ext/mbstring/oniguruma -I/usr/src/php-5.6.36/ext/mbstring/libmbfl -I/usr/src/php-5.6.36/ext/mbstring/libmbfl/mbfl -I/usr/local/mysql/include -I/usr/src/php-5.6.36/ext/sqlite3/libsqlite -I/usr/src/php-5.6.36/ext/zip/lib -I/usr/src/php-5.6.36/TSRM -I/usr/src/php-5.6.36/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /usr/src/php-5.6.36/ext/standard/scanf.c -o ext/standard/scanf.lo ......此处省略...... Zend/zend_virtual_cwd.lo Zend/zend_ast.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lz -lexslt -lresolv -lcrypt -lrt -lmysqlclient -lmcrypt -lstdc++ -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcurl -lxml2 -lz -lm -ldl -lssl -lcrypto -lfreetype -ldl -lm -licui18n -licuuc -licudata -ldl -lm -licuio -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxslt -lxml2 -lz -ldl -lm -lssl -lcrypto -lcrypt -o sapi/cgi/php-cgi Generating phar.php Generating phar.phar PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. clicommand.inc directorytreeiterator.inc invertedregexiterator.inc directorygraphiterator.inc pharcommand.inc phar.inc Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/local/php-5.6.36/lib/php/extensions/no-debug-non-zts-20131226/ Installing PHP CLI binary: /usr/local/php-5.6.36/bin/ Installing PHP CLI man page: /usr/local/php-5.6.36/php/man/man1/ Installing PHP FPM binary: /usr/local/php-5.6.36/sbin/ Installing PHP FPM config: /usr/local/php-5.6.36/etc/ Installing PHP FPM man page: /usr/local/php-5.6.36/php/man/man8/ Installing PHP FPM status page: /usr/local/php-5.6.36/php/php/fpm/ Installing PHP CGI binary: /usr/local/php-5.6.36/bin/ Installing PHP CGI man page: /usr/local/php-5.6.36/php/man/man1/ Installing build environment: /usr/local/php-5.6.36/lib/php/build/ Installing header files: /usr/local/php-5.6.36/include/php/ Installing helper programs: /usr/local/php-5.6.36/bin/ program: phpize program: php-config Installing man pages: /usr/local/php-5.6.36/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php-5.6.36/lib/php/ [PEAR] Archive_Tar - installed: 1.4.3 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.4.2 [PEAR] PEAR - installed: 1.10.5 Wrote PEAR system config file at: /usr/local/php-5.6.36/etc/pear.conf You may want to add: /usr/local/php-5.6.36/lib/php to your php.ini include_path /usr/src/php-5.6.36/build/shtool install -c ext/phar/phar.phar /usr/local/php-5.6.36/bin ln -s -f phar.phar /usr/local/php-5.6.36/bin/phar Installing PDO headers: /usr/local/php-5.6.36/include/php/ext/pdo/
6、创建软链接
[root@localhost php-5.6.36]# ln -s /usr/local/php-5.6.36/ /usr/local/php
7、拷贝并改名PHP配置文件
[root@localhost php-5.6.36]# cp /usr/src/php-5.6.36/php.ini-production /usr/local/php/lib/php.ini
8、拷贝并改名PHP-FPM配置文件
[root@localhost php-5.6.36]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
9、编辑PHP-FPM配置文件(vim /usr/local/php/etc/php-fpm.conf)
把以下这段
;pid = run/php-fpm.pid
去掉注释并保存
pid = run/php-fpm.pid
10、拷贝PHP-FPM服务文件至启动目录并添加执行权限
[root@localhost php-5.6.36]# cp /usr/src/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm && chmod +x /etc/rc.d/init.d/php-fpm
11、将PHP-FPM服务配置开机启动并检查
[root@localhost php-5.6.36]# chkconfig php-fpm on [root@localhost php-5.6.36]# chkconfig --list php-fpm Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
12、启动PHP-FPM服务并验证
[root@localhost ~]# systemctl start php-fpm.service
[root@localhost ~]# systemctl status php-fpm.service && ss -lnat ● php-fpm.service - LSB: starts php-fpm Loaded: loaded (/etc/rc.d/init.d/php-fpm; bad; vendor preset: disabled) Active: active (running) since Wed 2018-05-09 15:45:44 CST; 12min ago Docs: man:systemd-sysv-generator(8) Process: 1328 ExecStop=/etc/rc.d/init.d/php-fpm stop (code=exited, status=0/SUCCESS) Process: 1343 ExecStart=/etc/rc.d/init.d/php-fpm start (code=exited, status=0/SUCCESS) CGroup: /system.slice/php-fpm.service ├─1345 php-fpm: master process (/usr/local/php-5.6.36/etc/php-fpm.conf) ├─1346 php-fpm: pool www └─1347 php-fpm: pool www May 09 15:45:44 localhost.localdomain systemd[1]: Starting LSB: starts php-fpm... May 09 15:45:44 localhost.localdomain php-fpm[1343]: Starting php-fpm done May 09 15:45:44 localhost.localdomain systemd[1]: Started LSB: starts php-fpm. State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:9000 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 *:22 *:* ESTAB 0 0 172.16.0.209:22 172.16.4.143:58911 LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::22 :::*
13、PHP和Nginx整合:编辑Nginx主配置文件(/usr/local/nginx/conf/nginx.conf)
把下面这段代码
#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; #}
去掉注释并修改为
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
14、检查Nginx配置文件是否有误并重载Nginx配置文件
[root@localhost conf]# /usr/local/nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx-1.12.2/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx-1.12.2/conf/nginx.conf test is successful [root@localhost conf]# /usr/local/nginx/sbin/nginx -s reload
systemctl status php-fpm.service #查看PHP-FPM运行状态
systemctl start php-fpm.service #启动PHP-FPM服务
systemctl stop php-fpm.service #停止PHP-FPM服务
systemctl restart php-fpm.service #重启PHP-FPM服务