Does anyone know how to edit the mail setting in the php.ini file by using Vagrant.
so I would ssh in terminal like so:
cd myapp
vagrant ssh
then what>?
Depending on your box, it might be
sudo nano /etc/php5/apache2/php.ini
then adopt you changes and restart with
sudo service apache2 restart
Without knowing what specific setting you want and what you want it changed to, you could try adding a shell script to the end of your Vagrantfile (in the "Local Scripts" area) to do a search and replace on the ini file.
#!/usr/bin/env bash
sed -i.bak s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT_WITH/g /etc/php5/apache2/php.ini
Failing that, you can use ini_set in your project (preferably in a bootstrap) to change mail settings on a per-project basis.
In my case where I'm using scotchbox on vagrant, changing the php.ini file won't reflect changes in phpinfo() function output so I changed /etc/php5/apache2/conf.d/user.ini file which could be a bare file or a file with few lines declaring php error display, I add my configurations here e.g. upload_max_filesize = 64MSave the change and issue sudo service apache2 restart. Viewed the phpinfo page and I can see the updated filesize.
Related
Let's say I have a local apache2 and I need a script that runs the apache2 with a special injected VirtualHost.
More presice:
I have a xampp Installation (PHP 7.3.10, MariaDB 10.4.8, mysqlnd 5.0.12-dev, Apache 2.4.41) on Windows 10.
Several PHP projects are located all over the hard drive. Until now I modify the ./apache/conf/extra/httpd-vhosts.conf file before starting the apache2 service on every project switch. With that I can leave the project folders where there are without copying them in the xampp installation folder.
Now I am curious if I can write a script for each project (bat or sh, GitShell is installed) that will run mariadb normally and apache2 with a temporarily VirtualHost for that specific project folder as DocumentRoot.
What I currently can do:
Lay down a httpd-vhosts.conf file and a startProject.sh script in a project folder. Running the script will copy the configuration file in the xampp installation and then start the apache2 service.
That is working, but only one apache2 process can start and not multiple projects at once.
What I want:
I want to use a parameter that specifies a VirtualHost by parameter when starting apache2.
Maybe by saying apache2 to use a special config file rather then the file in the own project structure.
Or I want to use a parameter by starting the apache2 process that specifies a alternatie DocumentRoot Folder for a already specified VirtualHost.
Currently this is my approach:
#!\bin\bash
BASEDIR=$(dirname "$0")
xamppPath="C:\xampp\v7.3.10"
cd $xamppPath
"apache\bin\httpd.exe" -S "$BASEDIR\httpd-vhosts.conf" &
But -S only prints out the VirtualHosts, not setting the configuration file.
How can I achieve running a project with a script somewhere on my harddrive without overriding the existing configuration file in the xampp installation folder?
Easier: build a couple of congratulation files, use option -f to specify an effective configuration file, not -S.
Can be more complicated: user -D name and use <IfDefine name> in the configuration file to "select" sections of it to apply to a particular start.
Note: I use apachectl, not directly httpd to start/stop Apache.
In the xampp package there is no direct apachectl file, so a use of -D <name> is not possible for me. It would be the perfect solution, but unfortunately not possible.
Now I have to override the httpd-vhosts.conf file from every project I want to start it. Therefore, I am using a modified script solution:
#!\bin\bash
BASEDIR=$(dirname "$0")
xamppPath="C:\xampp\v7.3.10"
cp -f "$BASEDIR\httpd-vhosts.conf" "$xamppPath\apache\conf\extra\httpd-vhosts.conf"
sleep 1
cd $xamppPath
"apache\bin\httpd.exe" &
It is not the perfect solution, but it works.
Two apache services at the same time with two different projects is not possible, but until now not necessary.
I am running this Docker instance of a linux debian:jessie with php 5.6.
This is part of my phpinfo :
As we can see the php.ini should be located at
/usr/local/etc/php
And this is what I have inside /usr/local/etc/
But there is no php.ini inside it.
I the other hand, I have the php.ini inside
So, from where exactly is my php.ini being loaded?
We dont even have a php process running but the php seems to be ok - being displayed phpinfo in the screen.
A little late to the party but since question is still relevant today, let me add a short answer:
Official php:7 images get their settings from /usr/local/etc/php folder.
# First log into the running container
$ docker exec -it «container_name» /bin/bash
# List folder content
$ ls /usr/local/etc/php
# Which outputs following line
conf.d php.ini-development php.ini-production
If needed, modifying settings via conf.d folder seems better alternative, since xdebug uses it. For example, you can change upload size by adding uploads.ini to conf.d folder with the following content:
file_uploads = On
memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600
Complete list of ini directives can be found at https://www.php.net/manual/en/ini.core.php
Let try it as an answer:
It does not exist at all, which means php will run the default options.
Look at your docker file, it starts from a "clean" OS, installs Apache and PHP in it. But it never copies the php.ini file from the PHP installation into /usr/local/etc/php. Actually in lines 31 and 32 it creates the conf.d directory but that is it.
So I would suggest, at the end of your docker file, add code to copy php.ini-production to /usr/local/etc/php.ini, and edits as required. Or use default options.
The default php.ini file that the docker php images look for is:
/usr/local/etc/php/php.ini
You can see this in the output from the phpinfo function (just run "php -a" in the container and then "phpinfo();" at the prompt):
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
You can always link this file in as a volume to get a custom one when running the container with a -v option like:
docker run -v /local/path/to/php.ini:/usr/local/etc/php/php.ini [OPTIONS] IMAGE [COMMAND] [ARG...]
I typically prefer to use the default ini file that comes with it, with just a few modified options as I need them. If you want your container to do this during build, you can do something like the following in the Dockerfile:
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
sed -i -e "s/^ *memory_limit.*/memory_limit = 4G/g" /usr/local/etc/php/php.ini
The RUN commands above will copy the default production ini file, and then will modify the memory_limit and set it to 4G in the ini file.
I prefer this method because it allows custom configurations to be used so the container always works with defaults when it's pulled, but you still have the option to override the ini file in the container by passing a volume in.
Short answer is you don't need one. If you're missing or want to add extensions, you can do so in your Dockerfile by doing docker-php-ext-install or docker-php-ext-enable.
Most of the common ones, you can simply do enable, such as mbstring for example, but for some less common ones, you might have to run pecl first or something to get the package. Take a look at this Docker documentation page for more information on php extensions
If you are using something like wodby (docker4php or docker4drupal) or lando or trying to find an answer "why php.ini doesn't work" (like me), these tools are using their own way to pass configuration into php
https://github.com/wodby/php#php-and-php-fpm-configuration
Is there any way to modify the php.ini file in Mac OSX.. I'm using XAMPP and i need to change the upload-tmp-dir path. Whenever I try to edit and save the file, it shows some error that I am not authorised to do so.
Please help!
You can update using editor in terminal and use sudo command to open it as superuser, see here.
sudo vim php.ini
or
sudo emacs php.ini
Your choice
What if you try to copy php.ini file to your Desktop, make changes, save it, and replace back?
1.open php.ini with superuser
sudo vim php.ini
2.press i to change somthing
3.press Esc and :wq to save and exit
4.restart your web server
Maybe step 4 is the reason "But my uploads are still not working.. ".
I've installed "PHP PECL EXTENSION/MODULE ON UBUNTU". At the end, I was asked to add some configuration lines in the a file called php_ini that can be found in this path:
/etc/php5/apache2/php.ini
However, after making my changes, I can't save the file because the file is read-only.
What the appropriate action to save my changes. I don't really why the file is read-only, I don't know if there is some thing I need to do. I'm new in Ubuntu/php
Thanks for helping.
For accessing the system files you need root permission.So you would need to use sudo command.it would be like sudo vim /etc/php5/apache2/php.ini(if u are using vim editor) as user2075215 mentioned in comment.
Use command:
"sudo gedit /etc/php5/apache2/php.ini"
It will open text editor, change your settings and save with ctrl+s and close the editor.
All changes will be saved.
Since I am a beginner in Terminal, I used cd multiple times to get to the location of my php.ini file.
cd etc
cd php
cd 7.0
.
.
.
Then I did
$ sudo xdg-open php.ini
and the file popped up and I am able save edits now.
I am new to Ubuntu Linux (version 13.10). I am following this tutorial to install MySQL, PHP, and Apache2.
It installed successfully, but I don't know where to write PHP files that execute when you navigate to the URL localhost/example.php.
I am looking at this link, but I am afraid that maybe it will not work and have to reinstall Ubuntu again.
In a newer version should be in a different path: /var/www/html
With a series of commands you can find:
ls /etc/apache2/sites-available/
That answers with something like
000-default.conf default-ssl.conf
In this case you need the second file default-ssl.conf; with
grep -n -e "DocumentRoot" /etc/apache2/sites-available/default-ssl.conf
you can obtain:
5: DocumentRoot /var/www/html
That means you can find (and change) DocumentRoot definition in the 5-th lines of the file /etc/apache2/sites-available/default-ssl.conf.
As a simple Google search would have showed you, it's (by default), /var/www/.
In the Ubuntu default config, that is defined in the default virtual host, the config file for that is /etc/apache2/sites-available/default
The default location of document root is /var/www. This, assuming you haven't touched the HTTPd configuration.
By the way, if you simply need a development server for PHP scripts, you can use the one emebedded in PHP > 5.4. Just cd to the project directory and launch:
php -S localhost:8008
In vscode (I'm sure in other editors as well) you can right click the file and copy path and copy relative path.
http://127.0.0.1:8000/site.php
Works for me.