3

Okay, I used to use apache - I've now moved over to nginx and I love it, but when it comes to my .htaccess values, I'm completely and utterly stuck.

I have this htaccess file:

php_value auto_prepend_file Resources/Core.php
php_value short_open_tag On

I'm not entirely sure how I can replicate this in nginx. I know I can use the global php.ini file, but I don't want to have it on all the virtual hosts, only one of them.

Thanks, Tom

1 Answer 1

8

Actually Tom, NGINX does not consider directory overrides.

You can however change the settings in the virtual hosts settings as:

location ~ \.php$ {
        expires off;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www//httpdocs/$fastcgi_script_name;
        fastcgi_param  PHP_VALUE   "auto_prepend_file=/var/www/your_folder/Resources/Core.php";
    }

the settings file will be found at '/etc/nginx/sites-available' in a default installation in a Linux server, change and restart NGINX

Sign up to request clarification or add additional context in comments.

7 Comments

I'm confused to why you're using fastcgi_param SCRIPT_FILENAME /var/www//httpdocs/$fastcgi_script_name; as that folder doesn't exist for me. :/
Dear @TomDoyle, I have mentioned default folders, you are free to edit it according to your needs. What's important to you is: fastcgi_param PHP_VALUE. Enjoy!
Huh, I did what you told me and now I'm uh, getting a No input file specified. message.
Did you change 'your_folder' to match your actual file system folder path?
Okay, it's all in and working but for some weird reason, no PHP errors are showing up! D:
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.