How to setup a PORT

Hi there,

I need to specify a port on my server (Linux Red Hat 7.2) so that when I access it throgh the browser it forwards me to a certain webpage or folder on the server.

For example, when I write http://domain.com:[FreePort] on the client side, it takes me to an administrator webpage on the server.

How can I do this??

Thanks

Are you using apache as your web server?

if you are using apache then you need
make some modification to your httpd.conf

Here are the modifications

port (specify the port) eg

port 8080

or to have multiple web site with
different port you can use virtual host
here is the modification you will need to make to your httpd.conf

NameVirtualHost 157.x.x.x
<virtualHost 157.x.x.x>
DocumentRoot /usr/local/apache/htdoc
serverName www.domain.com:8080
<virtualHost>

then stopped and started apache

Note
157.x.x.x will be your web server ip address
DocumentRoot will be were your web file are that html, htm or php files

But it displays the HTML pages only, I need to execute PHP code through this port.

When I access a PHP page with the new port only the HTML code is executed!!

Any Idea how to solve this, note that I tried to simulate the port 80 entries, but still I cannot execute PHP using the new port.

Thanks again.

Are you trying to execute php as your default web page?

if you are, then you need to modify this section of your httpd.conf file:

<IfModule mod_dir.c>
DirectoryIndex index.php
</ifModule>

then stop and start apache

Note
index.php will be the name of your php file.
e.g if your php file is called welcome.php

the section of httpd.conf file will look like

<IfModule mod_dir.c>
DirectoryIndex welcome.php
</ifModule>

Hi there..

I checked the httpd.conf file, the entry you mentioned was already added, and it's well functioning through thr ports 80, 443.

The problem was that I cannot execute any .php file using the port I configured, as I mentioned previously, the HTML code is executing perfictly. The problem is with the server side code like PHP.

e.g:-

http://mydomain.com:port/index.html >> This will work perfectly

but

http://mydomain:port/index.php >> only the HTML and non PHP code will be executed, any code between <?php ?> wont execute.

I hope it's clear now, note that I am working on live Web Server and using PHP mainly.

I hope to find a solution for this problem.

Thanks

To be able to excute a php script on apache, you need to add the
following lines to your httpd.conf file

add this line to your Addhandler Directives:

AddHandler cgi-script .cgi .pl

and add this lines to your php Directives:

ScriptAlias /php/ "/usr/local/apache/php"
AddType application/x-httpd-php .php

finally stop and start apache or since you on live web server you
can issue

kill -TERM `cat /usr/local/apache/logs/httpd.pid`

this will cause any changes to apache's httpd.conf file take affect
without stopping apache.

Note
ScriptAlias /php/ "/usr/local/apache/php"

/usr/local/apache/php will be the location of your php file. e.g
if the local of your php is /www your ScriptAlias will be
ScriptAlias /php/ "/www/php"