Archive

Archive for the ‘Apache Performance’ Category

How to Optimize Your LAMP Configuration

September 4th, 2008 No comments

Today I’m just sharing a link: I don’t think I can explain this better than IBM guys did. These three acrticles contain a comprehensive guide for your LAMP system optimization. Here is the first one, that contains general linux settings for perfect LAMP config. The second one describes how to fine tune Apache and PHP and finally the third one deals with MySQL – you will find out how to optimize MySQL configuration for any server . I usually recommend this guide for those who didn’t tune anything before – it’s clear and brings excellent results. If you have links to similar excellent tutorials, you’re welcome to share them in comments. Have a nice day!

Apache Stopped Working After PHP Upgrade – How to Fix

August 24th, 2008 No comments

If you are often working with PHP upgrades, you should do this automatically – you already know all the issues you might face. But if it’s done for the first time, it is quite hard to find your problem. I will tell you about the most common issue and about the applicable actions to fix this.

When you update your PHP installation via Directadmin build system or when you do this manually, new modules are added to httpd.cond, but the older ones are not deleted. This usually causes problems, as apache refuses to start after PHP upgrade, What do you need to do in order to tun apache again?

You need to edit your httpd.conf file (it is usually located at /etc/httpd/conf/httpd.conf). Open this file fith any editor you like and comment all strings that contain “php4″. The same directives for PHP5 are added automatically so you don’t have to worry about it. When you comment everything related to PHP4, you should save httpd.conf and try to reboot apache. If everything is OK, it should start, if not – you have to follow its logs or errors you receive at the command line window. Let me remind you that most useful way to restart apache is service httpd restart.

How to Change Owner of Files Created by Apache

July 18th, 2008 No comments

If you manage any script that creates files on the server, you might meet the prob;em that you cannot edit files created by this script. This is especially related to PHP scripts, that, for example, create some text files in a folder. When you try to open these files via your FTP client, you will most probably receive “Permission Denied” error when you try to save your changes.

When you run your PHP scripts, that are creating files, they almost in all cases are started by user Apache. This user has all the permissions on the created files. So we have Apache as an owner and Apache as the Group. That’s why we don’t have access to these files – we simply don’t own them.

I know two different solutions for this problem. The first one is quite intelligent – to use suphp. This is an Apache module, that allows to run php by the user that initially owns the executed file. That’s a great solution as it is done for entire server and all users’ scripts will be affected.

Another solution is not so beautiful, It’s a “patch” for scripts that are actually running. If you don’t have suphp installed or don’t want to install it for any reason, you can use root crontab to chown files created by your scripts. For example, we will recursively chown a folder where script generated files are located. Just add the following line to your root crontab:

*/10 * * * * chown user:user /folder_to_chown

This is not quite a good idea but I don’t know any other solutions at the moment.

How To Deny Directory Listing Using .htaccess

June 16th, 2008 2 comments

Often when you’re using shared hosting, there are some problems with directory listing. Server administrators should avoid this as this represents a security hole. But what to do if you don’t have access to httpd conf and need to prevent directory listing? What to do if you have something like this:

A simple string in .htaccess file will save you. Here it is:

IndexIgnore *

In some cases the following string will also work:

Options -Indexes

One of these two solutions will lead you to showing 403 error to the user that tries to look what files are located in your directory. But let me repeat – this is a security hole and you should notify your system administrator about this issue. This is an emergency solution…