skip to Main Content

I’m trying to improve the installation documentation of some open source software, but I’ve hit a snag with the web server configuration. I have this software working well with Apache, but I need to use Nginx in the documentation for consistency. How can I get the same results in Nginx with this Apache configuration?

<VirtualHost *:80>
        ServerName example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/publisher/public

        <Directory /var/www/publisher/public>
                AllowOverride None
                Order Allow,Deny
                Allow from All
                Header set Access-Control-Allow-Origin http://example2.com

                <IfModule mod_rewrite.c>
                    Options -MultiViews
                    RewriteEngine On
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteRule ^(.*)$ index.php [QSA,L]
                </IfModule>
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

2

Answers


  1. Chosen as BEST ANSWER

    I used this documentation page to get the correct base configuration for Nginx, as this particular project uses Symfony:

    https://symfony.com/doc/current/setup/web_server_configuration.html#nginx

    As noted there, I needed to set fastcgi_pass to 127.0.0.1:9000 to match my PHP-FPM config.


  2. You can use online tools like for the quick convert

    still, you need to look for missing keys, here is a basic convert:

    server_name example.com;
    root /var/www/publisher/public;
    error_log ${APACHE_LOG_DIR}/error.log;
    
    location / {
      if (!-e $request_filename){
        rewrite ^(.*)$ /index.php break;
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search