没有不值得去解决的问题,也没有不值得去学习的技术!

How to Remove the Default Virtual Host in LNMP 2.1

The process of removing the default virtual host in LNMP 2.1. Checking the directory, only .user.ini remains in /home/wwwroot/default; the other files have already been manually deleted.

1. The process of removing the default virtual host in LNMP 2.1. Checking the directory, only .user.ini remains in /home/wwwroot/default; the other files have already been manually deleted. See Figure 1.

The process of removing the default virtual host in LNMP 2.1. Checking the directory, only .user.ini remains in /home/wwwroot/default; the other files have already been manually deleted.
Figure 1
Plaintext

[root@iZ2zeaj7tnbv8d3gsoy1w5Z wwwroot]# cd default/
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# ls -la
total 4
drwxr-xr-x 2 www  www  23 Mar  8 19:17 .
drwxr-xr-x 4 root root 32 Mar  8 16:57 ..
-rw-r--r-- 1 root root 48 Mar  8 16:43 .user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# pwd
/home/wwwroot/default
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]#


2. Reference: LNMP add, delete virtual host and pseudo-static usage tutorial https://lnmp.org/faq/lnmp-vhost-add-howto.html . However, the default virtual host does not exist. See Figure 2.

Reference: LNMP add, delete virtual host and pseudo-static usage tutorial https://lnmp.org/faq/lnmp-vhost-add-howto.html . However, the default virtual host does not exist.
Figure 2
Plaintext

[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# lnmp vhost list
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Nginx Virtualhost list:
objectapi.ikhw.cn
object.ikhw.cn


3. Although the file /usr/local/nginx/conf/nginx.conf exists and contains server server_name _; root /home/wwwroot/default; . I decided to remove the configuration related to this server. See Figure 3.

Although the file /usr/local/nginx/conf/nginx.conf exists and contains server server_name _; root /home/wwwroot/default; . I decided to remove the configuration related to this server.
Figure 3

4. The .user.ini file cannot be modified directly. To modify or delete it, you must first run: chattr -i /home/wwwroot/default/.user.ini . Then rm -f /home/wwwroot/default/.user.ini will work. See Figure 4.

The .user.ini file cannot be modified directly. To modify or delete it, you must first run: chattr -i /home/wwwroot/default/.user.ini . Then rm -f /home/wwwroot/default/.user.ini will work.
Figure 4
Plaintext

[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# chattr -i /home/wwwroot/default/.user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# ls -la
total 4
drwxr-xr-x 2 www  www  23 Mar  8 19:17 .
drwxr-xr-x 4 root root 32 Mar  8 16:57 ..
-rw-r--r-- 1 root root 48 Mar  8 16:43 .user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# rm -f /home/wwwroot/default/.user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# ls -la
total 0
drwxr-xr-x 2 www  www   6 Mar 18 10:41 .
drwxr-xr-x 4 root root 32 Mar  8 16:57 ..
[root@iZ2zeaj7tnbv8d3gsoy1w5Z default]# cd ..
[root@iZ2zeaj7tnbv8d3gsoy1w5Z wwwroot]# ls -l
total 0
drwxr-xr-x 2 www  www   6 Mar 18 10:41 default
drwxr-xr-x 4 root root 64 Mar 11 14:56 object
[root@iZ2zeaj7tnbv8d3gsoy1w5Z wwwroot]# rm -rf default/
[root@iZ2zeaj7tnbv8d3gsoy1w5Z wwwroot]# ls -la
total 0
drwxr-xr-x  3 root root 17 Mar 18 10:42 .
drwxr-xr-x. 5 root root 47 Mar  8 16:43 ..
drwxr-xr-x  4 root root 64 Mar 11 14:56 object


5. Run lnmp nginx reload to reload the Nginx configuration.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系