安裝nginx
1.用yum安裝,執(zhí)行命令:
yum install -y nginx
2.默認(rèn)安裝路徑是:
/usr/sbin/nginx
3.默認(rèn)配置路徑是:
/etc/nginx
4.自定義nacos配置(mynacos.conf):
[root@localhost conf.d]# ls
default.conf mynacos.conf
upstream cluster{
server 192.168.128.30:8848;
server 192.168.128.21:8848;
server 192.168.128.22:8848;
}
server {
listen 80;
server_name dhgate.nacos.internal;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
proxy_pass http://cluster;
}
}
啟動nginx
1.先查看nginx是否啟動服務(wù)(現(xiàn)在是啟動后樣子,如果啟動了,就不需要下面的操作了):
[root@localhost conf.d]# ps -ef | grep "nginx"
root 5353 1 0 11:11 ? 00:00:00 nginx: master process nginx
nginx 5354 5353 0 11:11 ? 00:00:00 nginx: worker process
root 5461 5265 0 11:16 pts/0 00:00:00 grep --color=auto nginx
2.先查詢nginx的安裝目錄:
[root@localhost local]# which nginx
/usr/sbin/nginx
or (whereis 包含安裝 和 配置路徑)
[root@localhost conf.d]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
3.查詢nginx配置文件目錄:
[root@localhost conf.d]# find /|grep nginx.conf
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/mynacos.conf
/etc/nginx/nginx.conf
/etc/nginx/nginx.conf.bak
4.啟動nginx命令:
nginx -c /etc/nginx/nginx.conf