環境 php
PHP安裝前準備 先將須要的軟件包以下位置放置。另外須要有WWW用戶 參照nginxmysql
知足以上條件後執行安裝腳本nginx
PHP安裝腳本:web
1 #!/bin/bash 2 #install PHP 3 #author Nod 4 #進入軟件包目錄 5 cd /server/tools/ 6 #解壓 7 tar xf php-5.5.32.tar.gz 8 #安裝對應的依賴包 9 yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y 10 #安裝lib 11 cd /server/tools 12 tar zxf libiconv-1.14.tar.gz 13 cd libiconv-1.14 14 #編譯環境 15 ./configure --prefix=/usr/local/libiconv 16 make && make install 17 yum -y install libmcrypt-devel mhash mcrypt 18 #開始安裝php 19 cd /server/tools/ 20 tar xf php-5.5.32.tar.gz 21 ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/ 22 cd /server/tools/php-5.5.32 23 touch /server/tools/php-5.5.32/ext/phar/phar.phar 24 #編譯環境 25 ./configure \ 26 --prefix=/application/php-5.5.32 \ 27 --with-mysql=/application/mysql/ \ 28 --with-pdo-mysql=mysqlnd \ 29 --with-iconv-dir=/usr/local/libiconv \ 30 --with-freetype-dir \ 31 --with-jpeg-dir \ 32 --with-png-dir \ 33 --with-zlib \ 34 --with-libxml-dir=/usr \ 35 --enable-xml \ 36 --disable-rpath \ 37 --enable-bcmath \ 38 --enable-shmop \ 39 --enable-sysvsem \ 40 --enable-inline-optimization \ 41 --with-curl \ 42 --enable-mbregex \ 43 --enable-fpm \ 44 --enable-mbstring \ 45 --with-mcrypt \ 46 --with-gd \ 47 --enable-gd-native-ttf \ 48 --with-openssl \ 49 --with-mhash \ 50 --enable-pcntl \ 51 --enable-sockets \ 52 --with-xmlrpc \ 53 --enable-soap \ 54 --enable-short-tags \ 55 --enable-static \ 56 --with-xsl \ 57 --with-fpm-user=www \ 58 --with-fpm-group=www \ 59 --enable-ftp \ 60 --enable-opcache=no 61 #安裝 62 make && make install 63 64 #配置文件處理 65 ln -s /application/php-5.5.32/ /application/php 66 cp /server/tools/php-5.5.32/php.ini-production /application/php/lib/php.ini 67 cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf 68 69 #啓動服務 70 /application/php/sbin/php-fpm
安裝完成後 PHP默認佔用的端口爲9000sql
[root@web02 scripts]# netstat -lntup | grep php
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1500/php-fpm bash