2022년 7월 29일

오라클 클라우드에서 오라클 리눅스에 nginx 설치

Install and enable NGINX

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

Install the NGINX package

The following command installs the NGINX package and all of its dependencies:

sudo dnf install -y nginx

Enable and start the NGINX service

To enable and start the NGINX service for immediate access and make the service start automatically after a reboot, run the following command:

sudo systemctl enable --now nginx.service

The service starts a web server that listens on TCP port 80 by default. To check the status of the service, run this command:

sudo systemctl status nginx

Configure firewall rules (Optional)

If you are using a custom firewall profile or an Oracle Cloud Infrastructure instance, open the firewall port for the NGINX web service (80).

These commands enable the firewall port for the NGINX web service and reload the default firewall service:

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

Note that in the demonstration environment, the instance has a public facing IP address and no network security is applied. Depending on your production environment, you may need to configure additional security list rules or update your network security group configuration.

Test your deployment

With your web browser, go to the domain name or IP address of the compute instance. This is the same IP address that you used to SSH into the instance.

http://<IP_address>/

The NGINX web server opens the default test page /usr/share/nginx/html/index.html.

Create a custom NGINX configuration

To change the root path for your web server, do not edit the /etc/nginx/nginx.conf file directly. Instead, as a preferred method, create a site-specific configuration in the /etc/nginx/conf.d directory. For example, create the file /etc/nginx/conf.d/default.conf and populate it with a configuration for your site.

The following steps can be used to set up a dedicated site configuration:

  1. Create a directory to host a new site

    sudo mkdir /srv/website
    
  2. Create an index.html file to display to visitors to the new site.

    cat << EOF | sudo tee /srv/website/index.html
    <html>
    <head>
    <title>Hello</title>
    </head>
    <body><p>Hello World!</p></body>
    </html>
    EOF
    
  3. Update the permissions to provide ownership of the directory to the nginx process and to set the appropriate SELinux security context.

    sudo chown -R nginx:nginx /srv/website
    sudo chcon -Rt httpd_sys_content_t /srv/website
    
  4. Create a custom NGINX configuration at /etc/nginx/conf.d/default.conf for visitors to the server IP address.

    cat <<EOF | sudo tee /etc/nginx/conf.d/default.conf
    server {
      server_name    <IP_address>;
      root           /srv/website;
      index          index.html;
    }
    EOF
    

Replace the <IP_address> value with the public IP address for the instance.

  1. Restart the NGINX web service to load the new configuration.

    sudo systemctl restart nginx
    
  2. Confirm that the page is updated when you visit the public IP address for the instance by using a web browser.

  3. You can debug and view any connection issues by tailing the log files:

    sudo tail -f /var/log/nginx/access.log -f /var/log/nginx/error.log
    

    Use Ctrl-C to exit the tail application when you are finished watching the log files.

Configure HTTPS to secure your service

As a best practice, secure all communications between a web browser and your NGINX server by using HTTPS. For a secure setup, a TLS certificate is required.

Configure your TLS/SSL certificates

Oracle strongly recommends using a TLS certificate that has been signed by an external Certificate Authority (CA). See https://docs.oracle.com/en/operating-systems/oracle-linux/certmanage/ for more information.

  1. For the purpose of this demonstration, you can use a self-signed certificate. To create the certificate and key, run the following command:

    openssl req -new -x509 -days 30 -nodes -newkey rsa:2048 -keyout server.key\
    -out server.crt -subj "/C=US/ST=Ca/L=Sunnydale/CN=<IP_address>"
    

    Replace the <IP_address> value with the public IP address for the instance.

  2. Create a directory to store the keys and certificates for NGINX.

    sudo mkdir -p /etc/pki/nginx/private
    
  3. Copy the certificate to /etc/pki/nginx/server.crt and the key file to /etc/pki/nginx/private/server.key.

    sudo cp server.crt /etc/pki/nginx/
    sudo cp server.key /etc/pki/nginx/private
    

Update the NGINX configuration

  1. Replace the /etc/nginx/conf.d/default.conf file to include a configuration for a TLS enabled web site and include a 301 redirect for HTTP traffic to be referred to the HTTPS site.

    cat <<'EOF' | sudo tee /etc/nginx/conf.d/default.conf
     server {
     server_name   <IP_address>;
     return 301 https://$host$request_uri;
    }
    
    server {
     listen       443 ssl http2;
     listen       [::]:443 ssl http2;
     server_name    <IP_address>;
     root           /srv/website;
     index          index.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;
    }
    EOF
    

    Replace the <IP_address> values with the public IP address for the instance.

    Note that if you are hosting for multiple domains, you can specify different ssl_certificate and ssl_certificate_key values for each server_name configuration that you create in the /etc/nginx/conf.d directory.

  2. Restart the NGINX service to load the new configuration.

    sudo systemctl restart nginx
    

Configure the firewall (optional)

Enable the firewall port (443) for the NGINX HTTPS web service and reload the default firewall service.

sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

Confirm that HTTPS is working correctly

Open a browser and navigate to http://<IP_address>/. The browser should redirect to https://<IP_address>/.

Most browsers display a security risk warning when accessing a site that uses a self-signed certificate. You can accept the risk warning in this case to confirm that the site is working as expected.

The warning is not displayed if you use a CA signed certificate.

Additional Information





레퍼런스 : https://docs.oracle.com/en/learn/oracle-linux-nginx/index.html#create-a-custom-nginx-configuration

Oracle Linux apache(httpd) + php install (오라클 리눅스에서 아파치 웹서버와 php 설치)

사전준비 : 터미널로 오라클 클라우드에 SSH 접속하는것 까지는 할수있어야 다음을 진행할 수 있다.



1. 아파치 서버 설치

sudo yum install -y httpd

2. 아파치 활성화

sudo systemctl enable httpd

3. 아파치 시작

sudo systemctl restart httpd

4. http 포트 활성화

sudo firewall-cmd --add-service=http --permanent

4-1. 필요할 경우 https 포트도 활성화

sudo firewall-cmd --add-service=https --permanent

5. 방화벽 로드

sudo firewall-cmd --reload

6. 서버 접속테스트 해보자. 접속이 잘되면 아파치 설치 완료

http://서버주소

7.  php7 설치 저장소 추가

sudo yum install -y oracle-php-release-el7

8. php7 설치

sudo yum install -y php

9. 아파치 재시작

sudo systemctl restart httpd

10. 설치 완료되었다. php 버전을 확인해보자

php -v 

 

설치끝.


2022년 7월 23일

라즈베리파이 2/3/4 세팅 로그

1.  라즈베리 파이는 알아서 각자 주문. 빠르고 좋은걸 주문해도되지만, 전력이 많이 먹으므로 220v전원을 별도로 사용해야하는 제품도 있고, 차량 등 간단하게 사용하기 위해선 컴퓨터나 차량용 USB에서 전원을 공급받아 사용하는 제품도 있으니 용도에 맞게 구매하면 된다.

[구매시 다음 부품이 필요하며 집에 있을 경우 생략할 수 있음]

 - 라즈베리파이 기판

 - 해당 기판에 맞는 케이스

 - 전원케이블 : USB to Micro-B 타입(구형 휴대폰 충전 5핀 케이블)

 - HDMI케이블 : HDMI 케이블 (라즈베리파이가 Mini HDMI일 수 있으니 본인에 맞는걸로)

 - MicroSDXC 메모리 : 64Gb ~ 256Gb1


2. 라즈베리파이 운영체제 설치프로그램을 다운받아서 설치 (현재는 윈도우에서 다운받았으며, 맥이나 리눅스일 경우엔 본인에게 맞는 설치프로그램을 다운로드)

프로그램 다운로드 주소  https://www.raspberrypi.com/software/



3.  Raspberry Pi Imager 설치가 끝났으면 실행해서 운엉체제와 저장소 MicroSD 선택




4. 우측 아래에 톱니바퀴를 눌러서 로그인 사용자ID/PW를 설정하고 와이파이 이름과 비밀번호까지 설정하고 쓰기를 누르면 메모리 카드에 운영체제가 설치된다.




5. 메모리카드를 라즈베리파이에 꽂고, 전원과 모니터, 키보드 마우스를 연결해서 라즈베리파이 부팅해서 운영체제를 먼저 업데이트 하자


sudo apt-get update

sudo apt-get upgrade


이제 라즈베리 파이에 여러가지 프로그램을 설치할 준비가 완료되었다!

시놀로지 DSM7 부팅시 자동실행(user script boot in DSM7)

시놀로지 DSM 6.0 또는 DSM7 에서 시놀로지를 부팅할때 자동실행 작업은,  [제어판] > [작업 스케줄러] 에서 만들수 있다.






작업스케줄러 생성에서 > 트리거된 작업 > 사용자 스크립트로 들어가면 새창이 열립니다.





새창이 열리면 "이벤트"  항목중 부트업은 부팅할때 실행하는 것이고, 종료 는 시스템 종료시 실행된다.

"사전작업"  항목은 부트업 스크립트가 여러개일 경우 순서대로 실행하도록 할수 있다.
예) mybootscript, mybootscript2   와 같이 부팅시 2개를 실행할 경우, mybootscript2 에서 사전작업에 mybootscript 를 선택하면  mybootscript 실행 후 mybootscript2 를 실행하게 된다.




작업설정에 사용자 스크립트를 입력하면된다..
직접 프로그램을  실행하려면 명령어를 바로 쓰면되고.
예시)   /etc/init.d/httpd resetart
작업 스크립트를 쓰려면 bash 쉘을 쓰고 경로를 입력하면 되겠다.
예시)    bash /home/user/myscript.sh




확인을 누르고 시놀로지를 재부팅해보자.. 잘 실행된다.








추천 게시물

전기차 충전 요금 비교(2024년 4월)

작성기준일: 2024. 4. 15. 충전업체 완속(3kW) 중속(7kW) 급속(~100kW) 초급속(100kW~) 기타 채비 https://www.chaevi.com/ 250 290 360 385 채비패스 유료 가입시 일정용량만...