php.ini file not found [closed] - php

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a hosted website with cPanel. I want to modify php.ini, but I don't get where that file is on server. I tried to find the location of the file using phpinfo() and I got the location as /usr/local/lib/php.ini but when I search in file manager I'm unable to find this location.
I looked at https://stackoverflow.com/a/3401536/1989696 and followed the same steps, but I'm not sure how to tell if the webserver supports SSH or SFTP access.
Also, how can I locate the php.ini file?

Unless you have a dedicated or virtual server, you are not allowed to edit system-wide PHP settings.
If PHP runs as CGI, you'll possibly have a custom .ini file you can tweak:
... or, if your PHP version is 5.3 or greater, you can create your own .user.ini files.
If PHP runs as Apache module:
... you can use good old .htaccess.
And, of course, 95% of the PHP settings can just be changed from within PHP code:
ini_set()

Related

PHP8 not working with Apache httpd localhost in Mac OS 12 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Upgraded to Mac OS 12 today and noticed PHP was removed. Have installed PHP 8 using brew. I've tried setting it up with the default httpd and also tried installing it with brew. I load the module in the config. In both cases, when I access the files on the localhost in my browser, it just prints the text in the php files and doesn't execute them. Haven't really got any clue left
You need to add the line AddType application/x-httpd-php .php to httpd.conf Apache configuration file to enable PHP file parsing. After editing the file restart Apache to reload new settings.
You can use an alternative like MAMP (My Apache MySQL and PHP). Installation instructions here: https://documentation.mamp.info/en/MAMP-Mac/Installation/.
It includes a prepackaged Apache/nginx web server, PHP and MySQL, as well as, a management GUI app native to macOS.

Curious as to why system said it was loading php.ini file from different directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I was wondering why my system says it is running the php from the /etc/php5/apache2/php.ini
directory when in fact it was running it from the /etc/php5/cli/php.ini .
When I did a phpinfo() on a file in the directory of the folder, I received this however the changes to the configuration file wasn't impacting the server until I searched the whole system for a php.ini file and found the php.ini file under the cli/ directory:
Hopefully you can see it. I wasn't sure exactly how to put in onto SO.
it's intentional so you can easily have different configuration depending on your runtime environment.
In your environment when php runs in command line mode it uses /etc/php5/cli/php.ini.
When you access it from browser php is running from apache. So then /etc/php5/apache2/php.ini is used.

Unable to open localhost? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have been using Lampp on a test machine. OS is Ubuntu 12.1. It was working fine before and running my scripts. Then it began displaying a pop-up asking me if I would like to open or save the file? I have tried changing the ports and restarted the machine and restart Lampp. Nothing has worked so far though.
Your MIME types are wrong and/or mod_php isn't loaded.
What is in the files? If they contain your PHP code, Apache is serving the files out rather than putting them through PHP. Check you are loading mod_php.
If they contain the output of the PHP code (i.e. the HTML) then they aren't being given the correct MIME types. I'm not sure where this is done, I think Apache or PHP adds the headers automatically. Check the Apache MIME types config

Can php.ini file be used at the directory level? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am wondering whether I can use a php.ini file at the directory level? Specifically, I have a domain pointed to a virtual document root in a sub-directory and would like to override some php.ini values previously defined in the php.ini file located in the physical root directory.
Is this possible simply by redefining these values in a new php.ini in the sub-directory? I'm trying to stay away from defining these in .htaccess file.
In general no, but in special (CGI/FastCGI) yes: http://php.net/configuration.file.per-user
Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.
In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). In case the PHP file is outside the document root, only its directory is scanned.
You can only set a limited subset of the ini-options in the user-ini-file. If you are hosting several independent sites on one server, you should consider FastCGI anyway, to keep them separated. With php5-fpm it's very easy to setup many pools of workers.

Custom PHP.ini not loading [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
When I print out the phpinfo(), it shows my Configuration File (php.ini) Path as /usr/local/php/lib Which is correct, and where the custom ini file is located. But my Loaded Configuration File is (none). It seems like my PHP is not loading the custom ini file, although it is there where the file is looking.
I have attempted to recompile PHP, and it had no effect.
I am currently running PHP 5.2.14 on Ubuntu on Apache.
Yes, I restarted apache. I also tried to stop it and start it completely fresh.
Also a slight addition: The PHP server is running fine. I have been running this server for 6 months with no issues. It is running off of the default settings it seems, and all extensions I have compiled PHP with work, like xmlrpc and mbstring. They are shown in the PHP info.
If the Loaded Configuration File is (none), then you do not have installed PHP and Apache correctly. Try to re-install them again (in my opinion first the PHP and then the Apache). It is less time consuming than trying to change configuration. When Loaded Configuration File is (none) and PHP and Apache is working, it means that your server is using a default configuration file (default php.ini), but not your modified one.
Check the file permissions of your php.ini file. Could be that it is THERE but apache cannot access it, should be same user & group of your apache user (www-data)
Usually you can do this:
sudo chown www-data.www-data php.ini

Categories