(tested on Ubuntu 22.04 and Apache 2.4.52)
PREMISES:
- here the website is a PHP framework app called appname which has a
/appname/public
folder which is the one to browse - I want also a virtual host
appaname.box
which later will allow to browse tohttp://appname.box
- It will listen on port 80
- Go to
/etc/apache2/sites-available
- Open terminal and execute
sudo cp 000-default.conf appname.box.conf
- Open site config
sudo nano appname.box.conf
and change content to:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName appname.box
ServerAlias appname.box
DocumentRoot "/var/www/appname/public"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/appname/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
- Enable site -
sudo a2ensite appname.box.conf
- Restart Apache -
sudo service apache2 restart
to disable site use
sudo a2dissite appname.box.conf
In the file appname.box.conf the line
ServerAlias appname.box
afterServerAdmin
creates the virtual host
- Go to
/etc
, open terminal and executesudo nano hosts
. - Add line
127.0.0.1 appname.box
- Configure hosts on each computer of your LAN that should use the app
- Restart Apache
Open http://appname.box
in the browser.
if browsing to
http://appname.box
results in a blank empty webpage, change user owner at the app site tree to Apache2 www-data user withchown -R www-data:www-data /path/to/MySite