Alex Hwang Alex Hwang - 1 year ago 69
Linux Question

Access server using Browser and IP instead of DNS

I want to access my test site from my home by using Firefox and entering IP instead of DNS.

My server is AWS Ubuntu and It has Mysql, Apache2 installed.

I want to access my test site like this in Firefox: x.x.x.x/test

But it showed me 404.

When I type in Firefox like this it works fine: x.x.x.x

I have no idea how to make this work.

Here's what I did in my server.

cd /var/www
sudo mkdir test
sudo cp wordpress test/
cd test
sudo mv -R test public
sudo chown -R www-data:www-data public
sudo chmod -R 775 public
cd /etc/apache2/sites-available
sudo cp 000-default.conf test.conf
sudo vim test.conf

Here is test.conf

<VirtualHost *:80>
ServerName test
ServerAdmin webmaster@localhost
DocumentRoot /var/www/test/public
<Directory /var/www/test/public/>
AllowOverride All

Here goes command again

sudo a2ensite test.conf
sudo service apache2 restart

Now I goto my Firefox and enter my AWS elastic IP in address bar like this:


Which gives me 404

Answer Source

You are doing a mistake in the document root. Change your Apache Configuration to below and restart apache then x.x.x.x/test it will work or type this url x.x.x.x/test/public in your browser.

<VirtualHost *:80>
    ServerName x.x.x.x
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/test
    <Directory /var/www/test>
        AllowOverride All
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download