新起点
保持持续运行
之前的代码都是通过node xxxx.js
来运行,一旦关闭了命令行窗口,程序就终止了;
现在将观察怎么样才可以让程序在关闭命令行窗口后仍然运行。
- 安装forever
sudo npm install -g forever
forever start xxx.js
//当想要关闭时
forever stop index.js
完善模板
发现了一些新问题,所以在展开网站的内容之前,添加一些常识性的笔记
发现了好玩的nginx 有了nginx之后,forever start xxx.js 就没用了
简单的操作
1、如何修改mysql的Root密码
1 mysqladmin -uroot -p123456 password 123
OR
2 set password for root@localhost = password('Yannian002.');
2、怎么登陆和退出MySQL
mysql -u root -p
3、nginx的故障
[emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)问题
当出现这个错误时,意味着80端口被占用。
方法:
fuser -k 80/tcp
将进程杀死后,启动nginx。
4、设置nginx开机启动
systemctl enable nginx.service
5、配置nginx文件
外网用户访问服务器的 Web 服务由 Nginx 提供,Nginx 需要配置静态资源的路径信息才能通过 url 正确访问到服务器上的静态资源。打开 Nginx 的默认配置文件 /etc/nginx/nginx.conf ,修改 Nginx 配置,将默认的 root/usr/share/nginx/html; 修改为: /root/Nicolas_Web; 如下:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /data/www;
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
阅读之后发现:
/usr/share/nginx/html
这个是ngix安装好只会放主页的默认路径
打开这个html文件之后看到的是:
扫描二维码关注公众号,回复:
8547758 查看本文章
[root@10-255-20-136 html]# ls
404.html 50x.html en-US icons img index.html nginx-logo.png poweredby.png
是储存nginx网站的文件夹