04-nginx服务器的安装,redis安装,前端部署

来源:互联网 发布:老人坐便椅子淘宝网 编辑:程序博客网 时间:2024/05/17 00:09

nginx服务器的安装

    wget http://nginx.org/download/nginx-1.10.0.tar.gztar -xvf nginx-1.10.0.tar.gzwget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gztar -xvf ngx_cache_purge-2.3.tar.gzgroupadd -r nginxadduser -r -d /var/cache/nginx -s /sbin/nologin -g nginx nginxyum -y install zlib zlib-devel openssl openssl-devel pcre pcre-develPRGDIR=`pwd`cd nginx-1.10.0./configure \--prefix=/etc/nginx \--sbin-path=/usr/sbin/nginx \--modules-path=/usr/lib/nginx/modules \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/run/nginx.pid \--lock-path=/run/nginx.lock \--http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-threads \--with-stream \--with-stream_ssl_module \--with-http_slice_module \--with-mail \--with-mail_ssl_module \--with-file-aio \--with-http_v2_module \--with-ipv6 \--add-module=$PRGDIR/ngx_cache_purge-2.3makesudo make installrm -rf /etc/nginx/html/mkdir -p /etc/nginx/conf.d/ /usr/share/nginx/html/install -m644 html/index.html /usr/share/nginx/html/install -m644 html/50x.html /usr/share/nginx/html/

nginx -t
可以查看nginx服务器的配置文件的语法是否正确,
也可以看到nginx配置文件的地址。

nginx -c nginx.conf 指定配置文件的地址

nginx -s reload 重启nginx服务器,在修改了配置文件之后。
nginx -s stop 停止nginx服务器
nginx -s start 启动nginx服务器

nginx 配置文件

  #声明用户为nobodyuser nobody;#开启nginx工作进程数,一般为1#可以通过ps -ef | grep nginx 查看到有4个工作进程worker_processes 4;#设置并发数events{        #设置最大并发数        worker_connections 1024;}http{    upstream bro-prj{         server  localhost:8080;    } include       mime.types;    default_type  application/octet-stream;    server {     listen       80;    server_name  118.190.159.49;    charset utf-8;    proxy_set_header Host $host:$server_port;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    location = / {        root   /opt/bro-prj/www;        index  index.html index.htm;    }    location = /index {        root          /opt/bro-prj/www;        rewrite ^(.*) /;    }    location ~ .*\.(html)$ {        root   /opt/bro-prj/www;        index  index.html index.htm;    }    location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|woff|woff2|svg|ttf)$ {        root   /opt/bro-prj/www;        index  index.html index.htm;    }    location ~ .*(css)$ {        root   /opt/bro-prj/www;        index  index.html index.htm;    }    location ~ /script/(user|role|syslog|wordbooks)\.js$ {        proxy_pass http://bro-prj;        proxy_set_header Host $host:$server_port;    }    location = /script/wordbooks.js {        proxy_pass http://bro-prj;        proxy_set_header Host $host:$server_port;    }    location / {        proxy_pass http://bro-prj;        proxy_set_header Host $host:$server_port;    }}}

安装redis

安装gcc

yum -y install gcc gcc-c++ kernel-devel

    安装配置redissudo groupadd -r redissudo adduser -r -s /sbin/nologin -g redis redismkdir -p /opt/redis/dbchown -R redis:redis /opt/rediscd ~wget http://download.redis.io/releases/redis-3.2.2.tar.gztar -xzvf redis-3.2.2.tar.gzcd redis-3.2.2makesudo make installsudo mkdir -p /usr/local/etc/redissudo cp redis.conf /usr/local/etc/redis/ipaddr=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -E '^(192|172|10)\.'`sudo sed -i "s/bind 127.0.0.1/bind 127.0.0.1 $ipaddr/" /usr/local/etc/redis/redis.confnohup redis-server /usr/local/etc/redis/redis.conf &

验证,查看redis的进程
ps -ef | grep redis

前台部署

  1. build构建html页面
  2. 将build下面的html页面复制出来
  3. 将公共的pub里面的html页面cp替换服务器上面的文件

ps: 可能出现的问题

Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)


去掉rel=”stylesheet”
再还原一下,当时就是这样解决的,也不知道是什么原因呢。