👋 欢迎来到吴老二技术博客,专注运维 / 数据库 / 云原生
首页/运维服务/正文

Centos7安装php

吴
吴老二
2021-01-09运维服务1988 次浏览0 条评论

yum源安装

有很多开源的项目都是使用的php语言编写的,不过在使用的时候必须安装php基础环境,这里记录一下php的安装方法,在没有安装之前首先更新一样EPLE源。
[root@wulaoer ~]# yum install epel-release
[root@wulaoer ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm 
[root@wulaoer ~]# yum install yum-utils
utils是yum源的管理工具,下面安装php7.3版本的
[root@wulaoer ~]# yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
根据网络安装时间不等,安装完成后启动一下php
[root@wulaoer ~]# systemctl enable php73-php-fpm
[root@wulaoer ~]# systemctl start php73-php-fpm
安装完成,看一下php的进程
[root@wulaoer ~]# ps -ef | grep php
root      1028     1  0 13:48 ?        00:00:00 php-fpm: master process (/etc/opt/remi/php73/php-fpm.conf)
apache    1155  1028  0 13:48 ?        00:00:00 php-fpm: pool www
apache    1156  1028  0 13:48 ?        00:00:00 php-fpm: pool www
apache    1157  1028  0 13:48 ?        00:00:00 php-fpm: pool www
apache    1160  1028  0 13:48 ?        00:00:00 php-fpm: pool www
apache    1161  1028  0 13:48 ?        00:00:00 php-fpm: pool www
root      1565  1540  0 13:58 pts/0    00:00:00 grep --color=auto php
php安装完成,看源码安装方法。

源码安装

首先安装依赖包,并下载php文件,根据自己的需求选择不同的版本
[root@wulaoer ~]# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel
[root@wulaoer ~]# yum -y install curl-devel
[root@wulaoer ~]# yum -y install libxslt-devel
[root@wulaoer ~]# yum install openssl openssl-devel
[root@wulaoer ~]# wget http://at1.php.net/distributions/php-7.0.2.tar.gz
解压进入文件进行安装到指定文件路径下
[root@wulaoer ~]# ./configure --prefix=/usr/local/php  --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-xmlrpc  --with-xsl  --with-zlib  --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-xml  --enable-zip
编译php文件
[root@wulaoer ~]# make &&  make install
配置php文件,并设置启动
[root@wulaoer ~]# cp php.ini-development /usr/local/php/lib/php.ini
[root@wulaoer ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@wulaoer ~]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@wulaoer ~]# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
启动php文件
[root@wulaoer ~]# /etc/init.d/php-fpm
安装后我们使用nginx做一下测试,可以参考:https://www.wulaoer.org/?p=1452
文章底部广告位在后台「广告设置」填写广告代码后显示

评论 0

评论需 登录 后发表(注册并验证邮箱)。
还没有评论,来抢沙发~