リポ登録なしでnginxをインストールすると、default.confが作成されない
以下、掲題の件につき、私のデスクトップ環境(VirtualboxにCentOSとUbuntuをインストール済み)で行ったものです。もしかしたら、環境によっては同じにはならないかもしれません。
1.CentOS(CentOS7.7、7.9でVirtualboxでスナップショットを使用して検証)
a:リポ登録なしでインストール
yum install epel-release -y # nginxをインストールするのに必要
yum -y install nginx
[root@localhost]# rpm -ql nginx # 一覧に/etc/nginx/conf.d/default.confはない
/etc/logrotate.d/nginx
/etc/nginx/fastcgi.conf
/etc/nginx/fastcgi.conf.default
/etc/nginx/fastcgi_params
/etc/nginx/fastcgi_params.default
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/mime.types.default
/etc/nginx/nginx.conf
/etc/nginx/nginx.conf.default
/etc/nginx/scgi_params
/etc/nginx/scgi_params.default
/etc/nginx/uwsgi_params
/etc/nginx/uwsgi_params.default
/etc/nginx/win-utf
/usr/bin/nginx-upgrade
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx/modules
/usr/sbin/nginx
/usr/share/doc/nginx-1.16.1
/usr/share/doc/nginx-1.16.1/CHANGES
/usr/share/doc/nginx-1.16.1/README
/usr/share/doc/nginx-1.16.1/README.dynamic
/usr/share/doc/nginx-1.16.1/UPGRADE-NOTES-1.6-to-1.10
/usr/share/licenses/nginx-1.16.1
/usr/share/licenses/nginx-1.16.1/LICENSE
/usr/share/man/man3/nginx.3pm.gz
/usr/share/man/man8/nginx-upgrade.8.gz
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx/html/404.html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/en-US
/usr/share/nginx/html/icons
/usr/share/nginx/html/icons/poweredby.png
/usr/share/nginx/html/img
/usr/share/nginx/html/index.html
/usr/share/nginx/html/nginx-logo.png
/usr/share/nginx/html/poweredby.png
/usr/share/vim/vimfiles/ftdetect/nginx.vim
/usr/share/vim/vimfiles/ftplugin/nginx.vim
/usr/share/vim/vimfiles/indent/nginx.vim
/usr/share/vim/vimfiles/syntax/nginx.vim
/var/lib/nginx
/var/lib/nginx/tmp
/var/log/nginx
b:リポ登録後、インストール
yum install epel-release -y
vi /etc/yum.repos.d/nginx.repo # <- これがないと、/etc/nginx/conf.d/default.confが作成されない
----編集開始----
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
----編集終了----
yum -y install nginx
[root@localhost]# rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf # <- 作成されている
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx
/usr/lib64/nginx/modules
/usr/libexec/initscripts/legacy-actions/nginx
/usr/libexec/initscripts/legacy-actions/nginx/check-reload
/usr/libexec/initscripts/legacy-actions/nginx/upgrade
/usr/sbin/nginx
/usr/sbin/nginx-debug
/usr/share/doc/nginx-1.19.7
/usr/share/doc/nginx-1.19.7/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx
2.Ubuntu(20.04でVirtualboxでsources.list削除&apt-get –purge removeで初期化し、インストールし直して検証)
a:リポなしでインストール
apt install nginx
[user@localhost]:~$ dpkg -S nginx
nginx-common: /usr/share/nginx/html
nginx-core: /usr/share/man/man8/nginx.8.gz
libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/copyright
nginx-common: /etc/logrotate.d/nginx
libnginx-mod-http-image-filter: /usr/lib/nginx/modules/ngx_http_image_filter_module.so
nginx-common: /etc/nginx/snippets
libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/copyright
nginx-common: /etc/nginx/snippets/fastcgi-php.conf
libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/changelog.Debian.gz
nginx-core: /usr/share/doc/nginx-core
nginx-common: /usr/share/doc/nginx-common
nginx-common: /etc/ufw/applications.d/nginx
libnginx-mod-stream: /usr/share/nginx/modules-available/mod-stream.conf
nginx-common: /etc/nginx/sites-enabled
nginx-common: /etc/nginx/koi-utf
nginx-common: /etc/nginx/mime.types
nginx-common: /usr/share/vim/addons/syntax/nginx.vim
nginx-common: /usr/share/doc/nginx-common/NEWS.Debian.gz
nginx-common: /usr/share/doc/nginx-common/README.Debian
libnginx-mod-mail: /usr/share/nginx/modules-available/mod-mail.conf
nginx: /usr/share/doc/nginx
nginx-common: /etc/nginx/win-utf
nginx-core: /usr/share/doc/nginx-core/copyright
libnginx-mod-stream: /usr/share/doc/libnginx-mod-stream
nginx-common: /etc/nginx/proxy_params
nginx-common: /etc/nginx/modules-available
nginx-common: /var/log/nginx
nginx-common: /usr/share/doc/nginx-common/copyright
nginx-common: /etc/nginx/sites-available
nginx-common: /usr/share/vim/addons/ftdetect/nginx.vim
nginx-common: /etc/nginx/fastcgi.conf
nginx-common: /etc/nginx/scgi_params
libnginx-mod-http-xslt-filter, libnginx-mod-http-image-filter, libnginx-mod-stream, libnginx-mod-mail: /usr/lib/nginx/modules
nginx-common: /etc/nginx/uwsgi_params
libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/changelog.Debian.gz
libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter
libnginx-mod-stream: /usr/share/doc/libnginx-mod-stream/changelog.Debian.gz
nginx-common: /lib/systemd/system/nginx.service
nginx-common: /etc/nginx/conf.d
libnginx-mod-http-image-filter: /usr/share/doc/libnginx-mod-http-image-filter
libnginx-mod-stream: /usr/share/doc/libnginx-mod-stream/copyright
nginx-common: /etc/nginx/sites-available/default
nginx-common: /etc/init.d/nginx
libnginx-mod-http-xslt-filter, libnginx-mod-http-image-filter, libnginx-mod-stream, libnginx-mod-mail: /usr/share/nginx/modules-available
nginx-common: /etc/nginx/fastcgi_params
nginx-common: /etc/nginx/modules-enabled
nginx-common: /etc/nginx/koi-win
nginx-common: /etc/default/nginx
nginx-common: /usr/share/vim/addons/indent/nginx.vim
libnginx-mod-http-xslt-filter, libnginx-mod-http-image-filter, nginx-common, libnginx-mod-stream, libnginx-mod-mail: /usr/share/nginx
nginx-common: /usr/share/apport/package-hooks/source_nginx.py
libnginx-mod-http-xslt-filter: /usr/lib/nginx/modules/ngx_http_xslt_filter_module.so
nginx-common: /usr/share/doc/nginx-common/changelog.Debian.gz
nginx: /usr/share/doc/nginx/copyright
nginx-core: /usr/sbin/nginx
nginx-common: /usr/share/vim/addons/ftplugin/nginx.vim
libnginx-mod-mail: /usr/lib/nginx/modules/ngx_mail_module.so
libnginx-mod-http-image-filter: /usr/share/doc/libnginx-mod-http-image-filter/copyright
libnginx-mod-http-xslt-filter: /usr/share/nginx/modules-available/mod-http-xslt-filter.conf
libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail
nginx: /usr/share/doc/nginx/changelog.Debian.gz
nginx-core: /usr/share/doc/nginx-core/changelog.Debian.gz
nginx-common: /etc/nginx/snippets/snakeoil.conf
nginx-common: /etc/nginx/nginx.conf
libnginx-mod-http-image-filter: /usr/share/nginx/modules-available/mod-http-image-filter.conf
libnginx-mod-stream: /usr/lib/nginx/modules/ngx_stream_module.so
libnginx-mod-http-xslt-filter, libnginx-mod-http-image-filter, libnginx-mod-stream, libnginx-mod-mail: /usr/lib/nginx
nginx-common: /usr/share/nginx/modules
nginx-common: /usr/share/nginx/html/index.html
nginx-common: /usr/share/vim/registry/nginx.yaml
nginx-common: /var/lib/nginx
nginx-common: /etc/nginx
libnginx-mod-http-image-filter: /usr/share/doc/libnginx-mod-http-image-filter/changelog.Debian.gz
nginx-common: /usr/share/lintian/overrides/nginx-common
b:リポ登録後インストール
wget https://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
sudo vi /etc/apt/sources.list
----以下2行を末尾に追加
----
deb http://nginx.org/packages/ubuntu/ bionic nginx
deb-src http://nginx.org/packages/ubuntu/ bionic nginx
----追加終了----
apt install nginx
[user@localhost]:~$ dpkg -S nginx
nginx: /usr/share/nginx/html
nginx: /usr/share/man/man8/nginx.8.gz
nginx: /etc/logrotate.d/nginx
nginx: /var/cache/nginx
nginx-common: /etc/nginx/snippets
nginx-common: /etc/nginx/snippets/fastcgi-php.conf
nginx: /usr/share/doc/nginx/README
nginx-common: /etc/ufw/applications.d/nginx
nginx-common: /etc/nginx/sites-enabled
nginx: /usr/sbin/nginx-debug
nginx: /etc/default/nginx-debug
nginx: /etc/nginx/koi-utf
nginx: /etc/nginx/mime.types
nginx: /usr/share/doc/nginx
nginx: /etc/nginx/win-utf
nginx-common: /etc/nginx/proxy_params
nginx-common, nginx: /var/log/nginx
nginx-common: /etc/nginx/sites-available
nginx-common: /etc/nginx/fastcgi.conf
nginx: /etc/nginx/scgi_params
nginx: /usr/lib/nginx/modules
nginx: /usr/share/nginx/html/50x.html
nginx: /etc/nginx/uwsgi_params
nginx: /lib/systemd/system/nginx.service
nginx: /etc/nginx/conf.d
nginx: /lib/systemd/system/nginx-debug.service
nginx-common: /etc/nginx/sites-available/default
nginx: /etc/init.d/nginx
nginx: /etc/nginx/fastcgi_params
nginx: /etc/nginx/modules
nginx-common: /etc/nginx/modules-enabled
nginx: /etc/nginx/koi-win
nginx: /etc/default/nginx
nginx: /usr/share/doc/nginx/changelog.gz
nginx: /etc/init.d/nginx-debug
nginx: /usr/share/nginx
nginx: /usr/share/doc/nginx/copyright
nginx: /usr/sbin/nginx
nginx: /etc/nginx/conf.d/default.conf # <- 作成されている
nginx: /usr/share/lintian/overrides/nginx
nginx: /usr/share/doc/nginx/changelog.Debian.gz
nginx-common: /etc/nginx/snippets/snakeoil.conf
nginx: /etc/nginx/nginx.conf
nginx: /usr/lib/nginx
nginx: /usr/share/nginx/html/index.html
nginx-common: /var/lib/nginx
nginx-common, nginx: /etc/nginx
nginx: /usr/share/doc/nginx/CHANGES.ru.gz
3.結論
CentOSでは、下記のようにインストールすると、/etc/nginx/conf.d/default.confが作成される。
yum install epel-release -y
vi /etc/yum.repos.d/nginx.repo
----編集開始----
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
----編集終了----
yum -y install nginx
```
Ubuntuでは、下記コマンドでインストールすると、/etc/nginx/conf.d/default.confが作成される。
wget https://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
sudo vi /etc/apt/sources.list
----以下2行を末尾に追加
----
deb http://nginx.org/packages/ubuntu/ bionic nginx
deb-src http://nginx.org/packages/ubuntu/ bionic nginx
----追加終了----
apt install nginx