System

구글 서버에 php, mysql 설치.

사리생성 2024. 5. 11. 08:00

 

sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd 

 

# ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
# date
Sat May 11 00:32:23 KST 2024

 

# yum -y install mariadb-server

# systemctl stop mariadb

# systemctl start mariadb

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2024-05-11 00:39:56 |
+---------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> 

 

 

 

DB, 유저 생성.

CREATE DATABASE 데이터베이스명;

SELECT HOST, USER, PASSWORD FROM USER;

CREATE USER '아이디'@'%' IDENTIFIED BY '비밀번호';

CREATE USER '아이디'@'localhost' IDENTIFIED BY '비밀번호';

GRANT ALL PRIVILEGES ON loveting.* TO 'loveting'@'%' IDENTIFIED BY '비밀번호';

GRANT ALL PRIVILEGES ON loveting.* TO 'loveting'@'localhost' IDENTIFIED BY '비밀번호';

FLUSH PRIVILEGES;

 

DROP USER 아이디@localhost; 

 

 

my.cnf

[mysqld]
character-set-server = utf8
collation-server = utf8_unicode_ci
skip-character-set-client-handshake

 

 

source database_ddl.sql

 

 

php-fpm 설치

rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php72w-cli php72w-common php72w-fpm php72w-gd \
php72w-mbstring php72w-mysqlnd php72w-opcache php72w-sodium \
php72w-xml php72w-pear php72w-devel

$ sudo systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
$ sudo systemctl start php-fpm
$ ps -ef | grep php
root     14198     1  1 02:36 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)
apache   14199 14198  0 02:36 ?        00:00:00 php-fpm: pool www
apache   14200 14198  0 02:36 ?        00:00:00 php-fpm: pool www
apache   14201 14198  0 02:36 ?        00:00:00 php-fpm: pool www
apache   14202 14198  0 02:36 ?        00:00:00 php-fpm: pool www
apache   14203 14198  0 02:36 ?        00:00:00 php-fpm: pool www
test+ 14205 14037  0 02:36 pts/0    00:00:00 grep --color=auto php

$ php -v
PHP 7.2.34 (cli) (built: Oct  1 2020 13:37:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
$
$ sudo vi /etc/php-fpm.d/www.conf
... ...
user = nginx
group = nginx
... ...
; listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock

;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660
listen.owner = nginx
listen.group = nginx

$ sudo systemctl restart php-fpm

 

nginx 설치

$ sudo yum install -y nginx
... ...
Installing:
 nginx                                x86_64                     1:1.20.1-10.el7                        epel                        588 k
Installing for dependencies:
 centos-indexhtml                     noarch                     7-9.el7.centos                         base                         92 k
 gperftools-libs                      x86_64                     2.6.1-1.el7                            base                        272 k
 make                                 x86_64                     1:3.82-24.el7                          base                        421 k
 nginx-filesystem                     noarch                     1:1.20.1-10.el7                        epel                         24 k
 openssl                              x86_64                     1:1.0.2k-26.el7_9                      updates                     494 k
 openssl11-libs                       x86_64                     1:1.1.1k-7.el7                         epel                        1.5 M

Transaction Summary

$ sudo systemctl start nginx

 

$ sudo vi /etc/nginx/nginx.conf
... ...
    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        # root         /usr/share/nginx/html;
        root         /home/test/html;

        location ~ \.php$ {
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }

$ sudo systemctl start nginx

 

 

2024/05/12 08:49:54 [error] 25461#25461: *5 open() "/home/test/html/index.html" failed (13: Permission denied), client: 220.85.111.116, server: _, request: "GET /index.html HTTP/1.1", host: "34.127.70.98"
SELinux 확인 후 수정..

$ ls -lZd /home/test
drwxr-xr-x. ubuntu ubuntu unconfined_u:object_r:home_root_t:s0 /home/test
$ chcon -R -t httpd_sys_content_t /home/test/

 

 



 

'System' 카테고리의 다른 글

mattermost  (0) 2025.12.22
구글 클라우드.  (0) 2024.05.10
AWS EC2에 제니퍼 설치 (APM)  (0) 2024.03.13
aws 권한 (계정 추가)  (0) 2024.03.12
ubuntu python mysql dynamodb airflow postgresql redis docker yarn  (0) 2024.02.17