nginx重定向网站目录到wordpress没找到DocumentRoot路径

硬件:树莓派4B 4GB

系统:Raspberry Pi OS (bullseye)

在尝试按照这篇博客配置树莓派服务器时,发现一处地方有不同,特此补充。

在将nginx重定向网站目录到wordpress时,原文中需要更改地方为:

(文件路径:/etc/nginx/sites-enabled/default)
DocumentRoot /var/www/xxxx (xxx为要修改的地方,此处改好后为wordpress)

但如果安装了sql7.4,该文件出现的内容可能如下

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html index.php;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	#
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
		fastcgi_pass unix:/run/php/php7.4-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen [::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

如果出现的是这段内容,我们只需要将以下语句

root /var/www/html;

修改为:

root /var/www/wordpress;

即可。

相关推荐

  1. Cordova WebView定向网站

    2024-02-19 18:24:01       46 阅读
  2. 使用 Nginx 将 HTTP 定向 HTTPS

    2024-02-19 18:24:01       51 阅读
  3. Nginx 中将 HTTP 定向 HTTPS

    2024-02-19 18:24:01       41 阅读
  4. Nginx定向

    2024-02-19 18:24:01       26 阅读
  5. nginx定向

    2024-02-19 18:24:01       28 阅读
  6. Nginx定向

    2024-02-19 18:24:01       27 阅读
  7. wordpress301定向传权

    2024-02-19 18:24:01       50 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-19 18:24:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-19 18:24:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-19 18:24:01       87 阅读
  4. Python语言-面向对象

    2024-02-19 18:24:01       96 阅读

热门阅读

  1. html5播放 m3u8

    2024-02-19 18:24:01       49 阅读
  2. Leetcode-1041. 困于环中的机器人

    2024-02-19 18:24:01       49 阅读
  3. Hexo删除主题

    2024-02-19 18:24:01       41 阅读
  4. 深度学习的进展

    2024-02-19 18:24:01       48 阅读
  5. devc++跑酷小游戏3.0.0 Dev-c++跑酷小游戏 1.0.0

    2024-02-19 18:24:01       45 阅读
  6. sql语句创建数据库

    2024-02-19 18:24:01       54 阅读
  7. 如何优雅地与ChatGPT对话?

    2024-02-19 18:24:01       62 阅读
  8. 数据结构三要素

    2024-02-19 18:24:01       42 阅读