Hi,

Like everyone, I access my apache server by typing http://localhost or http://127.0.0.1 but what I want is that I want to access it from outside by typing a domain name like

I've added my current IP information for you.

This is what I need. I'll be much appreciated your help. Thanks in advance

ubuntu@ubuntu:~$ ifconfig | grep inet
          inet addr:192.168.100.158  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::230:5ff:feec:bbb2/64 Scope:Link
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host

Dani AI

Generated

Good practical follow‑up that complements the networking hints from , the /etc/hosts note from , and the registrar/router comments from . Assuming the domain already resolves to the site’s public address (or uses a dynamic‑host service as mentioned), the remaining work is on the host: configure Apache to serve the project, lock down file ownership and permissions, enable necessary modules, and place TLS in front of the site. The snippets below are ready to drop into an Ubuntu/Debian LAMP host.

Example VirtualHost (save as /etc/apache2/sites-available/myproject.conf):

<VirtualHost *:80>
    ServerName my.domain.com
    ServerAlias www.my.domain.com
    DocumentRoot /var/www/myproject

    <Directory /var/www/myproject>
        Options FollowSymLinks
        AllowOverride All
        # Apache 2.4:
        Require all granted
        # For Apache 2.2 replace the above line with:
        # Order allow,deny
        # Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/myproject-error.log
    CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined
</VirtualHost>

Common server tasks (example commands — adapt to the distro/version):

chown -R www-data:www-data /var/www/myproject
find /var/www/myproject -type d -exec chmod 755 {} \;
find /var/www/myproject -type f -exec chmod 644 {} \;
a2ensite myproject.conf
a2enmod rewrite ssl
service apache2 reload

Key operational notes and troubleshooting: reserve a fixed LAN IP (DHCP reservation) for the server so router rules remain valid; open/allow ports 80 and 443 in the host firewall; obtain an automated TLS cert (Let’s Encrypt via certbot is the usual choice) and automate renewal; expect that accessing the public name from inside the same LAN may fail on routers without hairpin NAT — test from an external network. If the ISP blocks incoming HTTP(S) or provides Carrier‑Grade NAT, use a public reverse proxy, a small VPS as a tunnel endpoint, or a tunneling service for exposure. Finally, keep the server software updated, limit admin interfaces to trusted IPs, and log/monitor access.

Recommended Answers

All 8 Replies

Hi,

Like everyone, I access my apache server by typing http://localhost or http://127.0.0.1 but what I want is that I want to access it from outside by typing a domain name like

I've added my current IP information for you.

This is what I need. I'll be much appreciated your help. Thanks in advance

ubuntu@ubuntu:~$ ifconfig | grep inet
          inet addr:192.168.100.158  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::230:5ff:feec:bbb2/64 Scope:Link
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host

Check out https://www.dyndns.com. this enables you to point a web address like to your computer. hold on... you will not be able to access the webpage hosted at your localhost yet. if you have a dynamic ip address which will be assigned to you by the ISP then the modem/router has to configured to work with dyndns.com so that each time your IP address is changed it will reflect in the dynDNS. next is to port forward the requests to the port 80 of your computer. inbound requests form the internet will reach the modem/router at these requests should be forwarded to inet addr: port:80. follow the router manufacturers guide to open the ports. sometimes you may have to open the ports in the firewall too.

Can I not do this without using websites like you've pointed out?

i'm afraid you cannot.

I guess you could put your in your /etc/hosts file, but that would only work on the computers where you put this. Not from anywhere else.

I am just mentioning this in case you have not done so but you would also need to register your domain name with a registrar like godaddy or networksolutions or one of the many other registrars so your domainname belongs to you and cannot be redirected somewhere else.

Ok, you got my mind opened now.

I've just bought a domain name and have set up my Ubuntu Desktop 10.10 with LAMP runing on it. What do I do in order to use my localy hosted project stored in /var/www/myproject when I type my domain anywhere in the world?

Guys thanks in advance

Hello,

First you have to figure out what the IP address of your router is and/or what the internet sees your address as. Go to one of the reporting pages like http://whatismyipaddress.com to find out. Once you have that address (which may change if your router is using DHCP on the WAN) go to your registrar and point your domain to that IP address. OR use the site that rje7 listed (which is really the way to go) and follow the instructions on setting up the registrar information.

Check on your router and make sure that you either allow port 80 through to the internal IP address of your Ubuntu server or many routers have an option for setting up a DMZ host IP which again would be the server IP ().

Then call a friend and have them ping (or use nslookup ) your domain name

ping <yourdomainname.com>     pings your domain
nslookup <yourdomainname.com>     asks your local DNS for the info
nslookup <yourdomainname.com> <specificnameserver.com>     asks the specific nameserver for the info

and see what they get. Remember it can take 24 hours for DNS information to update accross the net. ping or nslookup will work from either Windows command prompt or Linux shell.

Thanks rch. I'll do that when I get back from hoiday.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.