centos中如何用yum安装lnmp环境php7.3

发布时间:2021-12-14 23:17:13 阅读:1219次

最早用lnmp环境需要自己一步步的编译安装,非常麻烦

后来用lnmp.org和宝塔方便了不少

可是用一键安装用来测试环境尚可,如果是生产环境不太好

有没有yum来安装lnmp环境呢,方法是有的

1、首先安装 EPEL 源:

yum install epel-release

安装 REMI 源:

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

2、安装 Yum 源管理工具:

yum install yum-utils

3、安装 PHP7.3:

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-xml

安装完成后最好重启一下计算机,不然有可能无法启动php

设置开机启动、运行服务:

systemctl enable php73-php-fpm
systemctl start php73-php-fpm

查找php.ini位置:

[root@xxx etc]# find /etc/opt/remi/php73 -name php.ini
/etc/opt/remi/php73/php.ini

编辑/etc/opt/remi/php73/php.ini替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令:

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/opt/remi/php73/php.ini

重启php73-php-fpm

systemctl restart php73-php-fpm

更多操作:

systemctl restart php73-php-fpm #重启
systemctl start php73-php-fpm #启动
systemctl stop php73-php-fpm #关闭
systemctl status php73-php-fpm #检查状态

查看 PHP
验证一下是否安装成功:

root@mf88.biz-service:~# php73 -v
PHP 7.3.0-1+(cli) (built: Dec 6 2018 20:24:55) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

更新 PHP
运行下面的命令系统就会更新所有可以更新的软件包括 PHP

yum update

安装更多组件
上面的一条命令安装 PHP 只是安装了部分 PHP 拓展,更多的软件可见:

yum search php73

安装redis

yum install php73-php-pecl-redis

以下为nginx配置文件

[root@iZuf66r5u8vbc5ezpd0w8yZ conf.d]# cat www.conf
server {
listen 80;
server_name www.test.com;
root  /var/www/html/www.test.com;
index index.php index.html;
if (!-e $request_filename) {
       rewrite  ^(.*)$  /index.php?s=/$1  last;
}
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

}

修改/etc/opt/remi/php73/php-fpm.d/www.conf

user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

安装mysql

rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-server mysql-devel mysql

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:centos中如何用yum安装lnmp环境php7.3 出自老鄢博客 | 欢迎分享