当前位置:首页 > 行业动态 > 正文

nginx卸载重装配置没变

一、nginx卸载重装前的准备工作

在进行nginx卸载重装之前,我们需要做好以下几方面的准备工作:

1. 备份网站数据:在进行任何操作之前,我们都需要确保网站的数据已经备份,以防止在卸载和重装过程中出现数据丢失的问题。

2. 停止正在运行的nginx服务:在卸载和重装nginx之前,需要先停止正在运行的nginx服务,以免影响到其他程序的正常运行,可以使用以下命令来停止nginx服务:

sudo service nginx stop

3. 检查系统依赖:在卸载和重装nginx之前,需要检查系统中是否还有其他的软件包依赖于nginx,如果有,需要先卸载这些依赖,以免在重新安装nginx时出现问题,可以使用以下命令来查看系统中的软件包依赖:

dpkg --get-selections | grep nginx

4. 下载nginx安装包:在卸载和重装nginx之前,需要先从官方网站或者其他可信的来源下载最新版本的nginx安装包,可以使用以下命令来下载nginx安装包:

wget http://nginx.org/download/nginx-1.20.1.tar.gz

二、卸载nginx

1. 删除nginx安装目录:使用以下命令来删除已经安装的nginx目录:

sudo rm -rf /usr/local/nginx

2. 删除nginx配置文件:使用以下命令来删除已经安装的nginx配置文件:

sudo rm /etc/nginx/nginx.conf

3. 删除nginx相关文件:使用以下命令来删除与nginx相关的文件:

sudo rm /usr/local/nginx/sbin/nginx*
sudo rm /usr/local/nginx/conf/nginx*

4. 删除系统服务:使用以下命令来删除已经安装的nginx系统服务:

sudo apt-get remove --purge nginx-common libnginx-mod-http-ssl-module libnginx-mod-http-v2_6-module libnginx-mod-http-v2_7-module libnginx-mod-perl-module libnginx-mod-rtmp-module libnginx-mod-udp-module libnginx-mod-utils-curl libnginx-mod-utils-java libnginx-mod-xml2-utils
sudo apt-get autoremove
sudo apt-get autoclean

三、安装并启动nginx

1. 解压安装包:使用以下命令来解压刚刚下载的nginx安装包:

tar -zxvf nginx-1.20.1.tar.gz

2. 编译并安装:进入解压后的目录,执行以下命令来编译并安装nginx:

“`

cd nginx-1.20.1/src/configure && sudo make && sudo make install && sudo make test && sudo make install-libs && sudo make install-html && sudo make install-devel && sudo make install-openssl && sudo make install-pcre && sudo make install-libpcre && sudo make install-compat && sudo make install-ngx_http_geoip_module && sudo make install-ngx_http_image_filter_module && sudo make install-ngx_http_map_module && sudo make install-ngx_http_memcached_module && sudo make install-ngx_http_referer_module && sudo make install-ngx_http_stub_status_module && sudo make install-ngx_http_userid_module && sudo make install-ngx_http_xsltproc_module && sudo make install-ngx_http_zip_module && sudo make install-openresty && sudo make install-luajit && sudo make install-luac; sudo ldconfig; cd ../objs && sudo cp objs/server objs/geoip objs/imagefilter objs/map objs/memcached objs/referer objs/stubstatus objs/userid objs/xsltproc objs/zip openresty/luajit/luajit.so openresty/luajit/libluajit.a openresty/compat/libpcre.a openresty/compat/libpcre++.a openresty/compat/libpcrealt.a openresty/compat/libpcre2.a openresty/compat/libpcre2posix.a openresty/compat/libssp.a openresty/compat/libcrypt.a openresty/compat/libcrypto.a openresty/compat/zlib.a openresty/compat/libpng15.a openresty/compat/libjpeg8.a openresty/compat/libfreetype6.a openresty; sudo mkdir -p /usr/local/openresty; sudo mv openresty/* /usr/local/openresty; sudo chmod a+rx -R /usr/local; sudo chmod a+rx ???????????????????????????????; sudo chmod a+rx ????????????????????????; sudo chmod u+x *; sudo chmod u+x conf/*; sudo chmod u+x conf/*.conf; sudo chmod u+x conf/*.htm; sudo chmod u+x conf/*.html; sudo chmod u+x conf/*.js; sudo chmod u+x conf/*.php; sudo chmod u+x conf/*.py; sudo chmod u+x conf/*.txt; sudo chmod u+w conf/*; sudo chmod u+w conf/*.conf; sudo chmod u+w conf/*.htm; sudo chmod u+w conf/*.html; sudo chmod u+w conf/*.js; sudo chmod u+w conf/*.php; sudo chmod u+w conf/*.py; sudo chmod u+w conf/*.txt; sudo find var tmp logs etc !( -name ‘*’ ) > tmpfileslist; for file in `cat tmpfileslist` do if [ `echo $file | cut -b1` = “‘” ] then continue else echo “sudo chown root:root $file”; done; cat tmpfileslist | xargs sudo chgrp root:root; cat tmpfileslist | xargs sudo chmod g=u,o=g $file; cat tmpfileslist | xargs sudo chattr +i $file; find var tmp logs etc !( -name ‘*’ ) > tmpfileslist; for file in `cat tmpfileslist` do if [ `echo $file | cut -b1` = “‘” ] then continue else echo “sudo touch $file”; done; cat tmpfileslist | xargs sudo touch $file; find var tmp logs etc | sort | uniq > filestoinstall; for file in `cat filestoinstall` do if [ `echo $file | cut -b1` = “‘” ] then continue else echo “sudo mv $file $file”; done; find var tmp logs etc | sort | uniq > filestodelete; for file in `cat filestodelete` do if [ `echo $file | cut -b1` = “‘” ] then continue else echo “sudo del $file”; done; exit; cd ~; wget tar zxf openresty_VERSIONNUMBER_all.tar.gz; cd openresty_VERSIONNUMBER; export NGINXROOT=`pwd`export NGINXCONF=$NGINXROOT’conf’export NGINXDAILY=$NGINXROOT’logs’export NGINXBINDIR=$NGINXROOT’bin’export NGINXLIBDIR=$NGINXROOT’lib’export NGINXVARDIR=$NGINXROOT’var’export NGINXMANDIR=$NGINXROOT’man’export NGINXDOCDIR=$NGINXROOT’doc’export NGINXPKGCONFIGDIR=$NGINXROOT’pkgconfig’export NGINXPIDDIR=$NGINXROOT’pids’export NGINXRUNDIR=$NGINXROOT’run’export NGINXLOCKDIR=$NGINXROOT’lock’export NGINXHTTPDUSER=wwwmake all install clean test deps rewrite reload restart graceful shutdown reopen reload save config save config dirty force reload reloadsave load test check status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version updowndownupupcheck status version up

0