参考网站 http://www.runoob.com/nodejs/nodejs-http-server.html https://github.com/nodesource/distributions #安装 curl -sL https://rpm.nodesource.com/setup_6.x | bash - yum install -y nodejs #查看版本 node --version #查看安装路径 rpm -qa 'node|npm' rpm -ql nodejs-6.11.2-1nodesource.el6.x86_64 npm -v #编辑服务文件 vim server.js [root@bj default]# cat server.js var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World '); }).listen(8080); console.log('Server running at http://0.0.0.0:8080/'); #运行 node server.js #访问 http://0.0.0.0:8080/
yum -y install -y zlib* zlib-devl* openssl openssl-devel pcre* wget http://nginx.org/download/nginx-1.10.3.tar.gz tar -xf nginx-1.10.3.tar.gz;cd nginx-1.10.3 ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-cc-opt=-O3 --with-stream echo $? make echo $? make install echo $? useradd nginx -s /sbin/nologin -M
user nginx nginx; worker_processes 4; error_log logs/error.log crit; pid logs/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 256; client_header_buffer_size 64k; large_client_header_buffers 4 64k; client_max_body_size 80m; sendfile on; tcp_nopush on; keepalive_timeout 120; send_timeout 360; proxy_ignore_client_abort on; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_buffer_size 512k; proxy_buffers 16 512k; charset utf-8; gzip on; gzip_types text/plain application/x-javascript text/css application/xml; gzip_static on; gzip_min_length 1k; gzip_buffers 4 32k; gzip_http_version 1.0; gzip_proxied any; gzip_disable "MSIE [1-6]."; gzip_comp_level 6; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; ssi on; ssi_silent_errors off; ssi_types text/shtml; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; log_format main '$time_iso8601 $remote_addr $query_string'; log_format normal '$remote_addr - $remote_user $time_iso8601 "$request_method $scheme://$host$request_uri $server_protocol" ' '$status $bytes_sent $request_length "$http_referer" "$http_user_agent" ' '"$http_x_forwarded_for" $request_time $upstream_response_time'; log_format logstash_json '{ "log_time": "$time_local", ' '"remote_addr": "$remote_addr", ' '"remote_user": "$remote_user", ' '"body_bytes_sent": "$body_bytes_sent", ' '"request_time": "$request_time", ' '"status": "$status", ' '"request": "$request", ' '"request_method": "$request_method", ' '"http_referrer": "$http_referer", ' '"body_bytes_sent":"$body_bytes_sent", ' '"http_x_forwarded_for": "$http_x_forwarded_for", ' '"http_user_agent": "$http_user_agent" } '; include vhost/*.conf; access_log logs/access.log normal; }