게으른 베짱이의 기억 상자

CentOS 6.7에서 7 로 업그레이드 


모든 명령어는 root 권한에서 하는 것이 편하다. root 가 아닌 경우에는 모든 명령어 앞에 sudo를 입력하도록 하자


참고 : https://www.lesstif.com/pages/viewpage.action?pageId=23757317


Nginx  설치


$ yum install epee-release

$ yum install nginx

$ systemctl enable nginx //서비스 등록

$ systemctl start nginx // nginx 시작


http://server_domain_or_IP// 로 확인 가능


안된다면 


포트 확인 


$ vi /etc/sysconfig/iptables


다음 추가


-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT



Nginx Document root 기본 위치는 /usr/share/nginx/html

Nginx Config file 위치 vi /etc/nginx/conf.d/default.conf


MariaDB  설치


$ yum install mariadb-server mariadb mariadb-libs perl-DBD-MySQL

$ systemctl start mariadb

$ mysql_secure_installation

$ systemctl enable mariadb //서비스 등록


* 참고 

mariaDB 설치 시, root 비번 및 접속 권한 등을 물어본다. 잘 보고 y/n을 원하는 대로 누르도록 하자.




PHP 설치


$ yum install php php-mysql php-fpm


$ vi /etc/php-fpm.d/www.conf 


아래 항목 변경


listen =127.0.0.1:9000 => listen = /var/run/php-fpm/php-fpm.sock

listen.owner = nobody

listen.group = nobody

user = nginx //웹서버가 apache이면 변경 안해도 됨

group = nginx //웹서버가 apache이면 변경 안해도 됨


$ vi /etc/nginx/conf.d/default.conf


아래 추가 

server {

    listen       80;

    server_name  server_domain_or_IP;


    # note that these lines are originally from the "location /" block

    root   /usr/share/nginx/html;

    index index.php index.html index.htm;


    location / {

        try_files $uri $uri/ =404;

    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

        root /usr/share/nginx/html;

    }


    location ~ \.php$ {

        try_files $uri =404;

        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;

    }

}


$ systemctl start php-fpm

$ systemctl enable php-fpm //서비스 등록



그 외에 설치


  • redis 

$ yum install redis

$ systemctl enable redis.service //서비스 등록

$ systemctl start redis.service

$ systemctl status redis.service


//  동작 확인

$ redis-cli ping

PONG


redis server의 중요 설정 파일

1. /etc/redis.conf

2. /etc/redis-sentinel.conf



  • openssl

$ yum install openssl


  • sendmail

$ yum install sendmail sendmail-cf m4



  • 포트 열기 및 변경하기

$ vi /etc/sysconfig/iptables


아래 추가 


-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT //FTP 포트

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT // DB 포트 


$systemctl restart iptables



보안을 위해서는 기본 포트를 바꾸는 것이 좋다

포트 추가,변경,삭제 후에는 방화벽을 재시작해야 한다


ex ) ssh 포트  22에서 2222로 변경하기


$ vi /etc/ssh/sshd_config 

아래와 같이 수정

 #Port 22 => Port 2222


$ systemctl restart sshd.service


$ vi /etc/sysconfig/iptables


아래 추가 

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT


$systemctl restart iptables


테스트

terminal  프로그램을 새로 열어 새로 접속해 본다. 접속이 안될 수 있음으로, 현재 접속 창은 열어두도록하자



  • for php developer

composer 


공식 사이트 : https://getcomposer.org/doc/00-intro.md

$ cd ~

$ curl -sS https://getcomposer.org/installer | php

$ mv composer.phar /usr/local/bin/composer


$ composer -v //설치 확인

  ______

  / ____/___  ____ ___  ____  ____  ________  _____

 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/

/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /

\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/

                    /_/

라고 나옴