public:computer:oracle_cloud

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:computer:oracle_cloud [2021/08/19 20:21] – [Let's Encrypt 클라이언트 Certbot 설치] alexpublic:computer:oracle_cloud [2022/04/01 11:04] (current) – [Nginx] alex
Line 146: Line 146:
 $ sudo systemctl restart apache2 $ sudo systemctl restart apache2
 </cli> </cli>
 +
 +==== Nginx ====
 +=== Update apt ===
 +<cli>
 +# sudo apt update && sudo apt upgrade -y
 +</cli>
 +
 +=== Install Nginx ===
 +<cli>
 +# sudo apt install nginx
 +</cli>
 +
 +=== Execute Nginx ===
 +<cli>
 +# sudo systemctl start nginx
 +# sudo systemctl status nginx
 +</cli>
 +
 +=== Troubleshootings on nginx ===
 +  * Job for nginx.service failed because the control process exited with error code
 +<cli>
 +# sudo systemctl status nginx.service
 +</cli>
 +
 +  * stop apache2 when running
 +<cli>
 +# sudo /etc/init.d/apache2 stop
 +</cli>
 +
 +<cli>
 +# sudo fuser -k 80/tcp
 +</cli>
 +
 +  * create .conf file: /etc/nginx/conf.d/xxx.xxx.xxx.conf
 +<sxh>
 +server 
 +{
 +  #server_name example.com; 
 +  root /var/www/dokuwiki; 
 +  index index.php; 
 +
 +  location / { try_files $uri $uri/ @dokuwiki; } 
 +
 +  location @dokuwiki 
 +  { 
 +    rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; 
 +    rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; 
 +    rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; 
 +    rewrite ^/(.*) /doku.php?id=$1&$args last; 
 +  } 
 +
 +  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:/var/run/php/php7.4-fpm.sock; 
 +  } 
 +
 +  location ~ /(conf|bin|inc|vendor)/ 
 +  { 
 +    deny all; 
 +  } 
 +
 +  location ~ /data/ 
 +  { 
 +    internal; 
 +  } 
 +
 +  #fastcgi_param HTTPS on; 
 +}
 +</sxh>
 +=== etc ===
 +  * version
 +<cli>
 +# sudo dpkg -l nginx
 +# nginx -v
 +</cli>
 +  * /etc/nginx/
 +<cli>
 +# sudo find / -name nginx.conf
 +</cli>
 +  * test
 +<cli>
 +# netstat -lntp
 +</cli>
 +  * if netstat doesn't exist
 +<cli>
 +# sudo apt install net-tools
 +</cli>
 +
 +  * force ssl
 +<sxh title:/etc/nginx/snippets/letsencrypt.conf>
 +# /etc/nginx/snippets/letsencrypt.conf
 +
 +location ^~ /.well-known/acme-challenge/ {
 +  allow all;
 +  root /var/lib/letsencrypt/;
 +  default_type "text/plain";
 +  try_files $uri =404;
 +}
 +</sxh>
 +
 +<sxh title:/etc/nginx/sites-availabe/default>
 +server {
 +    listen 80;
 +    server_name wiki.theta5912.com;
 +    #root /var/www/dokuwiki;
 +
 +    include snippets/letsencrypt.conf;
 +    return 301 https://$host$request_uri;
 +}
 +
 +server {
 +#    listen 80;
 +    listen 443 ssl;
 +    listen [::]:443 ssl;
 +
 +    server_name wiki.theta5912.com;
 +#    ssl on;
 +
 +    ssl_certificate /etc/letsencrypt/live/wiki.theta5912.com/fullchain.pem;
 +    ssl_certificate_key /etc/letsencrypt/live/wiki.theta5912.com/privkey.pem;
 +
 +    root /var/www/dokuwiki;
 +    index index.php index.html index.html;
 +
 +    location / {
 +        try_files $uri $uri/ @dokuwiki;
 +    }
 +
 +    location @dokuwiki {
 +        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
 +        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
 +        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
 +        rewrite ^/(.*) /doku.php?id=$1&$args last;
 +    }
 +
 +    location ~ \.php$ {
 +        # Caution: be sure the php7.2-fpm.sock matches your version
 +        include snippets/fastcgi-php.conf;
 +        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
 +        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 +        include fastcgi_params;
 +    }
 +
 +    location ~ /(data|conf|bin|inc|vender)/ {
 +        deny all;
 +    }
 +
 +}
 +                        
 +</sxh>
 +
 ==== <del>MySQL</del> mariaDB ==== ==== <del>MySQL</del> mariaDB ====
  
Line 346: Line 501:
     RewriteEngine On     RewriteEngine On
     RewriteCond %{HTTPS} off     RewriteCond %{HTTPS} off
-    RewriteRult .* __ BROKEN-LINK:https://%{SERVER_NAME}%{REQUEST_URI}LINK-BROKEN__ [R,L]+    RewriteRule .* __ BROKEN-LINK:https://%{SERVER_NAME}%{REQUEST_URI}LINK-BROKEN__ [R,L]
   </IfModule>   </IfModule>
 </VirtualHost> </VirtualHost>
  • public/computer/oracle_cloud.1629372081.txt.gz
  • Last modified: 2021/08/19 20:21
  • by alex