[root@yfs01 nginx]# ./sbin/nginx -c nginx.conf nginx: [emerg] open() "/usr/local/nginx/nginx.conf" failed (2: No such file or directory)文件不存在怎么解决
时间: 2023-08-15 19:26:37 浏览: 191
这个错误提示是因为 Nginx 没有找到指定的配置文件。请确认您的 Nginx 安装目录下是否存在 `nginx.conf` 文件。如果不存在,您可以从 Nginx 官网下载一个示例配置文件,并将其保存为 `nginx.conf`。如果已经存在 `nginx.conf` 文件,您可以尝试指定绝对路径启动 Nginx,如下所示:
```
./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
```
其中,`/usr/local/nginx/conf/nginx.conf` 是您的 Nginx 配置文件的绝对路径,您需要根据实际情况替换为正确的路径。
相关问题
配置nginx路径时出现以下错误该怎么解决 [root@yfs01 nginx]# --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module -bash: --error-log-path=/var/log/nginx/error.log: 没有那个文件或目录 [root@yfs01 nginx]# --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy -bash: --http-client-body-temp-path=/var/temp/nginx/client: 没有那个文件或目录 [root@yfs01 nginx]# --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --conf-path=/usr/local/nginx/nginx.conf
这个问题是因为您在执行配置 `./configure` 命令时,没有将配置选项和 `./configure` 命令分开。请在执行 `./configure` 命令之前将配置选项和命令分开,例如:
```
./configure --prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--conf-path=/usr/local/nginx/nginx.conf
```
这样,您就可以通过单独的行来设置每个配置选项,而不会出现 `-bash: --error-log-path=/var/log/nginx/error.log: 没有那个文件或目录` 这样的错误信息。
配置nginx 路径时,出现这个错误该怎么解决?[root@yfs01 nginx]# --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module -bash: --error-log-path=/var/log/nginx/error.log: 没有那个文件或目录 [root@yfs01 nginx]# --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy -bash: --http-client-body-temp-path=/var/temp/nginx/client: 没有那个文件或目录 [root@yfs01 nginx]# --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --conf-path=/usr/local/nginx/nginx.conf
这个错误是因为您在命令行中输入了配置选项,但是缺少了nginx的可执行文件路径,您需要在命令行中添加nginx的可执行文件路径,例如:
```
/usr/local/nginx/sbin/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --conf-path=/usr/local/nginx/nginx.conf
```
请注意,上述命令中的`/usr/local/nginx/sbin/nginx`是您的nginx可执行文件路径。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)