# обновляемся
sudo apt-get update
# ставим нужные пакеты
sudo apt-get install build-essential libssl-dev
# ставим nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
source ~/.profile
# смотрим список доступных версий ноды
nvm ls-remote
# ставим нужную
nvm install <version>
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
})
"http:\/\/web\.archive\.org\/web\/[0-9]+\/([^"]+)"
// search pattern"$1"
// replace pattern#!/bin/bash
#
DB_USER=root
DB_PASSWORD=root
DB_HOST=localhost
NOW=$(date +"%d-%m-%Y")
DUMP_FOLDER=${PWD}/dump/${NOW}
[ -d ${DUMP_FOLDER} ] || mkdir -p ${DUMP_FOLDER}
DB_LIST=$(echo "SHOW DATABASES WHERE \`database\` != 'mysql' AND \`database\` != 'phpmyadmin' AND \`database\` NOT LIKE '%_schema';" | mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD})
for DB_NAME in $DB_LIST
do
if [ ${DB_NAME} != 'Database' ];then
DB_FOLDER=${DUMP_FOLDER}/${DB_NAME}
[ -d ${DB_FOLDER} ] || mkdir -p ${DB_FOLDER}
TABLE_LIST=$(echo "USE ${DB_NAME};SELECT \`table_name\` FROM information_schema.tables WHERE \`table_schema\` = '${DB_NAME}' AND \`table_name\` NOT LIKE 'Tables_in%';" | mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD})
for TABLE_NAME in $TABLE_LIST
do
if [ ${TABLE_NAME} != 'table_name' ]; then
mysqldump --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} -B ${DB_NAME} --tables ${TABLE_NAME} > ${DB_FOLDER}/${TABLE_NAME}.sql
fi
done
fi
done
var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 15,
host: 'localhost',
database: 'node',
user: 'node',
password: '123'
});
var Tasks = {
list: function(callback){
pool.getConnection(function(err, connection) {
connection.query(
'SELECT * FROM tasks',
function(err, rows) {
connection.release();
callback(rows);
});
});
},
edit: function(){}
};
module.exports = Tasks;
var tasks = require('./tasks');
tasks.list(function(list){
console.log(list);
});
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
sendfile on;
access_log /root/projects/logs/domen.ru/access.log;
error_log /root/projects/logs/domen.ru/error.log crit;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
server {
listen 80;
server_name domen.ru www.domen.ru;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name domen.ru www.domen.ru;
keepalive_timeout 60;
keepalive_requests 50;
ssl_certificate /root/domen.ru.ssl/domen.ru.crt;
ssl_certificate_key /root/domen.ru.ssl/domen.ru.key;
ssl_session_cache shared:SSL:30m;
ssl_session_timeout 1h;
ssl_stapling on;
resolver 8.8.8.8;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
ssl_dhparam /root/domen.ru.ssl/domen.ru.dh4096.pem;
add_header Strict-Transport-Security 'max-age=604800';
location / {
proxy_pass http://localhost:8080;
#proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
proxy_buffer_size 128k;
proxy_buffers 32 128k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
}
}
}