In the process of learning nginx, the default.conf file in the conf.d directory cannot be found after installing nginx. The reason is that the EPEL source under the operating system is downloaded by default, which is the Fedora operating system
Scheme I
resolvent
Reinstall nginx and modify the EPEL image source address of nginx
Reinstall
sudo yum install yum-utils
Create a new nginx.repo file
sudo vim /etc/yum.repos.d/nginx.repo
add to
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
By default, a stable repository of nginx packages is used. If you want to use the mainline nginx package, run the following command:
sudo yum-config-manager --enable nginx-mainline
Installing nginx
sudo yum install nginx
This is the information I found on the Internet. I see that many people have handled this problem according to this scheme, but like me, there is still no default.conf file under scheme 1 conf.d, so you can try the second method.
Scheme II
Because the default.conf itself is a configuration file, my idea is to directly create one since there is no one, and see if it works. So I created an empty file with VI default.conf, and then found the contents of the default.conf file on the Internet and put it in.
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /mystatus {
stub_status;
}
location/{
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 404 /50x.html;//Modify the 404 status code of the corresponding pointed to the access directory, and restart the server after modification.
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Finally, we changed the configuration according to the project requirements we deployed. Let’s also start nginx to have a look. We can see that there is no error after starting nginx, and we can also see the process of nginx, which shows that this method is feasible and simpler than scheme 1.
Read More:
- Nginx Error: Swap file “/etc/nginx/.nginx.conf.swp“ already exists
- Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:
- [Solved] keystone Install Error: Failed to parse /etc/keystone/keystone.conf: at /etc/keystone/keystone.conf:687
- [Solved] nginx: [error] open() “/usr/local/nginx/nginx.pid” failed (2: No such file or directory)
- [Solved] Nginx Restart Error: /run/nginx.pid failed (2: No such file or directory)
- ./ungrib.exe Start Error: Could not Fould libpng16.so.16 (/etc/ld.so.conf and ldconfig)
- [Realtek sdk-4.4.1] RTL8198D How to Fix pptp/l2tp HW checksum error issue
- Nginx error: nginx: [error] invalid PID number ““ in “/run/nginx.pid“
- Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]
- Solve the problem of 404 Not Found error in nginx accessing dynamic interface
- Nginx Startup Error: Job for nginx.service failed because the control process exited with error code
- Common configuration methods of nginx
- How to fix the ERROR: Failed to build gem native extension in Centos 8
- Nginx Error: [emerg] bind() to [::]:80 failed (98: Address already in use)
- How to Solve Error: “Hdaudio hdaudioc0d2: unable to bind codec”
- Nginx realizes the same background service for portal and business
- [Solved] Nginx Startup Error: directive is not allowed here in
- How to Fix Ubuntu(Linux) mount error(22)
- [Ubuntu] How to Solve dpkg Error: dpkg: error: failed to open package info file ‘/usr/local/var/lib/dpkg/status’ for reading: No such file or directory
- [Solved] Cannot run program “svn” (in directory “D: xxxx”): CreateProcess error=2, the system cannot find the specified file.