PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] What is the right way to configure Apache to serve a project over a local network

 September 21, 2022     apache, ip, virtual-hosts, virtualhost     No comments   

Issue

I have my project running in an apache virtual host. the name of the conf file is btapp.local.conf this is the content of the file

<VirtualHost *:80>
ServerName btapp.local
DocumentRoot /var/www/btapp/app/webroot


<Directory /var/www/btapp/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

My local network IP is addr:192.168.3.218 But when i am trying to access the project from the network by 192.168.3.218/btapp.local I am getting the error The requested URL /btapp.local was not found on this server. As of now, I have edited my 000-default.conf and put the content of btapp.local.conf (basically i have pointed default host to the path of the project) I want to know the follwing things
1.Is this the right way to serve a project over the network?
2.Are there other ways that I can use to serve the project through the network without modifying the 000-default.conf file?

EDIT this is my /etc/hosts file content

127.0.0.1 localhost
127.0.1.1 bonnie
127.0.1.1 btapp.local

Solution

The right way can be to set up a virtual host and run it in a different port. To set up a port mention the port in the ports.conf file in the etc/apache2 path

this is the ports.conf file that i am using

Listen 80
Listen 81

<IfModule ssl_module>
   Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

In this case, I have set 81 as a new port configure a virtual host to run on this port this is my 000-default.conf in the /etc/apache2/sites-available path

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot /var/www/btapp/app/webroot
    <Directory /var/www/btapp/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

1. So, to answer my 1st question, yes there is a way to serve the project over the network without overwriting the default configuration of local port 80
2.default.conf file doesnot need to be modified if the virtual host is created into a seperate conf.



Answered By - isnvi23h4
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing