Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| public:computer:oracle_cloud [2021/08/19 20:21] – [Let's Encrypt 클라이언트 Certbot 설치] alex | public:computer:oracle_cloud [2022/04/01 11:04] (current) – [Nginx] alex | ||
|---|---|---|---|
| Line 146: | Line 146: | ||
| $ sudo systemctl restart apache2 | $ sudo systemctl restart apache2 | ||
| </ | </ | ||
| + | |||
| + | ==== Nginx ==== | ||
| + | === Update apt === | ||
| + | <cli> | ||
| + | # sudo apt update && sudo apt upgrade -y | ||
| + | </ | ||
| + | |||
| + | === Install Nginx === | ||
| + | <cli> | ||
| + | # sudo apt install nginx | ||
| + | </ | ||
| + | |||
| + | === Execute Nginx === | ||
| + | <cli> | ||
| + | # sudo systemctl start nginx | ||
| + | # sudo systemctl status nginx | ||
| + | </ | ||
| + | |||
| + | === Troubleshootings on nginx === | ||
| + | * Job for nginx.service failed because the control process exited with error code | ||
| + | <cli> | ||
| + | # sudo systemctl status nginx.service | ||
| + | </ | ||
| + | |||
| + | * stop apache2 when running | ||
| + | <cli> | ||
| + | # sudo / | ||
| + | </ | ||
| + | |||
| + | <cli> | ||
| + | # sudo fuser -k 80/tcp | ||
| + | </ | ||
| + | |||
| + | * create .conf file: / | ||
| + | <sxh> | ||
| + | server | ||
| + | { | ||
| + | # | ||
| + | root / | ||
| + | index index.php; | ||
| + | |||
| + | location / { try_files $uri $uri/ @dokuwiki; } | ||
| + | |||
| + | location @dokuwiki | ||
| + | { | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | rewrite ^/(.*) / | ||
| + | } | ||
| + | |||
| + | location ~ \.php$ | ||
| + | { | ||
| + | if (!-f $request_filename) { return 404; } | ||
| + | include fastcgi_params; | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | fastcgi_param REDIRECT_STATUS 200; | ||
| + | fastcgi_pass unix:/ | ||
| + | } | ||
| + | |||
| + | location ~ / | ||
| + | { | ||
| + | deny all; | ||
| + | } | ||
| + | |||
| + | location ~ / | ||
| + | { | ||
| + | internal; | ||
| + | } | ||
| + | |||
| + | # | ||
| + | } | ||
| + | </ | ||
| + | === etc === | ||
| + | * version | ||
| + | <cli> | ||
| + | # sudo dpkg -l nginx | ||
| + | # nginx -v | ||
| + | </ | ||
| + | * /etc/nginx/ | ||
| + | <cli> | ||
| + | # sudo find / -name nginx.conf | ||
| + | </ | ||
| + | * test | ||
| + | <cli> | ||
| + | # netstat -lntp | ||
| + | </ | ||
| + | * if netstat doesn' | ||
| + | <cli> | ||
| + | # sudo apt install net-tools | ||
| + | </ | ||
| + | |||
| + | * force ssl | ||
| + | <sxh title:/ | ||
| + | # / | ||
| + | |||
| + | location ^~ / | ||
| + | allow all; | ||
| + | root / | ||
| + | default_type " | ||
| + | try_files $uri =404; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <sxh title:/ | ||
| + | server { | ||
| + | listen 80; | ||
| + | server_name wiki.theta5912.com; | ||
| + | #root / | ||
| + | |||
| + | include snippets/ | ||
| + | return 301 https:// | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | # listen 80; | ||
| + | listen 443 ssl; | ||
| + | listen [::]:443 ssl; | ||
| + | |||
| + | server_name wiki.theta5912.com; | ||
| + | # ssl on; | ||
| + | |||
| + | ssl_certificate / | ||
| + | ssl_certificate_key / | ||
| + | |||
| + | root / | ||
| + | index index.php index.html index.html; | ||
| + | |||
| + | location / { | ||
| + | try_files $uri $uri/ @dokuwiki; | ||
| + | } | ||
| + | |||
| + | location @dokuwiki { | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | rewrite ^/ | ||
| + | rewrite ^/(.*) / | ||
| + | } | ||
| + | |||
| + | location ~ \.php$ { | ||
| + | # Caution: be sure the php7.2-fpm.sock matches your version | ||
| + | include snippets/ | ||
| + | fastcgi_pass unix:/ | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | include fastcgi_params; | ||
| + | } | ||
| + | |||
| + | location ~ / | ||
| + | deny all; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | | ||
| + | </ | ||
| + | |||
| ==== < | ==== < | ||
| Line 346: | Line 501: | ||
| RewriteEngine On | RewriteEngine On | ||
| RewriteCond %{HTTPS} off | RewriteCond %{HTTPS} off | ||
| - | | + | |
| </ | </ | ||
| </ | </ | ||