#nginx服务器的安装
wget http://nginx.org/download/nginx-1.10.0.tar.gz
tar -xvf nginx-1.10.0.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar -xvf ngx_cache_purge-2.3.tar.gz
groupadd -r nginx
adduser -r -d /var/cache/nginx -s /sbin/nologin -g nginx nginx
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
PRGDIR=`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.3
make
sudo make install
rm -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/
问题:
操作make时
./configure
yum -y install gcc
make: *** 没有规则可以创建“default”需要的目标“build”。 停止。
yum install pcre*
nginx -t
可以查看nginx服务器的配置文件的语法是否正确,
也可以看到nginx配置文件的地址。
nginx -c nginx.conf 指定配置文件的地址
nginx -s reload 重启nginx服务器,在修改了配置文件之后。
nginx -s stop 停止nginx服务器
nginx -s start 启动nginx服务器
nginx 配置文件
#声明用户为nobody
user 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
安装配置redis
sudo groupadd -r redis
sudo adduser -r -s /sbin/nologin -g redis redis
mkdir -p /opt/redis/db
chown -R redis:redis /opt/redis
cd ~
wget http://download.redis.io/releases/redis-3.2.2.tar.gz
tar -xzvf redis-3.2.2.tar.gz
cd redis-3.2.2
make
sudo make install
sudo mkdir -p /usr/local/etc/redis
sudo 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.conf
nohup redis-server /usr/local/etc/redis/redis.conf &
验证,查看redis的进程
ps -ef | grep redis
#前台部署
- build构建html页面
- 将build下面的html页面复制出来
- 将公共的pub里面的html页面cp替换服务器上面的文件
###ps: 可能出现的问题
Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)