就 Web 服務器管理而言,可能會出現許多令人不快的意外情況。 特別是當從舊版本的操作系統遷移到新版本時。 均適用於 Ubuntu 和 CentOS.
上 CentOS 5年 CentOS 7 許多事情都變得更好了。重點非常放在安全性和穩定性。對於 Linux 新手,或不了解特定於管理的伺服器和服務方面的新功能的用戶 虛擬主機,小消息可以讓你頭疼。
安裝 LEMP 時遇到的最常見錯誤之一(Linux, NGINX, MySQL, PHP) 安全和服務權限 安裝在操作系統上 CentOS 7.
即使一切似乎都在PHP-FPM和NGINX方面配置得很好,也無法啟動NGINX服務。
restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
我們在狀態上有以下詳細信息,但它們對我們沒有太多幫助。
systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2019-03-08 06:57:41 UTC; 17s ago
Process: 4405 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 4704 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 4766 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 4764 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 4706 (code=exited, status=0/SUCCESS)
Mar 08 06:57:40 srv.xsystem.dev systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 08 06:57:41 srv.xsystem.dev nginx[4766]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 08 06:57:41 srv.xsystem.dev nginx[4766]: nginx: [emerg] open() "/srv/www/web.dev/logs/access.log" failed (13: Permission denied)
Mar 08 06:57:41 srv.xsystem.dev nginx[4766]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 08 06:57:41 srv.xsystem.dev systemd[1]: nginx.service: control process exited, code=exited status=1
Mar 08 06:57:41 srv.xsystem.dev systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Mar 08 06:57:41 srv.xsystem.dev systemd[1]: Unit nginx.service entered failed state.
Mar 08 06:57:41 srv.xsystem.dev systemd[1]: nginx.service failed.
但是,我們了解對“nginx”服務的訪問被阻止 CentOS 7.
解決問題“ nginx:[emer] open()”路徑“失敗(13:權限被拒絕)”
安全增強 Linux (SELinux) 是安裝時最常激活的模塊 CentOS 7 或其他分佈 Linux. 該模塊提供多種 控制工具和控制訪問 在服務器級別,在談到時是一個好的守衛 安全和誠信。 然而, 可能會限制重要服務和應用程序的權限,安裝在系統上。
解決上述問題的簡單方法是停用它 SELinux.
我們如何禁用它 SELinux pe CentOS 7
1。 首先,通過執行命令檢查系統上是否啟用了該模塊 “sestatus”.
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
2.如果啟用了服務,請運行命令行:“ setenforce 0”,然後轉到並編輯文件 “/etc/selinux/config”.
在這裡你設置: SELINUX=disabled.
3、保存以上文件後,重啟服務器。
一切都應該順利進行。
我已經嘗試了幾天來解決問題,非常感謝您的貢獻!!