Linux 安裝php 5.4 – yii2 環境

對於線上環境,通常使用linux,這裏講述如何在linux下面安裝php 5.4php

1.yum 安裝基礎
yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gzip make bzip2bzip2-devel pcre-devel wget ncurses-devel cmake make perlmysql

yum -y install gcc automake autoconf libtool make gcc-c++ glibc libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel lib
2.安裝libmcryptlinux

libmcrypt下載地址:http://download.csdn.net/detail/terry_water/6974153c++

固然,您能夠本身去官網下載sql

安裝:libmcrypt
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install
下載完成後,按照上面的步驟安裝完libmcrypt,就能夠安裝php了vim

3.安裝phpapi

wget http://cn2.php.net/distributions/php-5.4.34.tar.gz
tar zvxf php-5.4.34.tar.gz
cd php-5.4.34
./configure --prefix=/usr/local/php --disable-fileinfo --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/libmcrypt --enable-zip --with-mysql=/usr/local/mysql --without-pear --enable-bcmath
make
make install
若是上面的下載地址不能下載,自行 去官網下載curl

複製php.ini到配置路徑,上面咱們配置的是/etc路徑ide

cp php.ini-development /etc/php.ini
4.設置用戶 php-fpmphp-fpm

cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vi etc/php-fpm.conf
搜索nobody ,修改爲以下

user = www-data
group = www-data
添加www-data用戶:

groupadd www-data
useradd -g www-data www-data
5.配置php-fpm

cp -f /tools/php-5.4.34/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
6.設置啓動,開機啓動

chmod 755 /etc/init.d/php-fpm
/etc/init.d/php-fpm start
/sbin/chkconfig --add php-fpm (添加到開機服務列表)
/sbin/chkconfig php-fpm on
php-fpm的啓動、中止和重啓:

/etc/init.d/php-fpm start
/etc/init.d/php-fpm stop
/etc/init.d/php-fpm reload
7.到此php的安裝就完成了,固然,後續須要安裝一些php的擴展。

執行

which php
,查看你的環境中是否已經有php,有的話刪除掉,直到找不到php。

而後把當前安裝的php設置爲php命令:

ln -s /usr/local/php/bin/php /usr/bin/php這樣命令行裏面的 php -m ,執行的就是 /usr/local/php/bin/php

相關文章
相關標籤/搜索