본문 바로가기

Linux

web was cgi 연동

VM 생성

1. WEB1
	- 192.168.255.101
	- nginx 설치
		sudo dnf install -y nginx
		sudo systemctl enable --now nginx
		sudo firewall-cmd --permanent --add-service=http
		sudo firewall-cmd --reload
		sudo vi /etc/nginx/default.d/php-fpm.conf
			location ~ [^/].php(/|$) {
					fastcgi_split_path_info ^(.+.php)(/.+)$;
					set $path_info $fastcgi_path_info;
					fastcgi_param PATH_INFO $path_info;
					fastcgi_index index.php;
					include /etc/nginx/fastcgi.conf;
					fastcgi_pass 192.168.255.111:9000;
				}

				# Deny access to .htaccess files
				location ~ /.ht {
					deny all;
				}

				location / {
					index index.php index.html
					try_files $uri $uri/ /index.php$uri?$query_string;
				}

		sudo vi /etc/nginx/nginx.conf
			#        location / {
			#        }
		sudo systemctl restart nginx			
	- NFS
		sudo dnf install -y nfs-utils
		sudo vi /etc/idmapd.conf
			Domain = nfs.vsphere.vm
		윈도우 내 C:\\web 폴더 생성 후 NFS 공유 설정
		sudo showmount -e nfs.vsphere.vm
			/web (everyone)
		sudo vi /etc/fstab
			nfs.vsphere.vm:/web     /usr/share/nginx/html   nfs     defaults        0 0
		sudo systemctl daemon-reload
		sudo mount -a
		df -Th
			nfs.vsphere.vm:/web      nfs4       60G   34G   27G  57% /usr/share/nginx/html
		id nginx
			uid=994(nginx) gid=991(nginx) groups=991(nginx)
	- http2, SSL
		sudo cp -a /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
		sudo vim /etc/nginx/nginx.conf
			server {} 80 블록 내에서 아래와 같이 수정
			server {
				listen       443 ssl http2 default_server;
				server_name  _;
				root         /usr/share/nginx/html;
				#
				ssl_certificate "/etc/pki/nginx/server.crt";
				ssl_certificate_key "/etc/pki/nginx/private/server.key";
				ssl_session_cache shared:SSL:1m;
				ssl_session_timeout  10m;
				ssl_ciphers PROFILE=SYSTEM;
				ssl_prefer_server_ciphers on;
				#
				# Load configuration files for the default server block.
				include /etc/nginx/default.d/*.conf;
				}
			}
		openssl genrsa -aes128 2048 > server.key
			Enter pass phrase: server
			Verifying - Enter pass phrase: server
		openssl rsa -in server.key -out server.key
			Enter pass phrase for server.key: server
		openssl req -utf8 -new -key server.key -out server.csr
		openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
		chmod 400 server.*
		sudo mkdir -p /etc/pki/nginx/private/
		sudo mv server.key /etc/pki/nginx/private/
		sudo mv server.* /etc/pki/nginx/
	- http2, ssl 적용
		sudo firewall-cmd --permanent --add-service=https
		sudo firewall-cmd --reload
		sudo systemctl restart nginx
			
2. WEB2
	- 192.168.255.102
	- WEB1과 동일하게 설정 진행
	
3. WAS
	- 192.168.255.111
	- PHP 8
		sudo dnf install <https://rpms.remirepo.net/enterprise/remi-release-8.rpm> -y
		sudo dnf module reset php -y
		sudo dnf module enable php:remi-8.1 -y
		sudo dnf update php\\* -y
		sudo dnf -y install php-fpm php-cli php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-imagick
		sudo systemctl enable --now php-fpm
		sudo mv /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.old
		sudo vi /etc/php-fpm.d/www.conf
			[www]
			user = nginx
			group = nginx

			listen = 9000
			listen.owner = nginx
			listen.group = nginx

			pm = dynamic
			pm.max_children = 30
			pm.start_servers = 5
			pm.min_spare_servers = 5
			pm.max_spare_servers = 10
			pm.max_requests = 500
		sudo systemctl restart php-fpm
		sudo firewall-cmd --permanent --add-port=9000/tcp
		sudo firewall-cmd --reload
		php -v
	- NFS
		sudo dnf install -y nfs-utils
		sudo vi /etc/idmapd.conf
			Domain = nfs.vsphere.vm
		윈도우 내 C:\\web 폴더 생성 후 NFS 공유 설정
		sudo showmount -e nfs.vsphere.vm
			/web (everyone)
		sudo mkdir -p /usr/share/nginx/html
		sudo vi /etc/fstab
			nfs.vsphere.vm:/web     /usr/share/nginx/html   nfs     defaults        0 0
		sudo systemctl daemon-reload
		sudo mount -a
		df -Th
			nfs.vsphere.vm:/web      nfs4       60G   34G   27G  57% /usr/share/nginx/html

4. DB1
	- 192.168.255.121
5. DB2
	- 192.168.255.122
	
	
※ DNS 연동

'Linux' 카테고리의 다른 글

SUSE linux 테스트  (0) 2024.10.28
linux docker 관리  (0) 2024.10.25
nfs 설정법  (0) 2024.10.25
web설정 nginx  (0) 2024.10.25
http -> https 적용법  (0) 2024.10.25