Nginx - bigktmbig/MyExperienceAlgorithm GitHub Wiki

setup nodejs project 1.nginx config: server { listen 80; server_name domain.com; location / { proxy_pass http://domain.com:3000; } }

  1. run cmd: sudo setenforce 0, sudo systemctl restart nginx, , sudo systemctl enable nginx

Run nodejs app via pm2

***require: root permission npm install pm2 -g pm2 start npm --name="react" -- start pm2 start npm --name="webrtc" -- start

Note: name không được trùng nhau!

Detect init system, generate and configure pm2 boot on startup

pm2 startup

Save current process list

pm2 save

====================================== ***require: root permission apt-get update apt-get install php apt-get install mysql-server apt-get install php-mysql apt-get install php-mbstring apt-get install php-xml apt-get install zip unzip apt-get install nginx

====================================== ***require: root permission apt-get install nodejs apt-get install npm apt-get install composer

====================================== setup adminer and config nginx htpassword: ***require: root permission

--download adminer-- mkdir /var/www/html/adminer sudo wget "http://www.adminer.org/latest.php" -O /var/www/html/adminer/index.php (<== don't forget this directive)

--config nginx-- touch /etc/nginx/sites-enabled/adminer.conf nano /etc/nginx/sites-enabled/adminer.conf

--Copy and paste this and save-- server { listen 80; #Your port, 443 use with ssl. server_name db.example.com adminer.example.com; # Your domain, multiple. root /var/www/html/adminer/; # adminer directive.

location / {
    index index.php adminer.php; # Index (run this file), multiple.
    try_files $uri $uri/ /index.php?$query_string;
}

# PHP (google -> copy -> paste :v)
location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; # Where your php-ftp in. (php < 7 is differen)
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}

# Config asscess password
auth_basic "Restricted"; # For Basic Auth
auth_basic_user_file /var/www/html/adminer/.htpasswd; # For Basic Auth
# Next step: make .htpasswd file.

}

--make .htpasswd file-- apt-get install apache2-utils htpasswd -c /var/www/html/adminer/.htpasswd [your-user] And input your password.

--test and reload nginx- test: nginx -t if test ok, reload: nginx -s reload