
基于Ubuntu安装Nginx服务器,并部署可视化大屏
仅供自己记录所用。
·
仅供自己记录所用
1. 安装与配置Nginx
apt-get install nginx
安装完成后修改配置文件,目的是定义访问网址、端口号、项目存储路径。
nginx配置文件: /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml #application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 8085; #访问的端口号。
server_name xinke902.bigScreen.com;
#root /usr/share/nginx/html; #默认的位置,现修改为自定的存放路径,这里的路径默
#认都是在根目录下开始的,先cd /再执行相应的操作
root /nginx_xinke902/myEcharts; #可以将项目放到该路径下
}
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
其中相对于原始代码,增加了以下内容:
server {
listen 8085; #访问的端口号。
server_name xinke902.bigScreen.com;
#root /usr/share/nginx/html; #默认的位置,现修改为自定的存放路径,这里的路径默
#认都是在根目录下开始的,先cd /再执行相应的操作
root /nginx_xinke902/myEcharts; #可以将项目放到该路径下
}
2. 修改/etc/hosts 文件
增加代码: 192.168.223.136 xinke902.bigScreen.com
作用是给IP地址取别名。
127.0.0.1 localhost
127.0.1.1 ubuntu
192.168.223.136 xinke902.bigScreen.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
3. 上传项目
项目存放路径:按照nginx.conf文件中的server 里面提到的 root 所对应的路径
root /nginx_xinke902/myEcharts; #可以将项目放到该路径下
4. 启动项目
最后打开网址就可以查看前端网页。
更多推荐
所有评论(0)