Home >Operation and Maintenance >Nginx >How to solve nginx error when using rewrite

How to solve nginx error when using rewrite

WBOY
WBOYforward
2023-05-14 20:52:041574browse

Problem Description

Since my English is not very good, I looked at the help document and found one that starts with without and one that starts with disable. I added the module that starts with without without thinking, and the nightmare began. .

How to solve nginx error when using rewrite

# When I configured the file, I was still full of confidence./sbin/nginx -t Check the syntax, eh? An error was reported. As expected, it might be that the configuration there was wrong. But when I checked it over and over again, I started to panic.

How to solve nginx error when using rewrite

Cause analysis:

First of all, according to the prompts, we know that nginx cannot parse rewrite (unknown command "rewrite"), I think it should The module is not installed, or its dependencies pcre and pcre-devel are not installed (you can also check these two dependencies when troubleshooting). Then I checked the dependencies (Figure 1). It does seem like there is no problem, everything that needs to be installed is installed. I knew it must be a compilation or dependency problem, so I opened Baidu.

How to solve nginx error when using rewrite

Solution:

Then I found this sentence. Compiling nginx with default parameters will support the rewrite module. Then I suddenly remembered what without means. Could it be that I turned off the rewrite function? Then I compiled and installed it directly without adding any parameters. Sure enough, it was successful!

How to solve nginx error when using rewrite

In the "./configure" configuration, "--with" means enabling modules, which means that these modules will not be automatically built when compiling"- -without" means disabling modules, which means these modules will be automatically built during compilation. If you want Nginx to run lightweight, you can remove some unnecessary modules.

The above is the detailed content of How to solve nginx error when using rewrite. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete