完全卸载nginx及安装的详细步骤

芝士年糕
• 阅读 385

前言

在开局配置Nginx时有可能会配置错误,报各种错误代码。看不懂或者懒得去看这个报错时,其实最简单的方式是卸载并重装咯。今天就带大家一起学习下,如何彻底卸载nginx程序。

一、卸载NGINX 卸载nginx程序的详细步骤

1、停止Nginx软件

/usr/local/nginx/sbin/nginx -s stop 如果不知道nginx安装路径,可以通过执行ps命令找到nginx程序的PID,然后kill其PID

完全卸载nginx及安装的详细步骤

2、查找根下所有名字包含nginx的文件 find / -name nginx

完全卸载nginx及安装的详细步骤

3、执行命令 rm -rf *删除nignx安装的相关文件

说明:全局查找往往会查出很多相关文件,但是前缀基本都是相同,后面不同的部分可以用*代替,以便快速删除~

[root@qll251 ~]# rm -rf /usr/local/sbin/nginx [root@qll251 ~]# rm -rf /usr/local/nginx [root@qll251 ~]# rm -rf /usr/src/nginx-1.11.1 [root@qll251 ~]# rm -rf /var/spool/mail/nginx 4、其他设置

如果设置了Nginx开机自启动的话,可能还需要下面两步

chkconfig nginx off

rm -rf /etc/init.d/nginx

删除之后,便可重新安装nginx了

二、开始安装NGINX a、安装所需插件 1、安装gcc gcc是linux下的编译器在此不多做解释,感兴趣的小伙伴可以去查一下相关资料,它可以编译 C,C++,Ada,Object C和Java等语言

命令:查看gcc版本

gcc -v

完全卸载nginx及安装的详细步骤

一般阿里云的centOS7里面是都有的,没有安装的话会提示命令找不到,

安装命令:

yum -y install gcc 2、pcre、pcre-devel安装 pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式,所以需要安装pcre库。

安装命令:

yum install -y pcre pcre-devel

完全卸载nginx及安装的详细步骤

3、zlib安装 zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip,所以需要安装

安装命令:

yum install -y zlib zlib-devel 4、安装openssl openssl是web安全通信的基石,没有openssl,可以说我们的信息都是在裸奔。。。。。。

安装命令:

yum install -y openssl openssl-devel b、安装nginx 我的环境是使用3A服务器安装的centos7 1、下载nginx安装包 wget http://nginx.org/download/nginx-1.9.9.tar.gz

2、把压缩包解压到usr/local/java tar -zxvf nginx-1.9.9.tar.gz 3、切换到cd /usr/local/java/nginx-1.9.9/下面 执行三个命令:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

make

make install 4、切换到/usr/local/nginx安装目录

完全卸载nginx及安装的详细步骤

5、配置nginx的配置文件nginx.conf文件,主要也就是端口

worker_processes  4;
worker_rlimit_nofile 65535;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  65535;
    #use epoll;
    #accept_mutex off;
    #multi_accept off;
}


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;
    #tcp_nodelay    on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #send_timeout 10s;
    #types_hash_max_size 2048;
    #client_header_buffer_size 4k;
    #client_max_body_size 8m;

    proxy_connect_timeout 300;
    proxy_send_timeout 300;
    proxy_read_timeout 300;
    proxy_buffer_size 64k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;

    #gzip  on;

    upstream test123456 {
        ip_hash;
        server 192.168.0.192:8081;
        server 192.168.0.144:8081;
        server 192.168.0.203:8081;
    }

    upstream testjk123456 {
        #ip_hash;
        server 192.168.0.192:8081;
        server 192.168.0.144:8081;
        server 192.168.0.203:8081;
    }




    # 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;
    #    }
    #}

    server {
        listen       443 ssl;
        server_name  test.jjtech.cn;
        ssl_certificate      /usr/local/java/ng.crt;
        ssl_certificate_key  /usr/local/java//ng.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        #ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!MD5:!DSS:!EXP:!ADH:!LOW:!MEDIUM;
        proxy_ssl_server_name on;

        #charset koi8-r;
        charset utf-8;

        #access_log  logs/host.access.log  main;
        #rewrite ^(.*)$ https://${server_name}$1 permanent;

        location /h5 {
            root   /usr/local/java;
            index  index.html index.htm;
        }

        location ~ ^/h5.*\.(css|jpeg|jpg|gif|js)$ {
            root   /usr/local/java;
        }


        location /bz {
            proxy_pass http://test123456/;
            proxy_send_timeout 18000;
            proxy_read_timeout 18000;
            proxy_connect_timeout 18000;

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection  "upgrade";

        }

        location /api {
            proxy_pass http://testjk123456/;
            proxy_send_timeout 18000;
            proxy_read_timeout 18000;
            proxy_connect_timeout 18000;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection  "upgrade";
        }

        location / {
           proxy_pass http://test123456/$request_uri;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection  "upgrade";
         }

         location /apilogin {
           proxy_pass http://test123456/$request_uri;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection  "upgrade";
         }




        #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;
        #}
    }

}

可以按照自己服务器的端口使用情况来进行配置 ESC键,wq!强制保存并退出 6、启动nginx服务 切换目录到/usr/local/nginx/sbin下面 完全卸载nginx及安装的详细步骤

启动nginx命令: ./nginx 7、访问你的服务器IP 显示

完全卸载nginx及安装的详细步骤

说明安装和配置都没问题OK了

8、nginx常用命令 1.启动nginx命点:./nginx 2.重启nginx命令:./nginx -s reload

  1. 停止 nginx 命令: ./nginx -s stop 或 ./nginx -s quit
  2. 关闭nginx进程:

ps -ef|grep nginx

命令 kill -9 8725 (进程号 上面的) 则关闭nginx

点赞
收藏
评论区
推荐文章
芝士年糕 芝士年糕
1年前
nginx 启动、停止、关闭
使用3A服务器搭建的centos系统安装nginx教程在我的往期博客中1,nginx指定配置文件/usr/local/nginx/sbin/nginxc/usr/local/nginx/conf/nginx.conf1c参数指定了要加载的nginx配置文件路径1,从容停止Nginx:killQUIT主进程号2,快速停止Nginx:kil
DevOpSec DevOpSec
3年前
NGINX的 IF AND 和 OR
if的逻辑用法什么是逻辑用法呢,就程序中的and、or关系,就叫做逻辑了.NGINX支持if的and与or或者&&与||吗?答案是No.当你尝试这样配置,重载nginx时,nginx会报出错误location/test/{default_typetext/html;
Stella981 Stella981
2年前
Nginx配置https
一、开启nginx的ssl模块1.未安装过nginx,编译安装配置参数如下:./configure\prefix/usr/local/nginx\withpcre\withhttp\_ssl\_modulessl模块\withhttp\_stub\_status\_module\wit
Stella981 Stella981
2年前
Linux 安装配置JDK 、 MySQL 、nginx
    今天我来讲一下在Linux下各环境的搭建,主要就讲一下jdk、MySQL、和一个代理服务器nginx1、jdk的安装配置   1)卸载自带openjdk     当我们拿到一个全新的ECS的时候上面有的会自带一个openjdk,但是我们一般不会用这个,所以在这里我们会先卸载这个自带的jdk   
Wesley13 Wesley13
2年前
LNMP架构中常见的502错误
1.配置错误因为nginx找不到phpfpm了,所以报错,一般是fastcgi\_pass后面的路径配置错误了,后面可以是socket或者是ip:port2.资源耗尽lnmp架构在处理php时,nginx直接调取后端的phpfpm服务,如果nginx的请求量偏高,我们又没有给phpfpm配置足够的子进程,那
Stella981 Stella981
2年前
Nginx 模块分类
L:34!(https://oscimg.oschina.net/oscnet/3f218ca9379733d571a853b919759402668.png) 我们进入Nginx安装目录来查看上述模块的位置在src目录下每个模块对应的文件夹如下 /usr/local/nginx/nginx1.14.2/srcro
Stella981 Stella981
2年前
Mac OS X 10.15 编译和安装 Nginx
想在自己电脑里装个Nginx来进行各种测试,下面是详细的过程记录:1\.下载软件首先建个临时目录nginxsrc并下载所需软件的源码进行配置mkdirnginxsrccdnginxsrcwgethttp://nginx.org/download/nginx1.17.8.tar.gz
Stella981 Stella981
2年前
Nginx SSL补充安装
在centos中,配置nginx的https时,出现如下错误。nginx:\emerg\unknowndirective"ssl"in/usr/local/nginx/conf/nginx.conf:102,说明编译是没有启用SSL。到解压的nginx目录下./configurewith
Stella981 Stella981
2年前
Nginx之使用nginx搭建简单的文件服务器
  使用nginx可以搭建简单文件服务器  安装nginx(不详述)    修改配置文件/usr/local/nginx/conf/nginx.confuserroot;worker_processes1;error_loglogs/error.log;pidlog
Wesley13 Wesley13
2年前
nginx配置虚拟主机相关教程
1.配置虚拟主机配置虚拟主机即:在一台服务器上启动多个网站;区分不同的网站方式:域名不同,端口不同;1.1通过端口区分虚拟主机1.1.1server节点的介绍nginx的配置文件路径:/usr/local/nginx/conf/nginx.conf一个se