Do I need to prepare two identical php projects and put them in the working directories of php and nginx respectively?
I only put the php project in the php container. I did not put it in the nginx working directory. Now I can only Access php files but cannot access html files
nginx configuration can specify the php directory, just specify it in a location.
No, just point the nginx configuration directory to your project path
First of all, the files that nginx will execute through your access can be specified in the conf of nginx;
Secondly, you can make a link on the server;
Thirdly, you can change two identical files, as long as the server The space format above is large enough
When configuring nginx, you can specify the file directory where the project is located, as shown in the following root path.
server
nginx There are many ways to use PHP, such as fastcgi. Remember to use the root + try_files mechanism to configure static files.
For a little more fun, you can use symbolic links to make two paths point to the same directory.
If you use Docker, you can use Volume, put the file in Volume, and then mount this Volume in both Nginx and PHP containers. Isn’t that enough?
Multiple containers are best managed using Docker Compose, where you can specify the name of each container, such as Nginx and PHP. This will be much more convenient.
What is the php directory? I only know nginx’s
root
Configuring the web directory