apache – Internetblog.org.uk https://www.internetblog.org.uk Web hosting, Domain names, Dedicated servers Fri, 29 Jan 2016 11:05:52 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.5 https://www.internetblog.org.uk/files/2016/01/cropped-favico-32x32.png apache – Internetblog.org.uk https://www.internetblog.org.uk 32 32 Running Apache on Another Port https://www.internetblog.org.uk/post/1555/running-apache-on-another-port/ Wed, 21 Jul 2010 16:51:09 +0000 http://www.internetblog.org.uk/post/1555/running-apache-on-another-port/ Apache featherQuestion: I have one instance of Apache running on the standard port 80, but I would like to run another on port 8080 for a different web application. Is this possible?

Answer: Yes, it is possible, and it is actually easier than you may think. Rather than creating a new install of Apache, all you have to do is create a virtual host that runs on the alternative port.

The first thing you need to do is open your Apache configuration file. On CentOS it is in /etc/httpd/conf/httpd.conf.

You should see the default “Listen” like that looks something like:

Listen 80

This tells Apache to listen to all addresses on port 80. You will want to create virtual hosts and have one of them on port 8080. Many web-based control panels have tools to make it easier. If not, simply make the configuration look like this:

NameVirtualhost 192.168.0.1:80
NameVirtualhost 192.168.0.1:8000

Servername main.servername.com
Serveralias servername.com www.servername.com
DocumentRoot /home/path/documents1/

Servername main.otherservername.com
Serveralias otherservername.com www.otherservername.com
DocumentRoot /home/path/documents2/

]]>
Configuring PHP: php.ini and phpinfo https://www.internetblog.org.uk/post/1515/configuring-php-phpini-and-phpinfo/ Fri, 09 Jul 2010 15:28:40 +0000 http://www.internetblog.org.uk/post/1515/configuring-php-phpini-and-phpinfo/ php logoWith your own dedicated server, many of the configuration tasks fall squarely on your shoulders. PHP is no exception. Most of the PHP configuration settings are found in the php.ini file, which is often located in /etc/php.ini on Linux servers. You must edit the file as root, and any configuration changes will only take effect after you restart your web server.

For example, a common setting that system administrators might want to change is the memory limit, which is generally too low for many web applications. Edit php.ini and find:

memory_limit = 16M

You can then change it to something like:

memory_limit = 64M

Save the file and then restart Apache:

service httpd restart

To see if changes have come into effect and to look at any other configuration settings you might want to change, you can create a phpinfo.php file in a regular document root of one your websites. Edit the file and add the following code:

<?php

phpinfo();

?>

Save it and then load that file from your web browser. It will print out a list of all PHP configuration settings.

]]>
Using GZIP for Faster Websites https://www.internetblog.org.uk/post/1488/using-gzip-for-faster-websites/ Thu, 01 Jul 2010 15:56:55 +0000 http://www.internetblog.org.uk/post/1488/using-gzip-for-faster-websites/ tar/gzip iconGood webmasters and system administrators are always looking for ways to increase efficiency and create faster websites. While much of website speed depends on the speed of the server, network connection, and the design of the site, there are other software tweaks that can add some zip to your site. Gzip compression is one of those tweaks.

Gzip is a free and open compression method, developed by the GNU project (the same project responsible for a good portion of GNU/Linux). Gzip is also an RFC 1952 standard and is the most popular method for web compression. What essentially happens is that the browser (client) contacts the site (host) and receives a header that indicates that the file can be compressed with gzip. If the browser supports gzip, it will respond and retrieve the compressed file, extract the contents, and display. As a result, it takes less time to download content, thus reducing stress on the server.

Gzip can reduce response size by 70%, which means a tremendous amount of savings on bandwidth. Furthermore, nearly 90% of browsers used on the Internet support it, which includes all modern browsers. The older ones that do not support it are fading away quickly. Apache 1.3 uses a module called mod_gzip, while Apache 2 uses one called mod_deflate. Many content management systems have support for gzip compression built into the backend, if the user choose to enable it.

]]>
Apache HTTP Server Optimization: Part 3 https://www.internetblog.org.uk/post/1483/apache-http-server-optimization-part-3/ Wed, 30 Jun 2010 16:11:38 +0000 http://www.internetblog.org.uk/post/1483/apache-http-server-optimization-part-3/ Apache Software Foundation LogoStartServers

You have already configured Apache to control the number of child processes to keep running. This directive will tell Apache how many to start initially when your server first boots. Depending on the level of traffic you expect to get, this number may be low or high. For general purposes, 5 should be sufficient.

StartServers 5

Timeout

This controls the amount of time Apache waits to do a number of tasks. For example, it controls how long it waits for a GET request (i.e. for someone to download a page or images) and also how long it will allow a POST request (i.e. when someone is sending something on a form). The default is 300, but you can lower it to something like 150 to help reduce some server strain when it is waiting on failed attempts and also help prevent DoS attacks on PHP scripts like message forums. Do not set it lower than 90, however, as this may cause some of your site visitors to get timeout errors on working content.

Timeout 150

Once you have made all of the changes you want to make to your Apache configuration file (httpd.conf), you need to restart Apache:

service httpd restart
or
/etc/init.d/httpd restart

These tips are not the only ones you can use to optimize your Apache installation, but they should help you get a head start.

]]>
Apache HTTP Server Optimization: Part 2 https://www.internetblog.org.uk/post/1477/apache-http-server-optimization-part-2/ Tue, 29 Jun 2010 18:27:21 +0000 http://www.internetblog.org.uk/post/1477/apache-http-server-optimization-part-2/ Apache Software Foundation LogoMinSpareServers and MaxSpareServers – Each virtual server on Apache uses its own set of child processes. With these settings, you can control how many spare processes Apache will run while waiting for more requests. When a child process reaches its maximum requests, the spare processes will be used. On a server with more than 2GB of RAM, you can use a higher number of spare servers to increase speed. If you do not have much RAM to spare, setting the max too high can cause problems.

MinSpareServers 5
MaxSpareServers 10

MaxRequestsPerChild – This is the maximum number of requests a child process will receive before it is killed. Make sure this setting is not too low, or it will create unnecessary load on Apache when it restarts the child.

MaxRequestsPerChild 1000 (for 1GB of RAM, 10,000 for 2GB)

KeepAlive and MaxKeepAliveRequests – This determines how long TCP connections are kept open for requests. Setting this higher will speed up HTML and Image downloading, but it can also add stress to the server. Whether or not to use KeepAlive depends on the purpose of your server. For a hosting server with shared hosting accounts, KeepAlive will probably just add too much CPU intensive stress. For a server with a single site that serves a lot of documents and demands speed (something like a wiki), you might want to keep it on.

KeepAlive off (or on – your choice)

]]>
Apache HTTP Server Optimization: Part 1 https://www.internetblog.org.uk/post/1474/apache-http-server-optimization-part-1/ Mon, 28 Jun 2010 16:27:08 +0000 http://www.internetblog.org.uk/post/1474/apache-http-server-optimization-part-1/ Apache Software Foundation LogoWhen running your own dedicated server or even a VPS (virtual private server), it is important make sure your server is running at optimal performance. Apache, the web server of choice for many Linux system administrators, will not automatically make itself stable, secure, and fast. You must do that, and there are several optimization techniques you can use to accomplish it. This week, I will cover a few.

Apache configuration is stored in a file called httpd.conf or apache2.conf, and it most often stored in /etc/httpd or /etc/apache2. To edit the file, you can use “vi” or “nano”.

MaxClients

This setting defines the number of visitors you can have connected at once. You can calculate the visitor capacity your server can support by using this formula:

150 x number of GigaBytes of RAM

For example, a server with 2GB of RAM can have 300 MaxClients. 3GB can support 450. Make it high enough to prevent user timeouts but low enough to avoid causing the server to lockup. A high amount can also make your server an easy target for DoS (Denial of Service) attacks.

ServerLimit

Set this value to the same as MaxClients (i.e. SeverLimit = 150 x number of GB of RAM)

I will continue the series on Apache optimization throughout this week. You can also read your Linux distribution’s specific documentation on Apache to find out specifics, such as where the configuration file is stored.

Source: linuxstuffs.net

]]>
What to do when your server goes down https://www.internetblog.org.uk/post/1427/what-to-do-when-your-server-goes-down/ Mon, 14 Jun 2010 20:57:52 +0000 http://www.internetblog.org.uk/post/1427/what-to-do-when-your-server-goes-down/ Stressed woman
First of all: do not panic. What may appear to be an outage, may actually be an issue with your network connection or Internet congestion. Once you have eliminated the usual suspects, there are a few steps you can take to resolve the issue quickly and get your dedicated server back up and running.

1. Test an SSH connection. If you can still SSH into your server, you most likely just have a software issue. If your web server application (such as Apache) has crashed, a simple restart may fix the problem. If you notice it starting to crash routinely every day or every week, you may have a security exploit.

2. If you cannot SSH into your server, try to ping and traceroute the server. If you get network connections all the way up the traceroute but cannot connect to your server, that means the network is fine, but the physical server may have crashed or been shutdown. Follow the normal procedure for rebooting. If your server is remote, you can ask your web host to reboot it. Some hosts also have automatic reboot switches that you can activate remotely. If something is wrong with the network, check with your host. They may already be diligently trying to fix the problem.

3. If rebooting does not fix the problem, and you cannot access your server, your host may offer you a KVM connection so that you can troubleshoot your server’s network settings.

4. If your host cannot even get the server to start in order to use KVM, they will probably have to re-image your box. This will erase everything, and you will be thankful at this point that you have kept backups of all websites on your server.

Photo Source: stock.xchng

]]>
Change a URL with mod_rewrite https://www.internetblog.org.uk/post/1186/change-a-url-with-mod_rewrite/ Thu, 08 Apr 2010 21:18:07 +0000 http://www.internetblog.org.uk/post/1186/change-a-url-with-mod_rewrite/ Apache Software Foundation LogoQuestion: My current website URL looks like http://mydomain.com/index.php?page=creative. How can I remove the index.php and question mark to make it look more like a regular page address?

Answer: If your web server is Apache, you should be able to do this with mod_rewrite. If you have a shared hosting account, first make sure that your web host has enabled mod_rewrite. Then, create an .htaccess file or edit your current one, placing the following strings inside it:

RewriteEngine on
RewriteRule ^([^/\.]+).html$ index.php?page=$1 [L]

The above will change http://mydomain.com/index.php?page=creative to:

http://mydomain.com/creative.html

This will make it easier for users to remember your URLs and possibly for search engines to index them.

]]>
Open source vs proprietary servers https://www.internetblog.org.uk/post/1137/open-source-vs-proprietary-servers/ Thu, 25 Mar 2010 20:07:07 +0000 http://www.internetblog.org.uk/post/1137/open-source-vs-proprietary-servers/ Open Source logoOpen Source typically refers to software that has code released under some type of free software license (GPL, BSD, Apache, etc.). Users and developers have access to the source code and can modify and redistribute it. Proprietary software usually means the source code is closed and/or the EULA (end user license agreement) forbids redistribution, copying, etc.

The benefit of open source software is that there is a large community involved in supporting it, finding bugs, and making it secure. For a server, this means that your software is not going anywhere even if the hardware vendor goes out of business. With proprietary software, you are at the mercy of the vendor or software developer when you need something fixed or have security problems.

The benefit of proprietary software is usually only evident if you make web applications in-house and do not intend to release that software to the outside public. In such cases you may view the software as your intellectual property. The cost for maintaining each varies depending on the setup and who you have maintaining it. If you or your employees have the knowledge to maintain free software, you can save a considerable amount of money.

]]>
How to redirect a specific IP address https://www.internetblog.org.uk/post/1133/how-to-redirect-a-specific-ip-address/ Wed, 24 Mar 2010 19:00:32 +0000 http://www.internetblog.org.uk/post/1133/how-to-redirect-a-specific-ip-address/ Custom 403 forbidden error page
Question: How do I redirect every visitor to my website except for me?

Answer: There are two methods you can use to accompany the results you want and both involve using an .htaccess file. The first is to redirect your site’s visitors with standard Apache directives:

ErrorDocument 403 http://www.yourdomain.com
Order deny,allow
Deny from all
Allow from 192.168.5.5

This will redirect anyone who visits the site to yourdomain.com, with the exception of your computer or whichever computer uses the stated IP address.

Alternatively, you may use mod_rewrite to achieve similar results:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^192\.168\.5\.5
RewriteCond %{REQUEST_URI} !/temporary-offline\.html$
RewriteRule .* /temporary-offline.html [R=302,L]

Photo Source: Flickr

]]>