clauddiu's avatar

Homestead and Apache

Howdy,

Can anyone please tell me how to replace Nginx with Apache in Homestead?

Claudiu

0 likes
20 replies
abhimanyusharma003's avatar

SSH into vagrant

vagrant ssh

Stop Nginx

sudo service nginx stop

Remove it

sudo apt-get purge nginx

Update you repos

sudo apt-get update

Install apache

sudo apt-get install apache2

Restart it

sudo service apache2 restart

You are now on Apache server, update the apache conf file as your needs

5 likes
clauddiu's avatar

Hey,

I'll give it a try, thank you! Is there a way to update homestead config instead to use apache by default? Because everything in homestead is based on nginx

bashy's avatar

Nginx is preferred for the front end proxy. Can use Apache behind.

Fusty's avatar

Lots of folks are not in control of the environment their code runs on. Having an apache box set up to point homstead at instead of the default would be very helpful. Thanks abhimanyusharma003 for the useful answer.

osteel's avatar

In case someone winds up on this post (just like me), a clean way to install Apache is to edit the ad hoc after.sh file, which you should find under ~/.homestead/, adding these lines:

sudo apt-get update
sudo apt-get install -y apache2

Then go to ~/Homestead/ and run:

vagrant provision

This will force the Homestead box to re-provision, taking into account the script you've just added.

I wrote a more complete article on the subject, for those interested.

clauddiu's avatar

@bashy So how is your link help us with the Homestead? Makes no sense.. but thanks.

@osteel Good stuff, thank you!

bashy's avatar

I was providing an alternative so you can configure your VM as you like (without changing/adding much). Homestead is made in the thought of Forge being used as the end point.

deep01106's avatar
switch nginx server to apache server
sudo service nginx stop

sudo apt-get purge nginx

sudo apt-get update

sudo apt-get install apache2

sudo service apache2 restart
deep01106's avatar
switch apache server to nginx server
sudo service apache2 stop

sudo apt-get purge apache2 

sudo apt-get update

sudo apt-get install nginx

sudo service nginxrestart
1 like
nodots's avatar

It's now possible to install apache using your Homestead.yaml file. Add a key to your sites called type. Set it to apache. like so:

sites:
    - map: laravel.local
      to: "/home/vagrant/laravel"
      type: apache

Make sure you don't mix up apache and nginx, that won't work.

Run vagrant up and to install apache and provision the right config files.

If it doesn't work, then first make sure to update to the latest version of homestead.

2 likes
Mikeritteronline's avatar

I've followed @nodots recommendation.

Receiving an error.

homestead-7: /tmp/vagrant-shell: line 52: /etc/apache2/sites-available/redacted.dev.conf: No such file or directory ==> homestead-7: ln: ==> homestead-7: failed to create symbolic link '/etc/apache2/sites-enabled/redacted.dev.conf' ==> homestead-7: : No such file or directory

then read this in his comment

"Make sure you don't mix up apache and nginx, that won't work."

So, do ALL of my sites have to be apache?

So, now I'm moving to a per-project install workflow.

impbob36's avatar

I've got apache running in Homestead (change type: apache, destroy box and vagrant up)

I can visit my site's homepage but sub-pages dont work. Switch back to nginx is fine so I assume it's a apache server setting somewhere

Any ideas?

The requested URL /help was not found on this server.

Apache/2.4.18 (Ubuntu) Server at test.dev Port 80
1 like
impbob36's avatar

Never mind ... seems like mod_rewrite was not enabled.

sudo a2enmod rewrite
sudo service apache2 restart
adamdehaven's avatar

You may also need to update your apach 2.conf AllowOverrides from None to all for /var/www

thinsoldier's avatar

So is it not possible to mix types?

Sites defined in Homestead.yaml must be ALL type: apache or ALL type: nginx?

No mixing?

bashy's avatar

@thinsoldier If you wanted multiple web server software running, you'd need to use different ports for each one.

thinsoldier's avatar

@bashy I have installed Homestead from scratch with only the 1 default site configured. I added type=apache to that and then vagrant reload --provision

It is currently installing 10 million things...

Since all of my work is on shared hosting running Apache I decided to try to use type=apache for everything I put into Homestead.

It seems to have worked this time.

Please or to participate in this conversation.