Category Archives: Apache-Nginx

Regular Expression to Parse Text Between Simple Tags (XML)

It is often necessary to extract text from a variable that contains HTML or XML code. I’ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages. preg_match_all(“/<tag>(.*?)</tag>/”, $source, $results); This construsion will create an… Read More »

Apache Stopped Working After PHP Upgrade – How to Fix

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… Read More »

How to Change Owner of Files Created by Apache

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… Read More »

How To Deny Directory Listing Using .htaccess

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… Read More »

How to Disable Web Access to Account With IP and Username in Directadmin

Sometimes it is necessary to disable http://ip/~username account access for any reason. Site can be unavailable or simply you don’t want users to access it in such a way. There is a simple directive in httpd.conf that will stop it. Just find the following lines and make them the same as below: <IfModule mod_userdir.c> #UserDir public_html UserDir disabled… Read More »

Disable Directory Listing Without Slash – Apache Config

Sometimes you need to deny directory listing on user input. For example, you don’t want your blog to be accessed at http://yoursite.com/blog, using only http://yoursite.com/blog/. This slash is added by mod_dir, that allows automatic adding of trailing slashes. A “trailing slash” redirect is issued when the server receives a request for a URL http://servername/foo/dirname where dirname is a… Read More »

Disable Apache Logging in httpd.conf – How to Do It

On busy servers you might need to take off everything that is not used. If Apache logs are neither watched nor analyzed, you should simply turn them off. How to do it? Simply, as usual: open httpd.conf and unload #LoadModule log_config_module modules/mod_log_config.so by commenting this line. You should also search for various log strings that should be found… Read More »

Viewing Apache Server Status From Your Browser

Sometimes you need to have a look at Apache status, especially, if your server serves many users and if often busy. You should monitor you server’s CPU load, and view other Apache performance information. There is a simple solution in httpd.conf, that allows you to do this directly from your browser. All you need is just to add… Read More »