php application fails to detect the right temp directory - php

In my Laravel 9 application running on AWS EC2, I'm trying to upload a file.
The action fails with this message: File could not be uploaded: missing temporary directory.
Inside my loaded php.ini, I have it set as upload_tmp_dir = /tmp
But when I do a phpinfo, I see the value for upload_tmp_dir is empty. Looks like whatever value I add for upload_tmp_dir is not read/recognized by php.
I used echo sys_get_temp_dir(); to get the path that the app is using, and it returns as:
/var/www/html/tmp
What's the reason the app is failing to detect the right path to the tmp directory?
If it matters, here are also the directory permissions:
/tmp is owned by root/root and is drwxrwxrwt+
everything under /var/www/html (where the app is) is owned by ec2-user/apache

Here is how I resolved this issue:
Edit /usr/lib/systemd/system/php-fpm.service. Set PrivateTmp=false
Edit /usr/lib/systemd/system/httpd.service. Set PrivateTmp=false
Reload parameters: sudo systemctl daemon-reload
Restart service: sudo systemctl restart php-fpm and sudo systemctl restart httpd

Related

How to Edit php.ini ( php version 7.1) file on amazon AMI instance

I want to change my default php.ini file configuration on amazon-ec2 AMI instance.i can access any my instance using putty and filezila.
This is only for php version 7.1 or greater.
Conncet your instance using filezila or winSCp .
Navigate to /etc folder.
you can see .ini file at bottom name php-7.1.ini.
using filezila right click on that file and click File Permissions.
If your file permission is 777 then good to go or it is any other than 777 then change it permission using command line interface just remember it's current permission.
use this command to change permission sudo chmod 777 /etc/php-7.1.ini
Now you can edit your .ini file.
After edit your file set back to it's previous permission to 644 or whatever your default ini permission using this command sudo chmod 644 /etc/php-7.1.ini.
And it's done dont forgot to restart server using this command sudo service httpd restart.

Nginx and PHP-FPM setup - PHP session path file permission problems after every yum update?

After a yum update , session path file permissions were changed on:
/var/lib/php/session
this becomes owned by "apache" (but I don't even have apache installed)
This caused a failure to create PHP sessions with Nginx/PHP-fpm and disabled phpMyAdmin.
To resolve, every time I have to do this manually :
sudo chown root:nginx /var/lib/php/session
is there any way or setting that this won't is overwritten by the yum-update process?

php7 fpm sock file ownership on service restart

I have just installed PHP7
https://github.com/kasparsd/php-7-debian
Everything works except each time I do service php7-fpm restart I need manually to set ownership on file /run/php7-fpm.sock to www-data
After setting the permissions everything works.. But how to avoid this on every restart?
The ownership is always root after restart
php-fpm.ini
user = www-data
group = www-data
Ownership of the file socket is determined by the listen.owner and listen.group directives in the FPM config file.
If thats your local development environment, just add www-data to the sudo. That should make things easy.
Also try reinstalling PHP
Following tutorial might be helpful.
https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-ubuntu-14-04

Editing php.ini on vagrant box

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.

How to open HTML file in browser in centos?

I am accessing one system with ipaddress 192.168.1.41 as a server. In this system has one HTML file which is located at path opt/openerp/apache/htdocs/index.html. Now how can I access the html file in my local system browser ?
I tried with 192.168.1.41/index.html but it does not work.
Can anyone help me how to access the file in my local browser
Put index.html in /var/www/ and try opening with the browser 192.168.1.41/index.html. First check apache2 is installed
Steps -
1. sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site_name
2. Change the default document root and directory directive in the new file to new location.
3. sudo a2dissite default && sudo a2ensite mysite [deactivate old site and activate new site]
4. sudo service apache2 restart

Categories