(openEuler21.03-x86)yum安装php+apache—shell脚本

举报
QGS 发表于 2022/02/22 11:57:12 2022/02/22
【摘要】 (openEuler21.03-x86)yum安装php+apache—shell脚本

#!/bin/sh
echo "#######################################################################"
echo "#                                                                                #"
echo "#                  正在配置openEuler21.03源 请稍后——           #"
echo "#                                                                                #"
echo "#######################################################################"

cat >> /etc/yum.repos.d/openEuler.repo<<EOF
[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=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler
EOF
#更新源

yum makecache

cho "#######################################################################"
echo "#                                                                     #"
echo "#                  正在关闭SElinux策略,防火墙 请稍等~                     #"
echo "#                                                                     #"
echo "#######################################################################"
#永久关闭SElinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld

echo "#######################################################################"
echo "#                  正在安装apache-----                                  #"
echo "#                                   请稍后-----                        #"
echo "#                                                                     #"
echo "#######################################################################"
yum install httpd -y
systemctl restart httpd
systemctl enable httpd
echo " httpd配置文件     : /etc/httpd/conf/httpd.conf  /var/www/html"

echo "#######################################################################"
echo "#                  正在安装php8.0-----                                  #"
echo "#                                   请稍后-----                        #"
echo "#                                                                     #"
echo "#######################################################################"
yum list php
yum -y install php
#查看版本
php -v
#查看启动模块
php --modules
#查看安装路径
whereis php
#启动,自启,查看运行状态
service php-fpm start
service php-fpm enable
echo "#######      正在配置Apache解析PHP请稍后    ###########################321"
#配置路径/etc/httpd/conf.d/php-fpm.conf
cat >> /etc/httpd/conf.d/php-fpm.conf<<EOF
<FilesMatch \.php$>
         SetHandler "proxy:fcgi://127.0.0.1:9000"
 </FilesMatch>
EOF

#Apache网页目录下编写简单的php网页,验证访问Apache的php网页
echo "配置路径/var/www/html/index.php"
cat >> /var/www/html/index.php<<EOF
<?php
phpinfo();
?>
EOF
service php-fpm restart
systemctl restart httpd
echo "浏览器访问IP/index.php"

【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。