广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买
LiNUX安装PHP7.X PHP版本:7.2.12 下载地址:http://cn2.php.net/get/php-7.2.12.tar.bz2/from/this/mirror
推荐(免费):PHP7
安装前准备,避免在安装PHP依赖包时报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt. 添加 epel 源centos 7.x
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm登录后复制
此处我将PHP 下载到 /usr/local 下,进入此目录下
tar -zxvf php7.2.12tar.gz登录后复制
进入目录
cd php-7.2.12登录后复制
安装PHP依赖包
yum install gcc libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel登录后复制
如果依赖包安装好,就将以下整段复制编译,PHP目录到 /usr/local/php;
./configure \--prefix=/usr/local/php \--with-config-file-path=/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache登录后复制
编译并安装:
make && make install登录后复制
编译完成之后,我们添加PHP命令到环境变量里
vim /etc/profile登录后复制
在文件末尾加入:
PATH=$PATH:/usr/local/php/binexport PATH登录后复制
要使改动立即生效执行
source /etc/profile登录后复制
查看PHP 版本
php -v登录后复制
这时候,nginx还是不支持php的,它需要php-fpm来处理两者的依赖关系,所以我们要胚子php-fpm
tar -zxvf php7.2.12tar.gz0登录后复制
启动php-fpm
tar -zxvf php7.2.12tar.gz1登录后复制
nginx和php-fpm整合 编辑/usr/local/nginx/nginx.conf
修改如下: 红框中 “#”号去掉 添加红框中内容 修改内容,如下(找到如下开头内容)
这里我将配置文件换到我自定义的文件中去,不做以上修改; 只在文件末尾加入
tar -zxvf php7.2.12tar.gz2登录后复制
创建文件夹,并创建编辑 app.conf 文件
tar -zxvf php7.2.12tar.gz3登录后复制
编辑内容:
tar -zxvf php7.2.12tar.gz4登录后复制
更多相关免费学习推荐:PHP7教程
以上就是详解LiNUX安装PHP7.X的详细内容,更多请关注9543建站博客其它相关文章!
发表评论