#关闭防火墙和 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_centos_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_运维_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_运维_05

(openEuler21.03-Centos7-x86)yum安装php+nginx—配置nginx解析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_centos_07

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

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

<?php
phpinfo();
?>

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