Set path for error_logs on php on dedicated server

Hello,

I have rented a dedicated server(linux+mysql+php) and have created a user  on this server ,on root of this user there is a folder of logs please let me know that how can find that this folder is set path  for error_log & acces_log?

Thanks
MOSTAGHASSIAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Loganathan NatarajanLAMP DeveloperCommented:
You need to locate php.ini on your dedicated server and look for this configuration,

error_log = /path/filename

Open in new window


You can set path where it should log and give permission to write.

More details here, http://php.net/manual/en/errorfunc.configuration.php#ini.error-log
MOSTAGHASSIAuthor Commented:
I cannot find php.ini on my server,i use Direcdamin ,in admin user i see 'php configuration safe mode' but there is not php.ini,and inside user i can't see.
Ray PaseurCommented:
Please install and run this script, shown here in its entirety.  Find the string "error_log" in the output.  Copy that line and post that here for us, please.
<?php phpinfo();

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Ray PaseurCommented:
Also, get rid of "safe mode."  It should not be part of any modern PHP installation.  Check the man page here for more information.
http://php.net/manual/en/features.safe-mode.php
MOSTAGHASSIAuthor Commented:
Hi Ray Paseur'

Sorry for delay,but on my dedicated server i have Directadmin and php also installed so how can access to php.ini via Directadmin,it is more simple for me.

For your code : <?php phpinfo(); do i put in a page and run it?
MOSTAGHASSIAuthor Commented:
I run  phpinfo() and for error_log this is the line:

error_log      no value         no value
MOSTAGHASSIAuthor Commented:
And :

Configuration File (php.ini) Path      /usr/local/etc/php5/cgi
Loaded Configuration File                    /usr/local/etc/php5/cgi/php.ini
Ray PaseurCommented:
Thanks, that is helpful.  I would go into the file at /usr/local/etc/php5/cgi/php.ini and add these lines

log_errors = On
log_errors_max_len = 1024
error_log = error_log

In my installation of PHP, I can delete the error logs, and PHP will create one if an error needs to be logged.  This makes it very easy to see if there have been any errors.  If the file appears, you know there was an error.
MOSTAGHASSIAuthor Commented:
How can access to php.ini from Direcadmin,and where save this error_log file?
Ray PaseurCommented:
php.ini is a regular text file.  You can edit it with any text editor.  

The error_log file will appear in the directory of the PHP script that has the error.  So if the error is in your web root, that is where the error_log file will be.  If the error is in a separate directory, the error_log will appear in the separate directory.
MOSTAGHASSIAuthor Commented:
Finally i could find the php.ini in Directadmin.

I enter as admin in Directadmin and under 'File Editor ' can open and edit some file regarding the system.

But i find 2 php.ini with these address,what are each one?

/usr/local/lib/php.ini
/usr/local/etc/php5/cgi/php.ini

In the second address i could find the :

log_errors = On
log_errors_max_len = 1024

which are comment out .

But meanwhile on the root of user in ftp i found a 'logs' folder and i see that for each day it produce 2 files:

mydomain.com.log.1
mydomain.com.error.log.1

the first one is regarding the IPs that have tried to connect to site,
and the second is for some 'Notice' and 'Warning'  regarding the codes in pages.

Please let me know that these 2 files for log and error.log are regarding the setting in php.ini and how in that file we set the path and also the name on files(are these as defult?) ?

thanks
Ray PaseurCommented:
I would just be guessing about file paths on your machine, and that would waste everyone's time.  So instead of guessing, I can tell you how to identify the true error_log file.

1. Remove the comment markers, so the directives take effect.
2. Restart everything from power-on .
3. Run this script, shown here in its entirety.
<?php error_log("HERE IT IS!!");

Open in new window

4. Look in the error_log files to find the string, "HERE IT IS!!" and you will know the location of the error_log file.

If your server is set up correctly the error_log file will be created in the same directory as the PHP script that logged the error, so if you have a lot of directories in your application server, you may find several error_log files from different PHP scripts.  This is really quite helpful, because instead of one large and potentially confusing error_log, your logs and PHP scripts will be kept together.
MOSTAGHASSIAuthor Commented:
Hi Ray;

I made mistake for accepting the answer,and requested from moderator to open the question that i correct it.

thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.