Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP7 .htaccess #149

Closed
ghost opened this issue Jan 4, 2017 · 16 comments
Closed

PHP7 .htaccess #149

ghost opened this issue Jan 4, 2017 · 16 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 4, 2017

the .htaccess file should also include directives for mod_php7.c

<IfModule mod_php7.c>
@colinmollenhour
Copy link
Member

I would prefer to just remove <IfModule mod_php5.c> instead of duplicate. If PHP isn't present then you've got major problems and probably don't want your webserver starting anyway and AFAIK all mod_php5 directives are compatible with all mod_php7 directives.

@ghost
Copy link
Author

ghost commented Jan 4, 2017

Removing the <IfModule mod_php5.c> may cause issues with apache+fastcgi. I don't use fastcgi myself so I can't say for certain, but from what I've read using php_value in .htaccess without mod_php causes a 500 error. See http://stackoverflow.com/questions/4117572/using-htaccess-with-fastcgi#4118492

@colinmollenhour
Copy link
Member

Ehh, what a mess. Here is a possible hack:

<IfModule mod_php5.c>
// Set doPhp = 1
</IfModule>
<IfModule mod_php7.c>
// Set doPhp = 1
</IfModule>
<If doPhp>
// php flags here
</If>

I don't know the exact syntax to use offhand though, perhaps SetEnv.

@ghost
Copy link
Author

ghost commented Jan 5, 2017

Yup. I came across this earlier, although it's only supported with apache 2.4. Can we drop support for older versions of apache?

<IfModule mod_php5.c>
    Define PHP_IS_ENABLED
</IfModule>

<IfModule mod_php7.c>
    Define PHP_IS_ENABLED
</IfModule>

<IfDefine PHP_IS_ENABLED>
</IfDefine>

Otherwise I'm just inclined to add a comment to the htaccess noting about PHP7, but I did have a few hours of wondering why my PHP's max memory wasn't being read before I realized the php5 bit. Fixing this would definitely help out people down the line.

@sreichel sreichel added the PHP7 label Jan 11, 2018
@seansan
Copy link
Contributor

seansan commented Sep 5, 2018

@jtnw Any thoughts on this? Or has this been solved?

@ghost
Copy link
Author

ghost commented Sep 5, 2018

@seansan for me, I just changed php5 to php7 in htaccess, haven’t touched it in the past year.

Apache 2.4 came out in 2012, so the Define directive should be widely supported. I would recommend we use the structure in my previous comment.

@seansan
Copy link
Contributor

seansan commented Sep 5, 2018 via email

@ghost
Copy link
Author

ghost commented Sep 5, 2018

Sure thing, let me just do a quick test to make sure that the directive works.

@Flyingmana
Copy link
Contributor

Flyingmana commented Sep 5, 2018

actually, Apache is kind of recommending to stop using mod_php https://wiki.apache.org/httpd/php and instead use the fcgi solutions.

Besides, everybody should get used to set php settings via the php.ini

@ghost
Copy link
Author

ghost commented Sep 5, 2018

Also, it seems that the Define directive cannot be used in .htaccess. I am trying this solution as well, but it doesn't seem to work for me: https://stackoverflow.com/a/49031283

Edit: so basically it means the Define solution would mean the user would have to edit the httpd.conf file to set the define which is much more confusing for a user.

@ghost
Copy link
Author

ghost commented Sep 5, 2018

I think the only solution right now is to duplicate the directives and put a comment in htaccess explaining it. Seems like mod_php shouldn't be used, but many people will keep using it and those htaccess settings for php are important. If there's another way I'm all ears though.

@ghost ghost mentioned this issue Sep 5, 2018
@Flyingmana
Copy link
Contributor

with mod_php you can use a php.ini like with php-fpm and php-cli
Every non-apache user is already doing this, and you need to put most of this settings anyway also for cli.

regarding the settings.

setting .htaccess php default comment
memory_limit 256M 128M is actually set higher in most environments I know
max_execution_time 18000 30 thats 5hours!!!, for cli it should be unlimited, for webserver this is cazy high
magic_quotes_gpc off off
session.auto_start off off
suhosin.session.cryptua off off
zend.ze1_compatibility_mode off off

@ghost
Copy link
Author

ghost commented Sep 5, 2018

@Flyingmana does the custom php.ini file require editing vhosts/httpd.conf though? Some users won't be able to edit those files if they're on shared hosting of any sort.

@Flyingmana
Copy link
Contributor

@jtnw I would refer to the documentation/faq/support of the shared hosting then. Also shared hostings likely would not allow to change memory_limit or max_execution_time in any way.

If people notice specific problems with the Environment, they would need to know where to change this settings anyway. And for people not used to apache, it could be confusing to change a setting, and wonder why it is overwritten somewhere else.

@ghost
Copy link
Author

ghost commented Sep 5, 2018

@Flyingmana good points, my only other reservation on making users edit httpd.conf is that it's a departure from the upstream installation process where users just have to extract to htdocs. However if there's a much better solution than my PR above which was just a quick fix, we should take it.

@colinmollenhour
Copy link
Member

Closed by #1001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants