Running Apache on Another Port

21 Jul, 2010

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/

(0) Comment Categories : VPS & Dedicated, Web servers
Tag: , , , , , ,

Using .htaccess Files on Your Website

2 Sep, 2009

Apache featherQuestion: What Is .htaccess and How Do I Use It?

Answer:

Apache HTTP Server by default is controlled by a single configuration file. On many Linux distributions, the file is called httpd.conf or something similar. If you have a shared hosting account, however, you do not have access to an Apache configuration file. Therefore, if you want Apache to behave a certain way when you are using it, you need to use .htaccess files.

The first thing to know about .htaccess files is that they are hidden. The period in front of the filename makes it a hidden file in Linux. When you type the command “ls” to list the files in a directory, you will not see hidden files. To view them, all you have to do is type “ls -a” which will show all files, including the hidden ones. If you do not have SSH access, you will need to configure your FTP client to see hidden files. The second thing to know about .htaccess is that the configuration options are virtually endless.

If you have a specific need for one, it is good to know how to find them. For example, with many content management systems, they use .htaccess files to create search engine-friendly URLs (i.e. changing index.php?2343546adf&thisandthat2343 to something like homepage.html). They usually provide the file as htaccess.txt. All you have to do is change it to .htaccess. You can do all sorts of things with .htaccess, from making custom Error 404 Not Found documents to setting up a password-protected directory. For an extensive tutorial of .htaccess features, see this site.

(0) Comment Categories : Software, Web Hosting
Tag: , , , , ,