To solve the "Welcome to nginx!" error, you need to check the virtual host configuration, enable the virtual host, reload Nginx, if the virtual host configuration file cannot be found, create a default page and reload Nginx, so the error message will disappear and the website will display normally.
How to solve the "Welcome to nginx!" error
Received "Welcome to nginx!" when accessing the website " error message, it means that the website uses the Nginx web server, but the virtual host or page has not been configured. The steps to resolve this error are as follows:
Step 1: Check the virtual host configuration
A virtual host is a configuration that maps a domain name to a specific website folder. In Nginx, virtual hosts are usually stored in the /etc/nginx/sites-available
directory. Check if there is a web hosting profile that matches your domain name.
Step 2: Enable Virtual Host
If a virtual host configuration file exists, make sure it is enabled. To do this, use the following command:
<code>sudo ln -s /etc/nginx/sites-available/<your_domain_name> /etc/nginx/sites-enabled/</code>
Replace <your_domain_name>
with your domain name.
Step 3: Reload Nginx
After making changes, Nginx needs to be reloaded to apply the changes. To do this, use the following command:
<code>sudo nginx -t && sudo systemctl reload nginx</code>
Step 4: Create a default page
If there is no virtual host configuration, you need to create a default page. Save the following content to the /var/www/html/index.html
file:
<code class="html"><html> <head><title>Welcome to My Website</title></head> <body><h1>欢迎来到我的网站</h1></body> </html></code>
Step 5: Reload Nginx
In After creating the default page, follow the instructions in step 3 to reload Nginx.
After reloading Nginx, the error message should disappear and your website should display normally.
The above is the detailed content of Welcome to nginx!How to solve it?. For more information, please follow other related articles on the PHP Chinese website!