Changing Apache to only use Localhost

Some windows configurations will block XAMPP, specifically the Apache web server on port 80. Most people use hardware firewalls on their routers instead of the windows firewall but if you have windows security problems the following may help:

You can change the Apache web server so that it is ‘bound’ only to the loopback network interface known as localhost which has an IP address of 127.0.0.1

To do this:

  1. Insert your XAMPP usb stick
  2. Goto the xampp\apache\conf folder
  3. Select the httpd.conf file and right-click
  4. Select Copy from the menu
  5. Select Edit, Paste or press CTRL C to make a backup copy of the Apache configuration file
  6. Now select httpd.conf, right-click and choose Edit from the menu
  7. Scroll down the file and find the Listen section, which looks like this:

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.

Find the line with Listen 80 and put a # in front of it to turn it into a comment. Type in a new line:

Listen 127.0.0.1:80

and select File, Save from the menu. This means the Apache web server will only listen for requests coming from localhost, the machine you are on – not for requests coming over the network or internet. This is how it should be for a development environment. We were going to cover this in the session on security but it might help those who are having trouble running XAMPP under specific windows setups.

2 Responses to Changing Apache to only use Localhost

  1. jzhao92 says:

    Hi Gord, I just don’t know how to start a new post, so I am writing my question here.
    On slide 15, session 04, there is one line ” VALUES (topicID,’Business’); “. Why is it not topic but topicID? Does topicID as PK refer to integrals? The commend quoted here seems to give topicID an non-integral value – Business.
    Thanks,

    Jin

    • lis9710 says:

      Jin – The topics table has 2 fields, a primary key of topicID (which is a number) and topics (which contains the text of the topic such as Business, Romance, Technical).

      The command inserts 2 values into the topics table.

      Since the table uses auto number for the primary key we do not insert a value (such as 12), we let the database handle it and assign the next available unique ID number. This is done by using the name of the field which is topicID instead of a value such as 12. Note that we could specify a real value with VALUES(12,’Business’); which would insert a PK of 12 but there is no need.

      The second value is text (business) to be inserted into the topic field. The end result is a topic of business with a primary key assigned by the database.

Leave a comment