簡(jiǎn)介:
nginx是一款輕量級(jí)web服務(wù)器,也是一款反向代理服務(wù)器(作為http的反向代理服務(wù)器)
安裝(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進(jìn)入目錄
cd nginx-1.12.2執(zhí)行(root下執(zhí)行)
sudo ./configure執(zhí)行
sudo make安裝
sudo make install查找
whereis nginx進(jìn)入安裝目錄
cd /usr/local/nginx
cd sbin/
./nginx查看進(jìn)程
ps -aux | grep nginx打開防火墻(打開相應(yīng)端口)
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload進(jìn)入目錄
cd /usr/local/nginx/
cd conf
創(chuàng)建文件夾
sudo mkdir vhost修改文件
sudo vim nginx.conf
增加一行(在https server上面一行)
include vhost/*.conf;局域網(wǎng)修改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
- 進(jìn)入目錄
cd vhost/
創(chuàng)建文件
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 *;
}
}