[英]Apache 403 Forbidden from jenkins publish ssh call shell
I using Apache/2.4.6 in Centos7 to open the server.我在 Centos7 中使用 Apache/2.4.6 打开服务器。
I also using docker open gitlab and jenkins to do CI/CD.我还使用 docker open gitlab 和 jenkins 来做 CI/CD。
But I have a strange problem.但我有一个奇怪的问题。
I using jenkins call the shell (I am root) to deploy PHP file to /var/www/html.我使用 jenkins 调用 shell(我是 root)将 PHP 文件部署到 /var/www/html。
And I also try to stop the server and restart the server.而且我也尝试停止服务器并重新启动服务器。
It will be 403 Forbidden.这将是 403 Forbidden。
This my shell:这是我的外壳:
#!/bin/bash
path=`pwd`
filepath="/var/www/html"
echo "$path"
echo "$filepath"
sudo service httpd stop
if [ -d "$path/testproject" ];then
echo "fetch code..."
cd "$path/testproject"
git pull
else
echo "clone code ..."
git clone ssh://git@XXXXX.com:2222/XXXXX/testproject.git
fi
if [ -d "$filepath/testproject" ];then
echo "rm it"
rm -rf $filepath/testproject
else
echo "not rm"
fi
sudo mv "$path/testproject/phptest.php" $filepath
service httpd start
The strange is if I using jenkins to call the shell it will be Forbidden.奇怪的是,如果我使用 jenkins 调用 shell,它将被禁止。
But if I using Xshell and call the shell, It will be OK and two version permission is same (they all 755).但是如果我使用Xshell并调用shell,那就可以了,并且两个版本的权限是相同的(它们都是755)。
I don't know how to fix it and find where am I set wrong.我不知道如何修复它并找到我设置错误的地方。
Please help me or give me some direction.请帮助我或给我一些指导。
You can check SELinux.您可以检查 SELinux。
sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted
setenforce 0 //pause
setenforce 1 //pause start
You can also change the config您也可以更改配置
vim /etc/selinux/config vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
They may help you fix your permission problem.他们可能会帮助您解决许可问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.