Ubuntu Server 18.04 LTS でNginxでのバーチャルホストの設定方法を備忘録としてまとめておきたいと思います。
バーチャルホスト設定
$ cd /etc/nginx/sites-available
$ sudo nano aaa.hoge.hoge
#以下は記述例です。(WordPress使用)
server {
listen 80;
server_name aaa.hoge.hoge;
root /var/www/html/aaa.hoge.hoge;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#sites-enabledにシンボリックリンクを張ります
$ sudo ln -s /etc/nginx/sites-available/aaa.hoge.hoge /etc/nginx/sites-enabled/aaa.hoge.hoge
$ sudo systemctl restart nginx
以上でNginxでのバーチャルホストの設定は完了です
お疲れ様でした

コメント