centos yum装置php7的办法:起首将yum仓库包晋级改换成PHP7的rpm包;而后应用yum饬令装置根本PHP组件;接着装置“PHP-fpm”并启动“php-fpm”;最初查看版本以检测能否装置胜利。
1、装置预备
应用如下饬令将yum仓库包晋级改换成PHP7的rpm包
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、开端装置
1.先应用yum饬令装置根本PHP组件,当前要用到啥再装置啥
yum -y install php70w.x86_64 php70w-cli.x86_64 php70w-co妹妹on.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
2.再装置PHP-fpm(过程治理器,提供PHP过程治理形式,能够无效管制内存以及过程、滑润圆滑重载PHP设置装备摆设)
yum -y install php70w-fpm php70w-opcache
3.装置完之后启动php-fpm
systemctl start php-fpm
4.查看版本以检测能否装置胜利
php -v
3、检测PHP能否能与Nginx互通
1.正在Nginx的默许HTML文件夹里(/usr/local/webserver/nginx/html/)新建一个index.php,内容以下:
<?php phpinfo();?>
2.修正Nginx的设置装备摆设文件(可以使用find /|grep nginx.conf搜寻设置装备摆设文件地位)Nginx.conf,修正新增以下:
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # 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; }
要将原属性修正成蓝色字体局部,否则拜访index.php会呈现如下状况(php-fpm找没有到原SCRIPT_FILENAME里执行的php文件)
3.重启Nginx
/usr/local/webserver/nginx/sbin/nginx -s reload
4.拜访域名(IP)/index.php呈现如下内容即为设置装备摆设胜利
4、检测PHP能否能与mysql互通
将上一份index.PHP内容修正以下
<?php // 创立衔接 $test = mysqli_connect('localhost','root','qq1234');//数据库效劳器地点,账号名,明码 // 检测 if (!$test) echo "衔接失败,请反省mysql效劳和账户明码"; echo "数据库衔接胜利!"; ?>
修正完之后间接拜访index.php,无需重启Nginx
以上就是centos yum装置php7的办法详解的具体内容,更多请存眷资源魔其它相干文章!
标签: Centos PHP7 php7开发教程 php7开发资料 php7开发自学 yum
抱歉,评论功能暂时关闭!