负载均衡,反向代理
没有什么是加一层是解决不了,高性能的HTTP的反向代理服务器,
占用内存少,
登陆这个网站nginx.org
下载nginx
[root@localhost ~]# nginx
-bash: nginx: command not found
[root@localhost ~]# ls
anaconda-ks.cfg ifdemo.sh
apache-tomcat-9.0.7 javase8u211-later-archive-downloads.html
apache-tomcat-9.0.7.tar.gz jdk-8u181-linux-x64.tar.gz
docker lingluan
dockerfile myshell.sh
Dockerfile mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
dockerfile-cmd-entory nginx-1.18.0.tar.gz
dockerfile-cmd-test oper.sh
docker-test-volume preVar.sh
hava.java readme.txt
hellworld.sh --restart=alwys
hi.sh shcode
[root@localhost ~]# tar -zxvf nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
[root@localhost ~]# cd nginx-1.18.0
[root@localhost nginx-1.18.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
#进入cd nginx-1.18.0 ls 显示有哪些文件
[root@localhost nginx-1.18.0]# ./configure
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
#make install
、
[root@localhost nginx-1.18.0]# whereis nginx 查看nginx 的配置文件在哪里
nginx: /usr/local/nginx
[root@localhost nginx-1.18.0]# cd /usr/local/nginx/ 进入
[root@localhost nginx]# ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 15 22:57 conf
drwxr-xr-x. 2 root root 40 Sep 15 22:47 html
drwxr-xr-x. 2 root root 6 Sep 15 22:47 logs
drwxr-xr-x. 2 root root 36 Jan 10 22:18 sbin
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx nginx.old
[root@localhost sbin]# ./nginx开启nginx
[root@localhost sbin]# cd ..
[root@localhost nginx]# cd conf/进入配置文件文件夹
[root@localhost conf]# ls
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
koi-utf nginx.conf.default win-utf
[root@localhost conf]# cat nginx.conf 查看配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server { 端口是80
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
http://192.168.31.200:80查看是否可以访问,
不能访问,查看防火墙端口是否打开 云服务的80是否能打开,
nginx的常用命令
cd /usr/local/nginx/sbin
./nigix
./nginx -s stop
./nginx -s quit
./nginx -s reload 重新加载配置文件
ps aux|grep nginx 查看nginx 进程
[root@localhost conf]# vim nginx.conf
[root@localhost conf]# ./nginx -s reload
-bash: ./nginx: No such file or directory
[root@localhost conf]# ls
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
koi-utf nginx.conf.default win-utf
[root@localhost conf]# cd ..
[root@localhost nginx]# ./nginx -s reload
-bash: ./nginx: No such file or directory
[root@localhost nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ./nginx -s reload
[root@localhost sbin]#
网友评论