Nginx path lookup:

1. Check the nginx installation directory for Linux

Enter commands in the shell

ps -ef | grep nginx

Returns the result

root 4593 1 0 Jan23 ? 00:00:00 nginx: master process /usr/sbin/nginx

2. View the directory of the nginx.conf configuration file

Enter commands in the shell

nginx -t

Returns the result

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

3. Start the nginx service

Type the command

Nginx installation directory -c nginx.conf configuration file directory

The -c parameter specifies the path to the configuration file. If the -c parameter is not specified, Nginx loads the nginx.conf file in the conf subdirectory of the installation directory by default.

Started making

  1. Pull the mirror

    docker pull nginx

Create a directory

Create a directory for storing files so we can make changes

mkdir -p /everything/nginx/conf /everything/nginx/html
Copy the code

Creating a Configuration File

Create a configuration file in the directory we created

touch /everything/nginx/conf/nginx.conf
Copy the code

Modifying a Configuration File

Change the nginx.conf file in the directory we created to the following

Worker_processes 1 worker_processes 1 worker_processes 1 worker_processes 1

{worker_connections 1024; worker_connections 1024; }

HTTP {default_type application/octet-stream;

# sendFile: sendFile on; #keepalive_timeout Keepalive_timeout 65; Server {# listen 80; #server_name localhost; Location / {root /usr/share/nginx/ HTML; index index.html; }}Copy the code

}

Create an HTML

Create index. HTML in the /everything/nginx/ HTML directory

touch /everything/nginx/index.html
Copy the code

Content for the index.html

I am index. The HTML…

Start the container

docker run --name nginx01 -p 80:80 -v /everything/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /everything/nginx/html:/usr/share/nginx/html --restart always -d nginx
Copy the code

Access to 127.0.0.1