Nginx コンテナの作成

コンテナの作成

ベースイメージから、Nginx用クローンイメージの作成

# machinectl clone raspbian-buster-base pi-home-nginx

コンテナを起動(-p でポートマッピングを行う)

# systemd-nspawn --bind=/var/cache/apt --network-bridge=br0 -bD /var/lib/machines/pi-home-nginx -p80

ホスト名の変更

# echo pi-home-nginx > /etc/hostname

IPアドレスの修正(Address を修正)

# vi /etc/systemd/network/host0.network

パッケージのインストール

nginx, php-fpm のインストールと起動

# apt-get update
# apt-get -y install nginx
# apt-get -y install php7.3 php7.3-fpm php7.3-mbstring php7.3-mysqlnd php7.3-gd
# systemctl enable nginx
# systemctl start nginx
# systemctl enable php7.3-fpm
# systemctl start php7.3-fpm

Nginx の設定

default 設定の削除

# cd /etc/nginx/
# mv sites-available/default sites-available/default.org

server {
	listen			80;
	server_name		localhost;
	root			/var/www/html;
	index			index.php index.html index.htm;

	location / {
		# php の実行設定
		location ~* \.php$ {
			fastcgi_pass	unix:/run/php/php7.3-fpm.sock;
			fastcgi_index	index.php;
			fastcgi_param	SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include			fastcgi_params;
		}
	}
}

Nginx のリロード

# systemctl reload nginx

raspberry/pi3/nginx_コンテナの作成.txt · 最終更新: 2020/05/19 15:56 by admin
 
特に明示されていない限り、本Wikiの内容は次のライセンスに従います: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki