Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure the php.ini on vagrant homestead

I want to allow short_open_tags in php.ini

I want to access to the php.ini on my vagrant box configured with homestead. I saw the php.ini file in /etc/php5/fpm/php.ini

But ... permission denied Is somebody knows ?

Thanks

like image 913
Thibault Van Campenhoudt Avatar asked Feb 02 '15 10:02

Thibault Van Campenhoudt


People also ask

How do I change PHP version to Homestead?

As a slightly simpler alternative to update-alternatives --config php you can enter the PHP version you want on the command line with a syntax of php71 where 7 is the major version and 1 the minor version. For example to switch to PHP 7.1 from another version simply type php71 .

What is Homestead PHP?

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. Vagrant provides a simple, elegant way to manage and provision Virtual Machines.

Where is PHP INI in laravel?

php. ini is in xampp/php if you are using Windows. It doesn't reside inside Laravel apps. @Sarout php.


4 Answers

Here is how you grant read/write access to php.ini, modify it, save changes & reload nginx:

1. Navigate to folder containing php.ini: $ cd /etc/php5/fpm

2. Grant read/write access: $ sudo chmod -R ugo+rw php.ini

3. Open php.ini: $ vim php.ini

4. Enter edit mode: $ i

5. Edit stuff

6. Exit edit mode: Press ESC

7. Save & close php.ini: $ :x!

7.1 OPTIONAL: Exit without saving: $ :q

8. Navigate to home (not sure if this is actually necessary): $ cd ~

9. Reload/Restart nginx: $ sudo nginx -s reload

10.1 Reload/Restart php: $ sudo service php5-fpm restart

10.2 If using PHP 7 then use $ sudo service php7.0-fpm restart (Thanks & Credit to Richard in comments).

11. ???

12. PROFIT! (or is that joke really too old?)

Here is a screenshot:

git bash showing php.ini before & after getting read/write access

Remember if you run $ vagrant provision, it'll reset all configuration files. Just so you know.

EDIT

Super useful to know. You can search in vim by exiting input mode, and type $ /post_max_size or whatever you want to find.

like image 187
MartinJH Avatar answered Oct 18 '22 03:10

MartinJH


Just create ".user.ini" file (.user.ini files) in public/

[PHP]
short_open_tag = On
like image 38
griba Avatar answered Oct 18 '22 03:10

griba


Simply ssh in to the homestead environment:

ssh homestead

Then become the superuser by typing:

sudo su

Then you will be able to edit your php.ini.

like image 3
Gareth Daine Avatar answered Oct 18 '22 03:10

Gareth Daine


I have tried to change the mentioned php.ini for over an hour.
I suggest to check first which php.ini is really loaded.
I have checked it with php -i.

In my case it was located in /etc/php/7.2/cli.

like image 3
Artur Smolen Avatar answered Oct 18 '22 03:10

Artur Smolen