I'm troubleshooting a php log file that has expanded way too rapidly and used up a lot of disk space.
What is the best way to clear a log file?
is it a problem to simply delete the log file? And will that log file be recreated as php tries to write to it?
It is entirely safe to just delete the php.log file. It will be auto-created the next time it is needed.
On Linux you can do :
cat /dev/null > /var/logs/php.log
On Mac OS X 10.6 I deleted /var/log/apache2/error_log. Minor panic when it didn't re-appear upon refreshing my page. Just had to restart apache by going through the Sharing settings. Now she's back.
It IS safe to delete the log file by doing the following:
Delete the php.log file altogether.
If on Apache Restart the Server using "service apache2 restart" command
If on NGINX you do not have to restart the server
You can run this simple command from terminal(in WHM) or From SSH terminal.
find -name error_log -type f -exec rm -rf {} \;
This command will find all files with name "error_log" and remove it.
Enjoy.
Related
I'm troubleshooting a php log file that has expanded way too rapidly and used up a lot of disk space.
What is the best way to clear a log file?
is it a problem to simply delete the log file? And will that log file be recreated as php tries to write to it?
It is entirely safe to just delete the php.log file. It will be auto-created the next time it is needed.
On Linux you can do :
cat /dev/null > /var/logs/php.log
On Mac OS X 10.6 I deleted /var/log/apache2/error_log. Minor panic when it didn't re-appear upon refreshing my page. Just had to restart apache by going through the Sharing settings. Now she's back.
It IS safe to delete the log file by doing the following:
Delete the php.log file altogether.
If on Apache Restart the Server using "service apache2 restart" command
If on NGINX you do not have to restart the server
You can run this simple command from terminal(in WHM) or From SSH terminal.
find -name error_log -type f -exec rm -rf {} \;
This command will find all files with name "error_log" and remove it.
Enjoy.
I have this odd error that only happens when I try to upload a new blade,
or update an already working blade file.
The error I get I've tried to remedy by trying to use chmod 777, but I'm to believe there is something with the actual blade file (not the code)
In short, I get this error:
So the odd thing is that the current project loads fine with each blade, but as soon as I make a change (or try to create a new blade) it gets this error.
I did see that there was a discrepancy in the file encoding but have changed that part now.
I tried to be specific on a fuzzy issue that I can't really get my head around
Edit:
Actual error message:
" UnexpectedValueException
The stream or file "/var/www/html/nu_web/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied"
If you're using CentOS 7, it could also be SELinux that makes it impossible to write to the log file.
If you have SELinux installed, you may want to know whether SELinux is on and which mode it is in. It is pretty straightforward.
Run the following command to check the current status & mode of SELinux:
$ sestatus
You can run the following command to set SELinux to permissive mode temporarily:
$ sudo setenforce 0
You may permanently disable SELinux on CentOS 7 if you want.
Run the following command to edit /etc/selinux/config SELinux configuration file:
$ sudo nano /etc/selinux/config
Now change SELINUX=enforcing to SELINUX=disabled
Now reboot your computer with the following command:
$ sudo reboot
Try running
sudo chmod -R 664 storage
sudo chmod -R 664 bootstrap/cache
in the route folder of your application, this will allow for errors to be added to the log file.
Run in your terminal
sudo chmod -R 777 /var/www/html/your_project name
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.
When I instal nextgen-gallery plugins. This error message appears
Downloading update from https://downloads.wordpress.org/plugin/nextgen-gallery.zip…
Unpacking the update…
Could not create directory.
How can I fix this problem ?
This is a permissions issue. Ensure the directory is writable by apache. Plugins are unpacked into the wp-content/plugins directory, so I would first attempt writing to the directory as apache:
sudo -u apache touch /path/to/wp-content/plugins/test.txt
Set permissions accordingly to correct the issue. You can read about permissions here: https://www.pluralsight.com/blog/it-ops/linux-file-permissions
You can read about the correct file permission scheme for Wordpress here: https://wordpress.org/support/article/changing-file-permissions/
#skrilled and #knutole's answer was great but I found that when attempting to fix the issue on the plugins folder, everything was ok and the answer did not work for me.
If anyone else has this issue, try looking at the upgrades folder also. This folder (from what I can see) is used as a folder to store temporary files for when WP upgrades or plugin updates are being ran.
If you simply receive the message stating 'Could not create directory' and there is no path specified, it could actually be talking about the upgrades folder.
Most likely, if you have configured it correctly, the http server associated to your wordpress site belongs to the group www-data. That's how one should configure it correctly.
Try members www-data and ps aux | grep www-data to be sure. In the latter command you should see on the last columns either nginx or apache.
In this case, you just need to set that group to the directory
sudo chgrp -R www-data <your_wordpress_root_dir>/
and then add full group permissions to such directory
sudo chmod -R g+rwx <your_wordpress_root_dir>/
Now it works perfectly :)
for nginx people
if you have php-fpm installed you have to tell it that its user and group is nginx. /etc/php-fpm.d/www.conf . find user which is assigned to apache by default and change it to nginx. also do it for group. then run this command :
sudo service php-fpm restart
also inside of your wordpress directory execute these commands
sudo chown nginx:nginx * -R
sudo usermod -a -G nginx username
change username into what your current username is.
yet you have to apply propper permissions.
run these commands inside your wordpress directory
sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
If you are using vsftpd as your FTP server and have enabled passive connections, you need to add pasv_promiscuous=YES to /etc/vsftpd/vsftpd.conf.
I was having a similar issue. It started with me trying to update a plugin on a migrated WP install. I didn't get it, all my permissions were EXACTLY the same as the old server. In my situation, I started to see that not much was working properly. I couldn't install/delete plugins or themes as well as uploading media would error out. Then I found the fix via some research.
If you are still having this issue, and changing permissions DID NOT fix the problem try this:
Go in to your hosting control panel and find your hosting settings, wherever you can edit your scripting settings. In Plesk (as in my example), this would be under Websites & Domains. Click on your domain name at the bottom. On the next screen, where it says "PHP support (run as..." change the dropdown from "Apache module" over to "FastCGI application". Everything should be fixed up now!
(Re)setting the permissions via ftp didn't make a difference for me either. There is no SSH available, so I had to log in the control panel (directadmin in my case), the File Manager where I could "Reset Owner" to "File ownership reset" the /wp-contents directory.
I'm running Nginx with Wordpress. I deleted the upgrade folder in wp-content and then ran the upgrade from the wordpress GUI again. I noted the linux user for the upgrade folder created was www-data. I then did a {sudo chmod -R www-data:www-data .} Ran the upgrade again from the GUI and it worked.
Probably need to change the permissions on most of the folders so they can't be modified by www-data but I'll figure that out tomorrow.
A permission issue, make sure apache (www-data) has write permissions.
All the above is great, but I think you missed the simplest issue. Your website is using more space than it has allotted, and therefore it is broke. Wordpress makes more files as is in use. If you are on the margin of going over, a simple overnight issue where you did nothing is possible. Go to bed, everything fine. In the morning website is broke.
I own my websites so I go into the reseller part of Hostmonster or Hostgator (I have sites on both hosting platforms) and I reallocate more space and the problem goes away usually. Try that first, or look into it before messing around with permissions. If you changed a permission and the issue came up, could be permissions, otherwise, check this first.
I had the same issue when I tried to install wp plugin(s). However, I managed to solve the problem with the following command:
sudo wp plugin install [plugin name] --allow-root
I have over 5 million session files in /var/lib/php5
I would like to delete all files in this folder using rm *, however I'm not sure if there are other files other than the session files in that directory that should not be deleted.
Through SSH it took a few minutes to make the file count and I'm not sure I can navigate through there with all these random filenames.
The setup is ubuntu lucid linx, apache 2 and php5. In the most common of setups are there other folders / files in /var/lib/php5 that I should not delete?
Edit The reason I want to remove the files is because I moved session handling to a database and don't need any of the files anymore.
cd /var/lib/php5
find . -name "sess_*" -print | xargs rm -v
Let PHP's gc perform cleanup by itself. Find php.ini and change session.gc_probability to something bigger, save it and restart Apache (call any php script). It says here http://somethingemporium.com/2007/06/obscure-error-with-php5-on-debian-ubuntu-session-phpini-garbage
In Debian and Ubuntu, /var/lib/php5, where the session data is stored,
has permissions of drwx-wx-wt and should only be cleaned by a cron
script. So, the package maintainers disable automatic session garbage
collection.
Or you could try to put ini_set('session.gc_probability', 100); session_start(); (if your session.gc_divisor is equal to 100) in one of your scripts and call it. The best way is to put in empty php file, because it might perform cleanup for a very long period of time.
ps: I would also try to leave session.gc_probability 1 and set session.gc_divisor to 1. It should call gc at every run, but you need it just for a directory cleanup.
And check your cron /etc/cron.d/php5 - it should run every half an hour to purge session files in the /var/lib/php5/ directory.
pps: found interesting comment
This does not disable it (it is commented out). The default within the
engine is still used - phpinfo() shows the value to be 1. There is a
problem with garbage collection in Debian (and thus Ubuntu) but that's
due to PHP wanting to vacuum garbage that has already been removed by
the cron script. This causes an error that may be displayed on the
unlucky page.
in PHP7, this worked
cd /var/lib/php/sessions/
sudo find . -name "sess_*" -print |sudo xargs rm -v
If you're using CODEIGNITER, then try with following commands.
cd /var/lib/php/sessions/
sudo find . -name "ci_*" -print |sudo xargs rm -v
sudo find . -name "cises*" -print |sudo xargs rm -v
cd /var/lib/php5
sudo find . -name "sess_*" -print |sudo xargs rm -v
This has worked in my case .
On my ubuntu computer, at /var/lib/php5, there is a sess ID file:
sess_a7kjdaojmneuhcgslj
If I tried to remove this file using the command:
sudo rm sess_a7*
I got an error message saying there is no such a file. I had to use the full name as:
sudo rm sess_a7kjdaojmneuhcgslj
It worked. This is my two cents.