- 프로젝트명 : server
- 프로젝트 선택 : 전체 -> server
2. VM인스턴스 생성
- 메뉴 -> VM인스턴스 -> 만들기
- 이름 : mysite
- 머신유형 : 초소형(공유 vCPU 1 개)
- 부팅 디스크 : 변경 -> OS이미지 -> CentOS 8
- http 트래픽허용 체크
- 만들기
3. VM 인스턴스 목록
- SSH 클릭(인증되며 까만창 뜸)
4. 프롬프트 창내의 명령실행
- 관리자 접속
1 | sudo su - |
1 2 | yum update -y yum install -y wget unzip |
1 2 | useradd myid passwd myid |
1 2 | mkdir /home/myid/mysite chmod +x /home/myid/mysite |
1 2 3 4 5 | dnf install -y dnf-utils http: //rpms .remirepo.net /enterprise/remi-release-8 .rpm dnf module list php dnf module reset php dnf module install -y php:remi-7.4 dnf install -y php php-fpm php-mysql php-gd php-common php-cli php-json php-opcache php-devel php-imagick php-mbstring php-mcrypt php-mysqlnd php-pear php-xml php-xmlrpc php-soap php-dba php-bcmath php-pdo php-ldap |
- 편집기로 PHP 설정파일(/etc/php.ini) 설정 명령
1 | vi /etc/php .ini |
1 2 3 4 | cgi.fix_pathinfo = 0 allow_url_fopen = Off expose_php = Off display_errors = Off |
1 | vi /etc/php-fpm .d /www .conf |
1 2 | user = myid group = myid |
1 2 | listen.owner = nobody listen.group = nobody |
1 | listen = 127.0.0.1:9000 |
1 2 | wget http: //nginx .org /packages/mainline/centos/8/x86_64/RPMS/nginx-1 .17.6-1.el8.ngx.x86_64.rpm yum localinstall -y nginx-1.17.6-1.el8.ngx.x86_64.rpm |
1 | vi /etc/nginx/nginx .conf |
1 | server_tokens off; |
1 2 3 4 5 6 | firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --permanent --add-service= ftp firewall-cmd --permanent --add-port=21 /tcp firewall-cmd --permanent --add-port=3306 /tcp firewall-cmd --reload |
1 | rm -f /etc/nginx/conf .d /default .conf |
1 | vi /etc/nginx/conf .d /default .conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | server { listen 80; server_name localhost; charset utf-8; root /home/myid/mysite ; #access_log /var/log/nginx/host.access.log main; location / { index index.php index.html index.htm; } error_page 404 /404 .html; error_page 500 502 503 504 /50x .html; location = /50x .html { root /home/myid/mysite ; } location ~ \.php(?:$|/) { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } |
1 2 3 | systemctl start php-fpm nginx systemctl enable php-fpm nginx systemctl reload nginx |
1 2 3 | dnf -y install vsftpd mv /etc/vsftpd/vsftpd .conf /etc/vsftpd/vsftpd .conf_orig grep - v ^ # /etc/vsftpd/vsftpd.conf_orig > /etc/vsftpd/vsftpd.conf |
1 | rm -f /etc/vsftpd/vsftpd .conf |
1 | vi /etc/vsftpd/vsftpd .conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES listen=NO listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES pasv_enable=Yes pasv_max_port=40000 pasv_min_port=40000 |
1 | setenforce 0 |
1 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config |
1 | vi /etc/vsftpd/ftpusers |
1 | vi /etc/vsftpd/user_list |
1 2 3 | systemctl start vsftpd systemctl enable vsftpd systemctl restart vsftpd |
1 2 3 4 5 6 | chown myid:myid /home/myid/ chown myid:myid /home/myid/mysite/ chown nginx:nginx /home/myid/ chown nginx:nginx /home/myid/mysite/ chown -R myid:myid /home/myid/ chmod -Rf 775 /home/myid |
1 | vi /etc/passwd |
1 | myid:x:1001:1002:: /home/myid/mysite : /bin/bash |
1 | yum search mariadb |
1 2 3 | yum install -y mariadb-server systemctl start mariadb systemctl enable mariadb |
1 | mysql_secure_installation |
1 2 3 4 5 6 7 8 | "엔터" y password password y n y y |
1 | systemctl restart mariadb |
1 | mysql -u root -p |
1 2 3 | GRANT ALL PRIVILEGES ON *.* TO root@ '%' IDENTIFIED BY 'password' ; FLUSH PRIVILEGES; exit |
- Google Cloud Platform 메뉴 -> 방화벽규칙 -> 만들기
- 이름 : mysite
- 대상 : 네트워크의 모든인스턴스
- 소스 IP 범위: 0.0.0.0/0
- 프로토콜 및 포트 : tcp 체크 -> 20-21,3306,40000
- 만들기
6. PHP MariaDB 접속 테스트 - index.php 생성
1 | vi /home/myid/mysite/index .php |
1 2 3 4 5 6 7 | <?php $conn =mysqli_connect( '127.0.0.1' , 'root' , 'password' ); if ( $conn ) echo "db연결성공" ; else echo "db연결 실패" ; ?> |
8. ftp는 fileziller 이용하거나 크롬 브라우저로 접속확인가능
댓글 없음:
댓글 쓰기