Web Hosting

How to Make Localhost Website Fast if it is very slow

For 3 years I've been working on slow XAMPP Apache server on Windows till the settings I found and really worked! Now my site workflow is very fast and efficiency increased.

My workflow involves working on localhost and almost daily evening I transfer the site code and database to production site.

Mine is Windows 7 PC , XAMPP, Apache2 and work on Joomla & Drupal sites.

If you don't know about XAMPP or WAMPP then I suggest you learn about it and use it to reduce many hosting hassles.

List of settings

Here are the list of settings which I did and ticked for me:

  1. To make your mysql access fast access the mysql connection as 127.0.0.1 and not as localhost. To do so in Joomla/Drupal/Wordpress just go to the settings/config file and in the database connection name replace localhost with 127.0.0.1.
  2. Edit windows\system32\drivers\etc\hosts file. Add these two lines:
    127.0.0.1   127.0.0.1
    127.0.0.1   localhost

    If there is this line comment it after inserting a # symbol at the very beginning of the line:

    ::1 localhost

    Change it to:

    #::1 localhost

    Mind you hosts file is write protected. To edit it, first go to Start button and find Notepad or Notepad++ and right click and click "Run as Administrator". I suggest you take a backup of hosts file as host.todays-date so that you can revert after updating it. After adding the entries run from command line: "ipconfig /flushdns"

  3. Find the Apache configuration file name httpd.conf it'd be apache/conf/httpd.conf. The apache folder will be directly within the xampp folder. Now uncomment these two by removing the first # symbol and change off to on:
    EnableMMAP on
    EnableSendfile on
    
    
  4. Now go and open your php.ini and change this line to:
    realpath_cache_size= 8m

    To locate your php.ini just see the phpinfo() output and search this name in it. If yours is XAMPP then simply typing http://127.0.0.1 will open XAMPP page. On the left look for phpinfo and click it.

  5. Try these first and there is still little room to make your mysql server faster by increasing the buffer sizes and also there are caching modules to make your PHP run faster. If you use Innodb then look for articles to make mysql faster for Innodb.
  6. Reboot your system if that your localhost website has quick response time. Also try disabling your firewall/anti virus for time being.

Use php handler DSO to save your web hosting account from being hacked

How I saved my Linux web hosting account from hacking attempts.

The most serious threat your web hosting account faces is that .htaccess may be misused to redirect your traffic to some other destination. Tinkering robots.txt can seriously affect your crawl by Google etc.

I simply stumbled upon this technique when trying to optimize my web hosting account on Centos using Cpanel/WHM.

Using this technique you improve your hosting performance and also lower your memory usage.

Simply change your PHP-handler to DSO. It is same as erstwhile mod_php. You gain huge performance gain compared to SuPHP mode.

Now the Apache server runs as nobody user. Any hacker trying to gain access can only run as 'nobody' user.

Here is the technique.

Note:Replace 'login' with your account user name.

Run this as root user:

set -x

for login in  account1 account2
do
if cd /home/$login/public_html
then
chmod -R 777 .
chown -R nobody:nobody .
find .  \( -name .htaccess -o  -name 'robots.txt' \)  -exec chmod 755 {} \; -exec chown $login.$login {} \;  -exec ls -l {} \;
chown $login.$login . *
chmod 555 . .. *
chown root.root . ..
echo "done"
fi
done

Now chmod everything else to 777 and owner as nobody:nobody as required by DSO mode otherwise your files may not upload and you may get strange errors.

Also don't run this if your site is linked using symbolic links.

So what it does is that it disallows write/remove permissions from the public_html and all files/directories directly in it( and not further).

It also removes write permission in all the .htaccess and robots.txt files. So any hacker will not be able to hack into .htaccess of the public_html and the one in your site folder.

So finally you're saved from disaster happening in with your site by manipulating it's .httaccess files.

When adding domains or email accounts change permission of your home folder and www and www/* to 777 and after you've done, rerun this script from root.

I suggest to setup up some monitoring programs to catch infections regularly.

Please also read steps I took to recover from Pharma Hacking

Syndicate content