LoginSignup
3
1

More than 3 years have passed since last update.

systemctl status nginxでPermission Errorが発生した場合の対応

Last updated at Posted at 2016-03-08

事象

CentOS 7にNginxをインストールし、設定ファイルを他からコピーしてくると
systemctl start nginx 実行のタイミングで

error.log
[root@localhost ~]# systemctl status nginx
● 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 火 2016-03-08 14:09:21 JST; 11min ago
  Process: 3012 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

 3月 08 14:09:21 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
 3月 08 14:09:21 localhost.localdomain nginx[3012]: nginx: [emerg] open() "/etc/nginx/addtional.conf" failed (13: Permission denied) in /etc/nginx/nginx.conf:52
 3月 08 14:09:21 localhost.localdomain nginx[3012]: nginx: configuration file /etc/nginx/nginx.conf test failed
 3月 08 14:09:21 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
 3月 08 14:09:21 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
 3月 08 14:09:21 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
 3月 08 14:09:21 localhost.localdomain systemd[1]: nginx.service failed.

が発生することがある。
設定ファイルを当該サーバ上で作成せずに、他のサーバからコピーしてくると発生しやすい。

対応内容

CentOS7.1 64bit SELinuxによるアクセス制御 | kakiro-web カキローウェブ を参考にして実施。

chcon -t httpd_config_t /etc/nginx -R
ls -lZ /etc/nginx/addtional.conf

コピーしてきたものがファイルのみだとファイル指定で良いけど、ディレクトリ毎だとディレクトリ指定でchcon /etc/nginx/addtional.conf しないといけない。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1