(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php

Posted 51QGS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php相关的知识,希望对你有一定的参考价值。

原文地址:​​https://bbs.huaweicloud.com/blogs/332734​

#关闭防火墙和 selinux 并重启
sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config
systemctl disable --now firewalld

#openEuler需要配源
vim /etc/yum.repos.d/openEuler.repo

[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler

[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-21.03/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/everything/$basearch/RPM-GPG-KEY-openEuler

[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-21.03/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler

[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-21.03/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/debuginfo/$basearch/RPM-GPG-KEY-openEuler

[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-21.03/source/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/source/RPM-GPG-KEY-openEuler

[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-21.03/update/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_nginx

安装php

#安装PHP 
#centos7
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum list php
yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
#openEuler
yum list php
yum -y install php
#查看版本
php -v
#查看启动模块
php --modules
#查看安装路径
whereis php

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_linux_02

#启动,自启,查看运行状态
service php-fpm start
service php-fpm enable
service php-fpm status

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_nginx_03

安装nginx

yum安装nginx,并处理端口占用报错:参考链接https://bbs.huaweicloud.com/blogs/278868

#centos7安装
yum -y install net-tools
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx

#openEuler
yum -y install net-tools
yum install -y nginx

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_nginx_04

#启动,重启,开机自启nginx,运行状态
systemctl start nginx
systemctl restart nginx
systemctl enable nginx
systemctl status nginx
#查看当前所有tcp端口
netstat -ntlp
#浏览器访问ip

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_php_05

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_php_06

#配置nginx解析php
vim /etc/nginx/conf.d/default.conf
nginx -t
systemctl restart nginx

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_nginx_07

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_nginx_08

#测试页面
vim /usr/share/nginx/html/index.php

<?php
phpinfo();
?>

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php_php_09


以上是关于(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析php的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统之openEuler安装部署

Linux系统之openEuler安装部署

漫画:什么是openEuler社区?

当OpenHarmony遇上OpenEuler

openeuleros_华为欧拉操作系统openEuler与CentOS

黑猴子的家:华为 OpenEuler(欧拉) Linux 之基本配置 - openEuler-20.03-LTS