完全卸載nginx以及安裝的超詳細(xì)步驟
前言
在開局配置Nginx時(shí)有可能會(huì)配置錯(cuò)誤,報(bào)各種錯(cuò)誤代碼??床欢蛘邞械萌タ催@個(gè)報(bào)錯(cuò)時(shí),其實(shí)最簡單的方式是卸載并重裝咯。今天就帶大家一起學(xué)習(xí)下,如何徹底卸載nginx程序。
一、卸載NGINX
卸載nginx程序的詳細(xì)步驟
1、停止Nginx軟件
/usr/local/nginx/sbin/nginx -s stop
如果不知道nginx安裝路徑,可以通過執(zhí)行ps命令找到nginx程序的PID,然后kill其PID
2、查找根下所有名字包含nginx的文件
find / -name nginx
3、執(zhí)行命令 rm -rf *刪除nignx安裝的相關(guān)文件
說明:全局查找往往會(huì)查出很多相關(guān)文件,但是前綴基本都是相同,后面不同的部分可以用*代替,以便快速刪除~
[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、其他設(shè)置
如果設(shè)置了Nginx開機(jī)自啟動(dòng)的話,可能還需要下面兩步
chkconfig nginx off
rm -rf /etc/init.d/nginx
刪除之后,便可重新安裝nginx了
二、開始安裝NGINX
a、安裝所需插件
1、安裝gcc
gcc是linux下的編譯器在此不多做解釋,感興趣的小伙伴可以去查一下相關(guān)資料,它可以編譯 C,C++,Ada,Object C和Java等語言
命令:查看gcc版本
gcc -v
一般阿里云的centOS7里面是都有的,沒有安裝的話會(huì)提示命令找不到,
安裝命令:
yum -y install gcc
2、pcre、pcre-devel安裝
pcre是一個(gè)perl庫,包括perl兼容的正則表達(dá)式庫,nginx的http模塊使用pcre來解析正則表達(dá)式,所以需要安裝pcre庫。
安裝命令:
yum install -y pcre pcre-devel
3、zlib安裝
zlib庫提供了很多種壓縮和解壓縮方式nginx使用zlib對(duì)http包的內(nèi)容進(jìn)行g(shù)zip,所以需要安裝
安裝命令:
yum install -y zlib zlib-devel
4、安裝openssl
openssl是web安全通信的基石,沒有openssl,可以說我們的信息都是在裸奔。。。。。。
安裝命令:
yum install -y openssl openssl-devel
b、安裝nginx
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/下面
執(zhí)行三個(gè)命令:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make make install
4、切換到/usr/local/nginx安裝目錄
5、配置nginx的配置文件nginx.conf文件,主要也就是端口
#user nobody; 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; #} } }
可以按照自己服務(wù)器的端口使用情況來進(jìn)行配置
ESC鍵,wq!強(qiáng)制保存并退出
6、啟動(dòng)nginx服務(wù)
切換目錄到/usr/local/nginx/sbin下面
啟動(dòng)nginx命令:
./nginx
8、訪問你的服務(wù)器IP
顯示
說明安裝和配置都沒問題OK了
9、nginx常用命令
1.啟動(dòng)nginx命點(diǎn):./nginx
2.重啟nginx命令:./nginx -s reload
3. 停止 nginx 命令: ./nginx -s stop 或 ./nginx -s quit
4. 關(guān)閉nginx進(jìn)程:
ps -ef|grep nginx
命令 kill -9 8725 (進(jìn)程號(hào) 上面的) 則關(guān)閉nginx
總結(jié)
到此這篇關(guān)于完全卸載nginx以及安裝的文章就介紹到這了,更多相關(guān)完全卸載及安裝nginx內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Kubernetes中Nginx服務(wù)啟動(dòng)失敗排查流程分析(Error:?ImagePullBackOff)
這篇文章主要介紹了Kubernetes中Nginx服務(wù)啟動(dòng)失敗排查流程(Error:?ImagePullBackOff),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03Nginx七層負(fù)載均衡之動(dòng)靜分離思路詳解
Nginx動(dòng)靜分離簡單來說就是把動(dòng)態(tài)跟靜態(tài)請求分開,不能理解成只是單純的把動(dòng)態(tài)頁面和靜態(tài)頁面屋里分離,這篇文章主要介紹了Nginx七層負(fù)載均衡之動(dòng)靜分離思路詳解,需要的朋友可以參考下2024-02-02Nginx服務(wù)器中414錯(cuò)誤和504錯(cuò)誤的配置解決方法
這篇文章主要介紹了Nginx服務(wù)器中414錯(cuò)誤和504錯(cuò)誤的配置解決方法,分別對(duì)應(yīng)Request-URI Too Large和Gateway Time-out這樣的錯(cuò)誤提示,需要的朋友可以參考下2015-12-12