Home > Article > Operation and Maintenance > What is the method to solve nginx pointing to local path and 500 error?
A vite vue3 project that I want to deploy to the server. The files after the project is built are all in the dist directory. Copy this directory to the server, and then configure it in nginx, as follows:
server { listen 3571; server_name localhost; location / { root /root/xxxx/dist/; try_files $uri $uri/ /index.html; } }
In this way, you can access this vue through the server's public IP port 3571 If you want to access the project through the domain name, you can configure it like this:
server { listen 80; server_name video.xxx.com; location / { root /root/xxxx/dist/; try_files $uri $uri/ /index.html; } }
In this way, you can directly access the vue project by accessing video.xxx.com directly.
Note that there may be a problem here, that is, a 500 error occurs during access after the configuration is correct. If you encounter this error, first check whether the local path is set correctly. If the path is correct, there may be a permission problem. The nginx user will be configured at the beginning of nginx, as follows:
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; ...
My default is the nginx user, so there is no permission to access the /root/xxxx/dist/ directory, so a 500 error occurs, change to root Users can do this, as follows:
user root; worker_processes auto; error_log /var/log/nginx/error.log; ...
Note: After reconfiguring nginx, you need to restart the nginx service (service nginx restart).
The above is the detailed content of What is the method to solve nginx pointing to local path and 500 error?. For more information, please follow other related articles on the PHP Chinese website!