Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

@bashy More Apache weirdness. Localhost in the browser points to my Laravel site. But Mysite in the browser gets me "site not found".

never the less,

Document root /var/www/MySite/public

Only if I turn on in etc/hosts 127.0.0.1 MySite

do I then see it both in localhost as well as Mysite in the browser.

Ideas ?

Many thanks !

bashy's avatar

Okay so list what domains you want routing to where and I'll help. Also I'd use lowercase for folder names

bashy's avatar

Glad you got it working but that's not a good way to do it.

vincej's avatar
Level 15

I am always keen to learn about a better way. Configuring Apache for Linux Mint (Ubuntu 14) has been a challenge. Every single one of the tutorials I have looked at did not work. Even the forums on Apache could not not solve the problem.

So if it's easy to fix let me know :o)

thanks

keevitaja's avatar
Level 13

Ok. Lets say you want to have a apache virtual host blog.local

  1. create directory
/var/www/blog
  1. create apache vhost config file /etc/apache2/sites-available/blog.conf(needs root)
<VirtualHost *:80>
 ServerName blog.local
 ServerAdmin your@email.com
 DocumentRoot /var/www/blog

 <Directory /var/www/blog>
         Options +Indexes +FollowSymLinks +MultiViews
         AllowOverride All
         Order allow,deny
         Allow from all
         Require all granted
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
  1. enable vhost
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/blog.conf .
  1. add /etc/hosts entry (needs root)
127.0.0.1   blog.local
  1. restart apache
sudo service apache2 restart

And i think thats it! At least it works in ubuntu!

1 like
bashy's avatar

The above + repeat for multiple sites (domains) pointing to other folders. Just edit the directories.

vincej's avatar
Level 15

You guys are Mega ! Thanks a billion Keevitaja, it worked first time ! Thank you Bashy for your generous offer of help. This Linux thing is going to take me a little time. But I'll get there.

One of the mysteries to me is that I researched this to death and no where did I see one major yet simple change. You create your server name with .local on the end. Similarly I don't not recall seeing the directory parameters you use. That's Great !

Many Thanks !! I don't know how to most fairly award the points but as Bashy has a ton already, I'll give them to Keevitaja :o)

vincej's avatar
Level 15

Sorry Guys - I spoke too soon ... before I did an Apache restart - apologies. I just don't get it. I'm getting nothing off my browser now, just a "page not available". I realise my earlier remark about the .local is misplaced and in fact makes no difference. My root directory is properly named.

The only difference in my workflow has been the use of sudo a2ensite auburntree.conf, which gives the same result as ln -s

I think I followed it exactly - this is what I've got on my sites-enabled and sites-available.

<VirtualHost *:80>
 ServerAdmin vincej@shaw.ca
 ServerName auburntree.local
 DocumentRoot /var/www/auburntree/public

<Directory /var/www/auburntree/public>
    Options +Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

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

My Host file:

127.0.0.1   auburntree.local

keevitaja's avatar

Check if you have

/etc/apache2/sites-available/auburntree.conf

and then

/etc/apache2/sites-enabled/auburntree.conf linked to /etc/apache2/sites-available/auburntree.conf

also if you have

127.0.0.1 auburntree.local

in /etc/hosts file, then it should at least point to whatever you get with browsing the localhost

vincej's avatar
Level 15

Thanks Bashy - I will give that a look -

Ok - rather than endlessly amend the existing .conf I decided to create a fresh one, following Keevitaja's work flow exactly .... and it works flawlessly !

I want to rebuild those sites. Now ... in a Linux world can I just go and delete the existing .conf files without any negative repercussions ? Or is there a set of commands to do it properly.

Again - Many thanks !

keevitaja's avatar

No set of commands needed. Just rm and that's it!

To remove a vhost, delete config file and the link with the /var/www/folder. Remove entry in /etc/hosts and restart apache.

EDIT:

One more thing which helps you a lot!

By default apache runs as root. It is fine, but when you upload something it cannot be removed/modified with your user. So i run apache as myself/keevitaja. That way i do not have to worrie about files that are created by apache. Files like cache, uploads etc...

in /etc/apache2/envvars

export APACHE_RUN_USER=keevitaja
export APACHE_RUN_GROUP=keevitaja

I think no more config is needed... i have not done that for a long time.

And remember to restart apache after each configuration change!

vincej's avatar
Level 15

thanks ... "delete ... the link with the www/folder" . I wanted to keep the auburntree folder and just create a new conf file. No probs right ?

keevitaja's avatar

No problem. Keep the files and just create new config!

bashy's avatar

Also note, running the web server on the same user as your login will have security issues (if a script has an exploit in it). One of the many reasons why there's an www-data and nginx/apache system users. They do not have SSH login or ability to change system wide settings.

vincej's avatar
Level 15

Thanks for that - I run this as a dev server behind a router, so perhaps naively, I dont feel too vulnerable

In the end I got it all working, however, in the process I learned that applying a new conf file to an old root doc does not work, at least not with L4 inside. So I reinstalled a fresh L4 with composer and made a fresh conf and it is now all working ! Hallelujah ! Big Thanks !

One thing I find about Laravel & Laracasts is that there is so much in it, it is hard to see the wood for the trees. When I learned CodeIgniter, it was easy, paint by numbers. Start to learn on chapter 1 and then go to Chapter 2. Even building apps with CI is easy as step 1,2,3.

With LC, once you get past the basic lessons, even the CodeBright lessons, there are so many directions you can go in, you can't see the wood for all the trees.

There is a book opportunity in this, "Start here, go there with Laravel" :o)

bashy's avatar

Everyone is learning new things every day :)

Just wait until you move to Nginx :P start all over again for the config setup for websites!

vincej's avatar
Level 15

let's hope my isp doesn't go to Nginx ... if they do, I'll have no choice.

keevitaja's avatar

@bashy you are too paranoid! And furthermore ssh is not enabled by default as there is no need for that.

For a local desktop machine it is OK to run apache as regular user!

bashy's avatar

For local with no access from internet, sure! I meant anything that is open to the world wide web :)

vincej's avatar
Level 15

@Shovels Hi - four months since I started this post, and here is an update. As a fellow Windows user, you made some good points:

I found myself unable to use Photoshop, Evernote and a couple of other Windows/Mac only apps. I know there are > alternatives, and WINE, but it was a struggle. Plus I run three monitors, and trying to get that running on Linux is not straight-forward.

As a fellow Windows user, I wished to report to you that today I finally completed the total rebuild of my dev. machine on Linux Mint 17.1. No big deal perhaps, but, in the process, I also installed a 250GB SSD whilst keeping my HHD with all the existing Windows files. My primary dev. machine is now LM17.1 with PhpStorm + Laravel. Now I boot straight off the SSD into Linux in 10 seconds from cold... no more dual boot hassles.

BUT I also installed VirtualBox with Win7 guest on it, so that now I can still access all the Win7 files off the HDD. I have Photoshop, Sony Movie Studio, all my old Outlook files ... everything you could wish for in Windows, which runs faster now than natively! AND I have a 3 x 24 inch screens set up. When Windows is turned on, I give it a whole screen.

Bottom line: I am really glad I made the move. Being able to keep up with Jeffrey's lessons without having to translate into "Windows" is a relief, and I have everything I would want. Personally I would stick to Linux .. all the productivity apps are built for Linux not Mac OS .. and if you have a Mac, you only end up using Linux after all.

The only down side ? It took a bit of work to get it all together, but well worth it.

Cheers !

1 like
Shovels's avatar

@vincej - Thanks for the update! Would you be able to email me at neal [@] netgorilla.co.uk - If it's okay I would love to pick your brains on a couple of setup issues I faced.

Previous

Please or to participate in this conversation.