Linux下PHP下载安装

一.   安装
1.    yum 安装
yum install php –y
 
2.    源码安装
1)   在官方网站(php.net)上下载php到本地。
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
2)   解压缩
tar –xf php-5.6.30
3)   进入目录
cd php-5.6.30
4)   创建文件夹
mkdir /usr/local/php
5)   安装依赖
yum install libxml2-devel –y
全部包如下:
yum -y install openssl
yum -y install openssl-devel
yum -y install curl
yum -y install curl-devel
yum -y install libjpeg
yum -y install libjpeg-devel
yum -y install libpng
yum -y install libpng-devel
yum -y install freetype
yum -y install freetype-devel
yum -y install pcre
yum -y install pcre-devel
yum -y install libxslt
yum -y install libxslt-devel
yum -y install bzip2
yum -y install bzip2-devel 
 
6)   安装
./configure --prefix=/usr/local/php  --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64 --without-pear  --disable-phar
注:如果要连接mysql,需要加上 --with-mysql=/usr/local/mysql
如果想后装mysql,需要加上 --with-mysql=mysqlnd
如果连接nginx,最好加上 --with-fpm-user=www  --with-fpm-group=www
               全部如下:
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-curl --with-freetype-dir --with-gd --with-gettext--with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip
注:32位系统要去掉--with-libdir=lib64。
make && make install
7)   拷贝服务脚本到init.d目录
cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
8)   添加执行权限
chmod +x /etc/init.d/php-fpm
9)   拷贝配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp xxw/tools/php-5.6.30/php.ini-production /usr/local/php/etc/php.ini     #前面为你下载解压后的目录
二.  PHP配置
php的配置文件为 php.ini
如果前面配置的时候没有加用户和组,这里可以直接打开/usr/local/php/etc/php-fpm.conf
将里面的user = nobody,改为和nginx一样的用户和组。

猜你喜欢

转载自blog.csdn.net/freshair_x/article/details/80376425