简介:
nginx是一款轻量级web服务器,也是一款反向代理服务器(作为http的反向代理服务器)
安装(linux)
sudo yum install gcc-c++
sudo yum install pcre pcre-devel
sudo yum install zlib zlib-deve
sudo yum install openssl openssl-devel
查找nginx是否安装
find -name nginx解压(nginx.org下载)
tar -zxvf nginx-1.12.2.tar.gz进入目录
cd nginx-1.12.2执行(root下执行)
sudo ./configure执行
sudo make安装
sudo make install查找
whereis nginx进入安装目录
cd /usr/local/nginx
cd sbin/
./nginx查看进程
ps -aux | grep nginx打开防火墙(打开相应端口)
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload进入目录
cd /usr/local/nginx/
cd conf
创建文件夹
sudo mkdir vhost修改文件
sudo vim nginx.conf
增加一行(在https server上面一行)
include vhost/*.conf;局域网修改host模拟
sudo vim /etc/hosts
192.168.217.131 www.qinxianyun.com
192.168.217.131 image.qinxianyun.com
192.168.217.131 s.qinxianyun.com
- 进入目录
cd vhost/
创建文件
sudo vim www.qinxianyun.com.conf
server {
listen 80;
autoindex on;
server_name www.qinxianyun.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".[;'<>]." ){
return 404;
}
location / {
proxy_pass http://127.0.0.1:8080/;
add_header Access_Control-Allow_origin *;
}
}
重启
sudo ../../sbin/nginx -s reload新建文件
sudo vim image.qinxianyun.com.conf
server {
listen 80;
autoindex off;
server_name image.qinxianyun.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
location ~ /(mmall_felmall-admin_fe)/dist/view/* {
deny all;
}
location / {
root /usr/ftpfile/;
add_header Access-Control-Allow-Origin *;
}
}