Mastering Nginx: A Beginner's Guide to High-Performance Web Servers

5. Verifying the Installation and Basic Operations

Section 5

Getting Started: Installation and Basic Configuration

Mastering Nginx: A Beginner's Guide to High-Performance Web ServersGetting Started: Installation and Basic Configuration

Congratulations! You've successfully installed Nginx. Now, let's make sure everything is working as expected and explore some fundamental operations. This section will guide you through verifying your installation and performing basic checks to ensure your Nginx server is up and running.

The first and most crucial step is to check if the Nginx process is running. You can do this using your system's service management tools. The specific command might vary slightly depending on your operating system (e.g., systemctl on modern Linux distributions, service on older ones, or even launchctl on macOS).

sudo systemctl status nginx

If Nginx is running correctly, you should see output indicating its active status. Look for lines like 'Active: active (running)' or similar. If it's not running, you'll typically see 'inactive (dead)' or an error message. In that case, you can try starting it with sudo systemctl start nginx.

Next, we'll verify that Nginx is listening on its default port, which is port 80 for HTTP. This confirms that the web server is ready to accept incoming connections.

sudo netstat -tulnp | grep nginx

This command will show you network connections. You should see a line indicating that Nginx is listening on port 80 (often displayed as 0.0.0.0:80 or :::80). The -tulnp flags ensure we see TCP listening ports, numeric addresses, and the associated process name.

The most direct way to confirm your Nginx installation is to visit it from your web browser. Open your browser and navigate to your server's IP address or hostname. If you're running Nginx on your local machine, you can usually use http://localhost or http://127.0.0.1.

チャプターへ戻る