Notice

: Function WP_Styles::add was called incorrectly. The style with the handle "hello-elementor-child-style" was enqueued with dependencies that are not registered: hello-elementor-theme-style. Please see Debugging in WordPress for more information. (This message was added in version 6.9.1.) in /home/csrkub/domains/cube-vps.com/public_html/wp-includes/functions.php on line 6131

Notice: Function WP_Scripts::add was called incorrectly. The script with the handle "gpress-custom-js" was enqueued with dependencies that are not registered: gpress-siema. Please see Debugging in WordPress for more information. (This message was added in version 6.9.1.) in /home/csrkub/domains/cube-vps.com/public_html/wp-includes/functions.php on line 6131

*Cube-Host– full cloud services!!

Installing and configuring Nginx on VPS

Installing and configuring Nginx on VPS

Preparation

  • VPS with Ubuntu 20.04/22.04/24.04 or Debian 11/12.
  • User with sudo, SSH access.
  • Domain (for HTTPS) and open ports 80/443 in the provider’s panel.

Installing Nginx and quick check


					
				

VPS

We expect 200 OK headers. The Nginx start page is usually located in /var/www/html/.

We allow HTTP/HTTPS in UFW and check the service.


					
				

VPS

If UFW is not used, ensure that 80/443 are open in the cloud firewall/provider panel.

Create a site directory and test page


					
				

VPS

We recommend a separate directory for each domain: /var/www/<domain>/html.

Create a server block (site configuration)

File /etc/nginx/sites-available/example.com:


					
				

VPS

We turn on the website, check the syntax, and reload it.


					
				

VPS

If nginx -t displays errors, correct the configuration (root path, domain names, closing brackets, etc.).

Gzip and basic security headers

Create the file /etc/nginx/conf.d/optimizations.conf:


					
				

Restart the config:


					
				

VPS

For production, consider CSP/Permissions-Policy — but test step by step so as not to “miss” the front end.

HTTPS in 2 minutes (Let’s Encrypt)


					
				

VPS

Certbot will write a 301 redirect to HTTPS and create a job for auto-renewal. Check https://example.com.

PHP-FPM support (optional)

Install FPM and connect it to Nginx:


					
				

In the site configuration (/etc/nginx/sites-available/example.com), add the following block:


					
				

We check and reread:


					
				

VPS

To verify, create /var/www/example.com/html/info.php with <?php phpinfo(); ?>, open it in a browser, and then delete the file.

Logs and quick problem analysis

  • Errors: /var/log/nginx/error.log
  • Access: /var/log/nginx/access.log
  • Quickly view the last lines: sudo tail -n 200 /var/log/nginx/error.log

Check units and ports:


					
				

Pre-launch checklist

  • Site directory created, owner/rights are correct.
  • Server block config saved, nginx -t — OK.
  • HTTP/HTTPS open in UFW/firewall.
  • Gzip and basic security headers enabled.
  • HTTPS issued by Let’s Encrypt, auto-update enabled.
  • (If PHP is required) — PHP-FPM connected, info.php removed.

Briefly for AlmaLinux/Rocky/CentOS (RHEL family)


					
				

Table of Contents

 

Prev