5 Easy Tips to Free Up Disk Space on Your Server

From time to time we need to clear up disk space on our servers, whether it is to just reduce disk space to help minimize the costs and usage of backup servers, or if it’s to clean up the server and help with performance.

Here are 5 easy ways you can instantly clear up hard drive space and reduce the number of inodes on your server:

1.) Remove User Generated cPanel Backups

Many times cPanel users aren’t aware that they should delete a cPanel backup before performing another cPanel backup.  Essentially they are taking backups of backups and this can quite easily add up to several gigabytes of space just for one account. A quick and easy way to remove these is to run the following command from root:

for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done

Make sure to copy the full command exactly how it is above. This will work for cPanel hosting servers only.

2.) Audit your MySQL Databases

Not only will this free up disk space but it can greatly help with increasing the performance on your server. Large MySQL databases on sites that are receiving a large amount of traffic can really slow down a server. Many times the tables that are using the most space in a database are simply from visitor logging or caching, things that can be freed up instantly be truncating the table.

Use the following command when logged in as root to show the highest usage databases on the server:

du -k --max-depth 1 /var/lib/mysql | sort -n

This will show a list of individual databases from lowest to highest. Databases larger than 500mb can be an issue with performance so it is worth it to investigate them.

Once you have the results from the command above, it is easy to go into phpMyAdmin and find the database. Once you have clicked on the database you should sort the table size by space, clicking it twice so that it shows the highest usage table on the top.

If the table is some type of visitor logging or tracking table, it generally is okay to truncate it. The same goes for caching. Make sure to backup the database just in-case before doing so, and it won’t hurt to do a quick google search to see if that table is okay to empty. Searching for the exact term/table name usually will bring up the results you are looking for.

This is a great way to free up disk space, RAM and help increase overall server performance.

3.) Remove Installatron and Fantastico Backups

If you are running Installatron or Fantastico on your server, it is easy for the backups for these files to use up a lot of inodes and space, taking up resources and slowing down performance. Usually once every few months we will remove these for that reason. You can do so by entering the following commands:

For Fantastico:

rm -rfv /home/*/fantastico_backups

For Installatron:

rm -rfv /home/*/.installatron/backups

These are the two software installers I am familiar with, if you are using another software installer the same can be done for it if you just insert the proper location where the backups are stored. Consult with the software developer to make sure it is okay to do so first.

4.) Get Rid of Cached Yum Files

Updates from Yum usually leave some unneeded files on the server. Do some Yum house cleaning:

yum clean all

5.) Delete Failed FTP Uploads

When users are uploading files via pure-ftp and the upload either fails or is interrupted it will leave a partial file on the server. You can quickly get rid of these to clean up some disk space:

locate .pureftpd-upload | xargs rm -fv

Using the above five ways we have sometimes cleared hundreds of Gigabytes of space and doing all of the above should take you less than an hour.

Let us know your results or if you have anything to add.

Share

How To Setup Multiple Stores With Magento

Magento Multi-Store & Setting Up Multiple Magento Stores Using One Admin Area

If you want to setup multiple Magento stores and multiple domains that share the same admin area, the tutorial below will assist you in doing so. This is very useful if you have a lot of stores that share the same or related products and you wish to manage it from one central location. You will also be able to track your sales and customers without having to login to the admin area of each website.

With the latest release of Magento Commerce it is much easier to set this up than it was in previous versions. Before it required you to modify the index.php file to handle your different domains pointing at different stores and various other complicated modifications. With Magento 1.4.x it is now much easier. The new index php contains the following code:

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

It checks two variables(code & type) and then uses them to run Magento. With the new code you’re able to set which store is supposed to be running under your main domain directly within your virtual host definition(root access required) or for our shared hosting and cPanel hosting customers you can actually now use .htaccess to accomplish this.

Creating your additional stores

If you haven’t already done so, the first thing you will need to do is setup your second store in the Magento admin area:

  1. Login to the Magento admin area.
  2. Go to the Catalog tab, then select Manage Categories.
  3. Click the ‘Add Root Category’ button on the left.
  4. On the right, for the Name, enter your secondwebsite.com. In the dropdown set Yes for both ‘Is Active’ and ‘Is Anchor’.
  5. Click on ‘Save Category’.
  6. Next you should go to the ‘System’ tab and select ‘Manage Stores’.
  7. Click the ‘Create Website’ button.
  8. For the Name enter your Secondwebsite.com, and for the ‘Code’ you should enter secondwebsite. You’ll be using this value later so make sure your note it down somewhere.
  9. Click ‘Save Website’.
  10. In the same area, click on the ‘Create Store’ button.
  11. For the Website, select your Secondwebsite.com from the dropdown. For the ‘Name’, you can enter Secondary Store. For the Root Category, select your now created Secondwebsite.com from the dropdown.
  12. Click the ‘Save Store’ button.
  13. Next click on the ‘Create Store View’ button.
  14. For the ‘Store’, select Secondary Store from the dropdown menu, make sure it’s for the created Secondwebsite.com. For the Name, you can enter English. For the ‘Code’, you should enter secondwebsite_en. For the Status, select ‘Enabled’ from the dropdown menu.
  15. Click on ‘Save Store View’.
  16. Next you will need to go to the ‘System’ tab and select ‘Configuration’
  17. For ‘Current Configuration Scope’ (located near the top left), change the dropdown menu from ‘Default Config’ to Secondwebsite.com.
  18. Select ‘Web’ from the left sidebar under the ‘Genera’l headline.
  19. For both the Unsecure and Secure sections, uncheck the Use default box next to the Base URL item, and enter the URL for your store, e.g. secondwebsite.com. Make sure to include the trailing backslash.
  20. Click the ‘Save Config’ button.

You’re almost done so hang in there!

Once you are finished creating the store, if you have not added your second domain as an add-on domain you will need to login to your cPanel account with us and create it as an Add-on domain now. Once you have done this you then need to copy your index.php and .htaccess file to the created directory for your add-on domain.

After copying over your index.php file, you should replace the following lines of code in the index.php file located only in the new add-on directory:

Replace this line:

$mageFilename = ‘app/Mage.php’;

With the following:

$mageFilename = ‘../public_html/app/Mage.php’;

Next you will need to either use the VirtualHost method(VPS and dedicated servers) or the .htacess method (for regular magento hosting / shared hosting accounts).

Using VirtualHost:

To set this up using the Virtualhost method you should simply add the following lines within your VirtualHost definition file:

SetEnv MAGE_RUN_CODE "base"  #Put your main/base website or store code here.
SetEnv MAGE_RUN_TYPE "secondwebsite"  #Here you should put 'secondwebsite' if the URL of the additional store you are adding is secondwebsite.com.

Using the .htaccess method:

If you do not have access to the virtual host file and are not a VPS or dedicated server customer, you can still use .htaccess for this.

In your .htaccess code you will need to define your main and secondary websites. For example if the URL of your main/base website is base.com and the URL of your second website is secondwebsite.com you should put the following code in your .htaccess


SetEnvIf Host .*base.* MAGE_RUN_CODE="base";
SetEnvIf Host .*secondwebsite.* MAGE_RUN_TYPE="secondwebsite";

You are, of course, not limited to using just 2 websites. To add additional stores you would simply add the additional lines of necessary code:


SetEnvIf Host .*thirdwebsite.* MAGE_RUN_TYPE="thirdwebsite";

etc.

You should now be all setup using Magento multi-stores and have multiple stores with one main admin area in Magento, without messing around with the code and the other previous lengthy methods :) .

If you have any questions, additions or issues with this feel free to comment.

Share