I tried different solutions suggested here, but still cannot find the file through cPanel on my live server.
I'm running
phpinfo();
And getting this result:
Configuration File (php.ini) Path /opt/alt/php56/etc
I cannot find these folders: /opt/alt/php56
But I could find the etc folder, however the file is not there, and I made sure I checked "View hidden files" options
What else could be done?
enter in your server comand line: php -i to see all of your php's config and also in very first lines of this command output, location of your php.ini if you can't find file like php.ini in your output which may not happen make one with touch command and put your configuration in that file and reload server, depend on what you use (like fpm or ...).
Try this command and find the path of PHP
which php
try:
php --ini
it will print all config files locations
In WHM go to Software >> MultiPHP INI Editor and edit php.in for your PHP version.
OR edit: /usr/local/lib/php.ini
I'm having:
Ubuntu Linux 12.04 LTS
Apache Web Server(Apache httpd 2.4.16)
PHP 5.5.29
Now, whenever something goes wrong in code I always see a white screen in my browser window with no output at all. So, I googled for the solution and come to know that I have to turn the error reporting on in order to get the detailed errors/exceptions/warnings/etc.
And for this I come to know that I need to change php.ini file which Apache web server is making use of.
I opened up the file '/etc/php5/apache2/php.ini' by selecting it with my mouse, right click on the file '/etc/php5/apache2/php.ini', selected the option 'Open With Sublime Text2' and open up the file in Sublime Text Editor.
I did one small change on line no.466 of '/etc/php5/apache2/php.ini' file as follows :
display_errors = Off //Old code present on line no.466 of php.ini
display_errors = On //New code changed by me on line no.466 of php.ini
I am not sure is this the only change I need to make to '/etc/php5/apache2/php.ini' file to get errors/warnings/exceptions/etc. Please guide me in detail regarding the changes I need to make to the file '/etc/php5/apache2/php.ini' to get all the possible errors/warnings/exceptions/etc.
Now when I tried to save this file I got a pop-up saying 'Unable to save /etc/php5/apache2/php.ini'.
I'm the owner of my laptop, the system is mine, I am the administrator of my system and still I can't make any change to the file. This is really an un-understandable, useless and strange stuff for me. Previously when I was using PHP on my windows machine such weird things and headache never happened.
Please someone take me out of this bloody mess by giving descriptive and step by step answer.
Few people are saying I have to open up the terminal and type commands there. But I'm not getting What is terminal? Where it is? How to open it? What is root user and what is sudo user? What does each of the users do? What's the difference in between them? The purpose of graphical text editor is to manipulate files and this Ubuntu is preventing me from doing it.
Everything is strange here with Ubuntu Linux. What's the use of it? etc.
What is terminal?
Terminal is an interface where you execute your commands. More details here. Its like cmd in windows.
Where it is? How to open it?
Open the Dash (Dash is similar to the Start button in windows)
and type terminal.
The black board like icon with >_ is your terminal, click on it.
This is what a terminal looks like.
What is root user and what is sudo user? What does each of the users
do? What's the difference in between them?
Quoted from Ubuntu docs
In Linux (and Unix in general), there is a SuperUser named root. The Windows equivalent of root is the Administrators group. The SuperUser can do anything and everything, and thus doing daily work as the SuperUser can be dangerous. You could type a command incorrectly and destroy the system. Ideally, you run as a user that has only the privileges needed for the task at hand. In some cases, this is necessarily root, but most of the time it is a regular user.
By default, the root account password is locked in Ubuntu. This means that you cannot login as root directly or use the su command to become the root user. However, since the root account physically exists it is still possible to run programs with root-level privileges. This is where sudo comes in - it allows authorized users to run certain programs as root without having to know the root password.
Editing the php.ini file:
Now that you know what terminal is, open the terminal and type:
sudo vi /etc/php5/apache2/php.ini
Note: There are various other editors, like nano, gedit etc.
You'll be prompted to enter the password:
[sudo] password for user:
Just type in the password and hit enter. You'll see the contents of php.ini in the terminal. Now, scroll and search for the line Display_errors =off. You will have to change this to Display_errors =on, to do this change press i, make your changes, press esc, press shift+q type wq! and hit enter.
Now, you will have to restart apache to have the changes take effect. So, type:
sudo service apache2 restart
and hit enter. Thats it. Hope that gives you an idea :)
Regarding php.ini
You can do runtime change in all settings of your php.ini or by editing php.ini.
You should keep error_reporting false by default. And in development you can make reporting on runtime.
error_reporting(E_ALL);
ini_set("display_errors", 1);
Do this only if you are in development mode to see all fatal/parse errors or set error_log to your desired file to log errors instead of display_errors in production (this requires log_errors to be turned on).
Regarding file changes
php.ini needs to be edited by root user.
So you can edit by terminal:
Open terminal
Switch user as root
Edit php.ini by vi editor and do changes.
Restart apache server
Or If you still want to edit by sublime
Open php.ini by sublime with root access
You need do required changes in php.ini
Restart apache server
Terminal
The terminal is an interface in which you can type and execute text based commands.
Think of it like cmd in windows.
How to run it:
Open the Dash (Super/window Key) or Applications and type terminal, or use the keyboard shortcut by pressing Ctrl+Alt+T.
As this is to broad, and you actualy don't need terminal for your problem; for a great explanation of terminal please see: What is a terminal and how do I open and use it?.
Display error settings in php.ini
There are 2 settings you must edit:
error_reporting = E_ALL
Make sure it only have the value E_ALL.
E_ALL = Show all errors, warnings and notices including coding standards.
E_NOTICE = Show notices
E_STRICT = Show coding standard warnings
if you put ~ in-front it, it means Except.
display_errors = On
Unix-like OS file permissions
In unix-like OSes, files and directories are owned by a user and distinct permissions (read, write, run) apply to the owner.
These are very simplified explanation:
The '/etc/php5/apache2/php.ini' file is owned by root and with write permission only for root, so you can't edit it unless you are the user root itself.
But there is a way for you to edit files owned by another user, and that is with a command: sudo (superuser do ...), or gksu/gksudo for graphical interfaces software.
You may think that your username is another administrator/SuperUser, so why can't you just edit and save the file? Well, in actual you are not. Your user is just a regular user, but with permission to do SuperUser task. In other word you are just a sudo user (sudoers).
So the only way for you to save the changes you made, is to run Sublime Text using root privilege.
This can be achieved from the terminal by executing it via command: sudo sublime or gksu sublime.
Or without terminal:
via Dash (press super/window key), just type gksu sublime and press enter (you will be asked for your password).
This makes you run sublime text editor as root user, so now you can open the '/etc/php5/apache2/php.ini' file and edit it and save it.
(If you don't have gksu, install it via Ubuntu Software Installer.)
I use gksudo and gedit to do the job.
gksudo makes it possible to open a graphical interface. Gedit is the default text editor for GNOME. If you have KDE, then will you use kedit.
First I find the correct location of the used configuration file. You can find it easily making a php file calling the function php_info.
The content of the php file is a call to one function:
phpinfo();
That is it. I always have a file info.php in the documentroot of apache (in Ubuntu /var/www. Then I make a call to that file with:
http://localhost/info.php
and a document containing a lot of information will be returned. In it, you have a configuration value:
Loaded Configuration File
The value on that line is the php file that is used by the apache server. You should edit that file in order to see errors displayed. Lets call that value %phpini-file%.
Next I open a terminal
(see https://help.ubuntu.com/community/UsingTheTerminal)
and type
gksudo gedit %phpini-file%
and I do traverse the file until I see error handling and logging.
After that you will find the variables that you would like to be changed.
On a development machine I set the variable error_reporting to:
error_reporting = E_ALL
The documentation in the file gives you good suggestions.
Underneath that variable you have the variables display_errors, display_startup_errors and log_errors. I always give those variables the values On on my development machine.
Some lines below that you have the variable track_errors. I put it to On.
After making those changes will you have to restart apache.
The way I do it is:
sudo /etc/init.d/apache2 restart
It is equivalent to
sudo service apache2 restart
but it is how I have remembered it.
Instead of a terminal you can type ALT + F2 and you will see a command line appear in the midst of your screen. Next you type your command and the action will be performed.
Root is the user that has all privileges on an unix based system. Sudo is an abbreviation of super user do and makes it possible to execute commands as if someone is root. The whole root concept makes it safe that not any user can do anything on the system. You must be root or otherwise get sudo privileges in order to make changes on the system.
You just need to press
Ctrl + Alt + T
and you'll see a window appearing, which is nothing but the Terminal.
There you just need to type :
sudo gedit /etc/php5/apache2/php.ini
[Gedit is nothing but the default linuk editor]
After that you'll be asked to enter the password, where you need to enter your system's password.
The file will open in the editor, just find Display_Errors in that page and replace off with on, so it will be :
Display_Errors=on
After the changes save and close that file.
And just restart your apache by typing this command on the TERMINAL again :
sudo /etc/init.d/apache2 restart
While learning to set up php to be able to send mail I came across the need to edit the php.ini file. The problem is that when I go to <localhost>/~username/phpinfo.php it tells me it is located at /Library/Server/Web/Config/php however the Web directory does not exist on my server. So where is my php.ini file? I have looked at answers to the same question by others and still was not able to find it. If I need to create it, how do I go about doing that?
I am using a macbook pro as my server running Yosemite.
Thanks in advance!
UPDATE:
So it looks like I found my php.ini file but it is not where php says it is looking phpinfo.php says its looking in /Library/Server/Web/Config/php should I copy the file to this location? also my file is actually named php.ini.default, does this need to be named as just php.ini?
execute this command
locate php.ini
This will give you a list of all files with names where 'php.ini' is a part of it.
E.g.
/etc/php.ini
/etc/php.ini.rpmnew
/home/myuser/mywebsite.com/demo/local_php.ini
...
I'd rather do this:
php -i | grep ini
It will give you the info for ini configuration in the php console client. If you are executing apache or nginx you can see all the PHP settings with
<?php
echo phpinfo();
I have set up a MAMP server on my local computer.
The server runs fine, no problems, but I need to install the mcrypt extension on PHP as I need to install Laravel.
I've been following this tutorial:
http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
I have an issue with the last step. When I create a new php.ini file using the following Terminal command, PHP refuses to run at all.
sudo cp /etc/php.ini.default /etc/php.ini
Basically with no php.ini file in the etc/ folder, the PHP works fine (PHP info pages load, sites using PHP run fine), but when it's in place, no PHP works and loading a PHP info page returns a blank white browser window.
Am I missing something?
OK I managed to figure out the issue, here's the solution for anyone stumbling on this in the future.
short_open_tags was disabled in the php.ini file. I simply enabled this, saved the file to the /etc folder and rebooted the Apache server and it works great now. I needed to modify the php.ini file again to add the mycrypt extension but now works great.
I'm running MAMP Pro v2.1.1 on OSX 10.8.5
I like to modify a couple settings for phpMyAdmin by modifying the settings in /Library/Application Support/absolute/MAMP PRO/phpMyAdmin/config.inc.php
This works just fine, but every time I restart MAMP, the settings revert back to the defaults. It's really annoying.
I know that the php.ini file and other files are meant to be edited with MAMP's built-in editor. But there does not appear to be an option for phpMyAdmin.
Actually I had the same issue... Pretty annoying but I found out after emailing them that the file at /Library/Application Support/absolute/MAMP PRO/phpMyAdmin/config.inc.php is basically a temporary placeholder for your settings, inasmuch as whenever you start up MAMP the contents of the file at /Applications/MAMP/bin/phpMyAdmin/config.inc.php is read and copied into it, overriding whatever's already there.
That said, here's what to do:
Stop all servers and quit MAMP (completely)
Make your changes to the file located at /Applications/MAMP/bin/phpMyAdmin/config.inc.php
Open MAMP again and start all servers
The settings from the file you just edited should now be copied into the one that's actually read by MAMP and should take effect immediately.
For instance, I prefer to not enable the AJAX feature, so I did this:
Shut down the servers
Closed MAMP (entirely)
Opened the file /Applications/MAMP/bin/phpMyAdmin/config.inc.php
Added $cfg['AjaxEnable'] = false; to the file
Saved the file
Reopened MAMP
Started the servers
... and all was well.
Its a very late answer but problem still persists in OS Sierra. So, this is what worked for me -
You can change the owner of phpMyAdmin by using this command -
sudo chown -R _www:_www /Library/WebServer/Documents/phpMyAdmin
Replace the directory path of phpMyAdmin in case you installed it somewhere else.