centos7.5(CentOS-7-x86_64-Minimal-1804)编译安装php7.1两种方法
程序员文章站
2022-03-12 10:21:12
...
方法一、简单安装(通过yum)
1.安装epel-release
1 |
rpm -ivh http: //dl .fedoraproject.org /pub/epel/7/x86_64/e/epel-release-7-5 .noarch.rpm
|
2.安装PHP7的rpm源
1 |
rpm -Uvh https: //mirror .webtatic.com /yum/el7/webtatic-release .rpm
|
3.安装PHP7
1 |
yum install php70w
|
方法二、编译安装
安装依赖:
yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel
mcrypt mhash
下载及解压php7.1:
wget http://cn2.php.net/distributions/php-7.1.0.tar.gz
tar zxvf php-7.1.0.tar.gz
cd php-7.1.0
配置及安装php7.1:
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-redis \
--enable-fpm \
--enable-fastcgi \
--with-fpm-user=www \
--with-fpm-group=www \
--without-gdbm \
--disable-fileinfo
make && make install
拷贝配置文件:
cp /usr/local/php-7.1.0/php.ini-production /usr/local/php7/etc/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
cp /usr/local/php-7.1.0/sapi/fpm/php-fpm.service /lib/systemd/system/php-fpm.service
编辑 php-rpm.conf,将 pid = run/php-fpm.pid 开启
创建php相关目录及给予权限:
mkdir -p /var/log/php/
mkdir -p /var/log/php-fpm/
mkdir -p /run/php-fpm/
mkdir -p /var/lib/php/session
touch /dev/shm/php-fpm.sock
chown www.www /dev/shm/php-fpm.sock
chmod 777 /dev/shm/php-fpm.sock
chown -R www:www /var/lib/php