PHP 7.2.10 编译安装

准备环境

1.CentOS 系统

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

2.防火墙

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# cat /etc/sysconfig/selinux
SELINUX=disabled
[[email protected] ~]# setenforce 0
[[email protected] ~]# getenforce 0
Permissive

3.YUM,EPEl源
本地YUM源可以,或者选择其他外部源

[[email protected] ~]# yum -y install epel-release

4.php依赖包

[[email protected] ~]# yum -y install gcc gcc-c++ libmcrypt-devel mcrypt mhash gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel openssl-deve python-devel zlib-devel freetype libxslt* bison autoconf re2c

5.php安装包

[[email protected] ~]# wget http://cn2.php.net/distributions/php-7.2.10.tar.gz
[[email protected] ~]# tar xvf php-7.2.10.tar.gz
[[email protected] ~]# cd php-7.2.10/
[[email protected] php-7.2.10]# ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mhash --with-openssl --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-pcntl --enable-calendar --enable-exif --enable-sockets --with-xmlrpc --with-libxml-dir --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-bz2 --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo
[[email protected] php-7.2.10]# make
······
Build complete.
Don‘t forget to run ‘make test‘.
[[email protected] php-7.2.10]# make install
······
/root/php-7.2.10/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
[[email protected] php-7.2.10]# /usr/local/php/bin/php -v  //版本验证
PHP 7.2.10 (cli) (built: Oct  9 2018 09:59:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

6.编译PHP的选项说明

7.PHP安装后的配置
php.ini文件

[[email protected] php-7.2.10]# useradd nginx
[[email protected] php-7.2.10]#  cp -a php.ini-production /usr/local/php/etc/php.ini
[[email protected] php-7.2.10]#  cp -a php.ini-production /usr/local/php/etc/php.ini
[[email protected] php-7.2.10]#  vim /usr/local/php/etc/php.ini
date.timezone = Asia/shanghai    #指定时区为上海
expose_php = Off      #禁止显示PHP版本
short_open_tag = ON   #支持PHP短标签
opcache.enable=1      #PHP支持opcode缓存
opcache.enable_cli=0
zend_extension=opcache.so     #在最后一行添加,开启opcode缓存功能

8.配置php-fpm和www.conf

[[email protected] php-7.2.10]#  cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] php-7.2.10]#  cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[[email protected] php-7.2.10]#  cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-7.2.10]#  chmod +x /etc/rc.d/init.d/php-fpm
[[email protected] php-7.2.10]#  chkconfig --add php-fpm

9.环境变量

[[email protected] php-7.2.10]#  cat /etc/profile
PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/
[[email protected] php-7.2.10]# source /etc/profile

10.启动 php-fpm

[[email protected] php-7.2.10]# systemctl start php-fpm
[[email protected] php-7.2.10]#  ss -ant|grep 9000
LISTEN     0      128    127.0.0.1:9000                     *:*   

11.创建测试页

[[email protected] php-7.2.10]# yum -y install nginx
[[email protected] ~]# vim /etc/nginx/nginx.conf
#把下面一段插入到server标签内
location ~ \.php$ {
            root           html;
            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] ~]#  vim /usr/share/nginx/html/index.php
#创建php测试网页
<?php
phpinfo();
?>
[[email protected] ~]# systemctl start nginx

12.测试

原文地址:http://blog.51cto.com/13767724/2296152

时间: 2024-10-16 11:48:07

PHP 7.2.10 编译安装的相关文章

ubuntu 13.10 编译安装conkeror

conkeror几年前我用过,还是一个不错的浏览器,这次因为笔记本只支持Ubuntu 13.10, 而不支持更新版本,就尝试着在Ubuntu 13.10上安装最新conkeror,但是没想到居然没有安装源.于是就编译吧, 当然还是要首先clone到源代码: git clone git://repo.or.cz/conkeror.git 然后根据官方文档的提示: To build your own Conkeror package, install fakeroot, quilt, and deb

Apache httpd-2.4.10编译安装

系统: CentOS6.5_64 软件: httpd-2.4.10.tar.bz2 依赖: openssl-1.0.1j.tar.gz.apr-1.5.1.tar.bz2.apr-util-1.5.4.tar.bz2.pcre-devel 下载地址: http://www.openssl.org/source/            openssl 下载地址: http://httpd.apache.org/download.cgi      httpd 下载地下: http://apr.apa

PostgreSQL 10编译安装(CentOS 7)

文档版本:v1.0 环境说明: PostgreSQL 10.9 CentOS 7.6 1 安装必要软件 # yum groupinstall -y "Development tools" # yum install -y bison flex readline-devel zlib-devel gcc 2 获取Postgres资源并编译安装 可通过访问https://www.postgresql.org/ftp/source/确定所需版本,以下使用10.9版本进行安装. # pwd /

ubuntu 14.10 编译安装 Python

从源代码直接编译安装Python2.7 $ wget -c https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz $ tar -xzvf Python-2.7.9.tgz $ cd Python-2.7.9/ $ LDFLAGS="-L/usr/lib/x86_64-linux-gnu" ./configure $ make $ sudo make install 其中, 上面的wget -c (url)是下载命令,参数-c表

ubuntu 14.10 编译安装 Ruby

源码编译安装ruby-2.2 1.获取源码包: wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz 2.安装依赖包 sudo apt-get install -y build-essential openssl curl libcurl3-dev libreadline6 libreadline6-dev git zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev li

Nginx1.10编译安装

企业实战千万PV的Nginx就得这么安装 更多文章请访问 乌龟运维 wuguiyunwei.com 已经上线六个个多月 现在非常稳定 这是现在的整理 Nginx 下载 wget http://nginx.org/download/nginx-1.10.3.tar.gz Openssl 下载 Wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz Pcre 下载 wget ftp://ftp.csx.cam.ac.uk/pub/softw

Nginx 1.10编译安装

Nginx安装很简单,如下: # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo # mkdir /software # cd /software/ # wget http://nginx.org/download/nginx-1.10.3.tar.gz # tar zxvf nginx-1.10.3.tar.gz # cd nginx-1.10.3 # mkdir /u

ubuntu 14.10 编译安装 Golang

以ubuntu wiki的 安装教程 为例: 安装gcc工具,因为golang有些功能是使用c写的,所以构建golang的编译是必须的 $ sudo apt-get install bison gawk gcc libc6-dev make 安装mercurial工具,目的使用hg命令来提取golang的源代码 $ sudo apt-get install mercurial 代取提取,如果您的网速比较慢的话,此步要多花点时间 $ hg clone -r release https://go.g

linux centos 6.10 编译安装mysql5.6.40版本,数据库主从

主机1 MYSQL配置: /etc/my.cnf : server_id = 41 log_bin=mysql-binbinlog-do-db =dbb1000log_bin_trust_function_creators=TRUEbinlog-ignore-db=mysqlbinlog-ignore-db=information_schemabinlog-ignore-db=performance_schemabinlog-ignore-db=test 给从库添加复制用户: grant rep