Home  >  Q&A  >  body text

In nginx + php environment, my php project must be placed in the nginx working directory and the php working directory. Isn’t this two copies?

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

漂亮男人漂亮男人2701 days ago808

reply all(7)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 13:18:04

    nginx configuration can specify the php directory, just specify it in a location.

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:18:04

    No, just point the nginx configuration directory to your project path

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:18:04

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:18:04

    When configuring nginx, you can specify the file directory where the project is located, as shown in the following root path.
    server

    {
        listen 80;
        server_name domainName;
        index index.html index.htm index.php;
        root  /path/to/your/project/;
    
    }

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:18:04

    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.

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:18:04

    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.

    reply
    0
  • 阿神

    阿神2017-05-16 13:18:04

    What is the php directory? I only know nginx’s rootConfiguring the web directory

    reply
    0
  • Cancelreply