標籤:php5.6.30 linux 安裝 配置
在第一次編譯安裝php5.6.30失敗後,參考了http://www.phpworld.cn/system/php/11.html的一些內容,第二次編譯安裝成功,特此記錄過程。
一、編譯安裝php5.6.30
安裝環境:
# cat /etc/redhat-release CentOS release 6.8 (Final)
# /application/nginx/sbin/nginx -vnginx version: nginx/1.6.3
下載php5.6.30安裝包
wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
解壓
tar -xjf php-5.6.30.tar.bz2
安裝所需依賴包
# rpm -qa zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel# yum install zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y
安裝libiconv庫
wget tar zxf libiconv-1.14.tar.gz cd libiconv-1.14./configure --prefix=/usr/local/libiconvmakemake install
開始安裝 php
[[email protected] php-5.6.30]#./configure --prefix=/application/php5.6.30 --with-mysql=mysqlnd --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 --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --without-pear --disable-phar#因為本機沒有pear包,所以選擇暫時跳過(--without-pear --disable-phar),等php安裝後再補裝go-pear
650) this.width=650;" src="https://s1.51cto.com/wyfs02/M01/8E/F1/wKiom1jPe6XTvL_PAAC_OlMXg4o910.jpg-wh_500x0-wm_3-wmp_4-s_1986251777.jpg" title="編譯成功" alt="wKiom1jPe6XTvL_PAAC_OlMXg4o910.jpg-wh_50" />
make 編譯
[[email protected] php-5.6.30]# make.........Build complete.Don‘t forget to run ‘make test‘.[[email protected] php-5.6.30]# make test
make test的結果報了一些問題,我沒有理會,繼續安裝了
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/8E/F0/wKioL1jPgDSyelcaAABZGVxzbBM744.jpg" title="2.jpg" alt="wKioL1jPgDSyelcaAABZGVxzbBM744.jpg" />
執行make install
[[email protected] php-5.6.30]# make installInstalling shared extensions: /application/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/Installing PHP CLI binary: /application/php5.6.30/bin/Installing PHP CLI man page: /application/php5.6.30/php/man/man1/Installing PHP FPM binary: /application/php5.6.30/sbin/Installing PHP FPM config: /application/php5.6.30/etc/Installing PHP FPM man page: /application/php5.6.30/php/man/man8/Installing PHP FPM status page: /application/php5.6.30/php/php/fpm/Installing PHP CGI binary: /application/php5.6.30/bin/Installing PHP CGI man page: /application/php5.6.30/php/man/man1/Installing build environment: /application/php5.6.30/lib/php/build/Installing header files: /application/php5.6.30/include/php/Installing helper programs: /application/php5.6.30/bin/ program: phpize program: php-configInstalling man pages: /application/php5.6.30/php/man/man1/ page: phpize.1 page: php-config.1Installing PDO headers: /application/php5.6.30/include/php/ext/pdo/
二、配置php
cp php.ini-production /usr/local/php/etc/php.ini #複製php設定檔到安裝目錄rm -rf /etc/php.ini #刪除系統內建設定檔
ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加軟連結到 /etc目錄
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷貝模板檔案為php-fpm設定檔
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加軟串連到 /etc目錄
修改php-fpm.conf
pid = run/php-fpm.pid #取消前面的分號
修改php-ini.conf
找到:disable_functions=
修改為:
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函數,如果某些程式需要用到這個函數,可以刪除,取消禁用。
找到:;date.timezone =
修改為:
date.timezone = PRC #設定時區
找到:expose_php = On
修改為:
expose_php = Off #禁止顯示php版本的資訊
找到:short_open_tag = Off
修改為:
short_open_tag = ON #支援php短標籤
注意:short_open_tag 必須開啟.開啟以後可以使用PHP的段標籤:()。同時,只有開啟這個才可以使用 <?= 以代替 <? echo 。有一些開源系統裡會使用短標籤,如果不開啟的話會報錯。
找到opcache.enable=0
修改為
opcache.enable=1 #php支援opcode緩衝
找到:;opcache.enable_cli=1 #php支援opcode緩衝
修改為:
opcache.enable_cli=0
在最後一行添加:
zend_extension=opcache.so #開啟opcode緩衝功能
:wq #儲存退出
配置nginx.conf
location ~ \.php$ { root html/bbs; #你網頁根目錄 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}
建立測試檔案:
[[email protected] bbs]# cat index.php <?php phpinfo(); ?>[[email protected] bbs]# cat index.html bbs.html[[email protected] bbs]# pwd/application/nginx/html/bbs
啟動php-fpm,重啟nginx,並測試結果
/application/php/sbin/php-fpm -c /application/php/etc/php.ini -y /application/php/etc/php-fpm.conf
/application/nginx/sbin/nginx -s reload
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M01/8E/F2/wKiom1jPigzxmni4AAD17TewVcs871.jpg" style="float:none;" title="3.jpg" alt="wKiom1jPigzxmni4AAD17TewVcs871.jpg" />
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/8E/F2/wKiom1jPig2D_LsFAAApJKIWHn4034.jpg" style="float:none;" title="4.jpg" alt="wKiom1jPig2D_LsFAAApJKIWHn4034.jpg" />
linux下編譯安裝配置php5.6.30過程