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

DMA's avatar
Level 2

Mcrypt PHP extension required

So I've got Laravel Homestead set up, installed Composer and Laravel locally and have followed the set up videos by the letter.

I'm following the Larabook video and on the second episode, when installing the way/generators I'm getting the "Mcrypt PHP extension required" error.

I thought the whole point of having Homestead was so that I didn't need to install things like this locally? Or have I missed the point entirely?

I feel like I'm going out of my mind just getting this all set up. I'm by no means a PHP newb but the install process of this hasn't been very straight forward for me so far.

Any ideas? (I'm in a Mac, and can view the larabook example 'welcome' page via the larabook.app:8000 url)

Thanks all

0 likes
23 replies
RayRutjes's avatar

Ssh in your vm then do:

sudo apt-get install php5-mcrypt
DMA's avatar
Level 2

It's already there on the VM.

The issue is that I'm trying to develop the code locally but host it on the vm dev environment as per the tutorial.

When I run PHP artisan locally, that's when I get the error saying I need MCrypt installed.

devjack's avatar
devjack
Best Answer
Level 1

ssh into the homestead box and do the commands there.

1 like
devjack's avatar
ssh vagrant@127.0.0.1 -p 2222

And then do all composer and php artisan commands while connected to the homestead box.

1 like
DMA's avatar
Level 2

Well, now I feel stupid. I didn't realise the connection between the local and VM machines were two-way. From how the description reads, I thought the local machine is mirrored only.

That explains it! Thank you.

devjack's avatar

That's why using homestead is awesome because it means you don't have to install stuff like mcrypt on your native system. Glad it works.

alias vm='ssh vagrant@127.0.0.1 -p 2222'

Set that as an alias then all you do is "vm" when you want to do new commands.

RayRutjes's avatar

When working on a project on a vm, I recommend executing all your commands in your VM. That way, your are assured that when you deploy your application, everything works.

DMA's avatar
Level 2

I've got the SSH alias set up, I just couldn't figure out exactly what Homestead does and doesn't do. I had the impression artisan would hook into Homestead and do the changes on the VM automatically.

Thanks again for the replies.

RayRutjes's avatar

I case you come to the point where you run your tests with selenium, don't forget that you can XFoward your browser session to your client sessions, so your browser will be launched outside the VM. This is very neat.

marcoacm's avatar

Guys, I still don't get this. Please help.

I had a laravel site running on my mac server, and I am trying to run it in a VM. I am getting the Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 error.

I ssh into the vm and ran the command sudo apt-get install php5-mcrypt and got this error The following packages have unmet dependencies: php5-mcrypt : Depends: phpapi-20121212

I am lost. Please help...

wsamoht's avatar

I just upgraded my Homestead vagrant box to v0.4.1 and was getting the error saying mcrypt is required. Homestead is now running PHP 7 so you can't use php5-mcrypt. I am still running Laravel 4.2 so not sure if Laravel 5.2 still uses mcrypt.

Anyways, I ran the following command and it fixed my issue.

sudo apt-get install php7.0-mcrypt
6 likes
simplenotezy's avatar

Running

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade

Fixed the issue

3 likes
Fonteijne's avatar

Canfiax,

Sudo apt-get upgrade

gives me the same error:

E: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/pool/main/o/openssl/libssl-doc_1.0.2e-1+deb.sury.org~trusty+1_all.deb  404  Not Found [IP: 91.189.95.83 80]

E: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/pool/main/o/openssl/libssl-dev_1.0.2e-1+deb.sury.org~trusty+1_amd64.deb  404  Not Found [IP: 91.189.95.83 80]

E: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/pool/main/o/openssl/openssl_1.0.2e-1+deb.sury.org~trusty+1_amd64.deb  404  Not Found [IP: 91.189.95.83 80]

Anyone any suggestions?

1 like
tylermauthe's avatar

I was able to get this working by editing:

/etc/apt/sources.list.d/ondrej-php-7_0-trusty.list

and changing the source to this:

deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main

I figured this out based on this (now deleted) post from the maintainer: https://webcache.googleusercontent.com/search?q=cache:X3m8CmJDMDUJ:https://launchpad.net/~ondrej/%2Barchive/ubuntu/php-7.0+&cd=1&hl=en&ct=clnk&gl=ca

I also tried looking into committing a fix for this, but the Vagrant box for Homestead is captured (not generated) and can only be updated by the owner.

tylermauthe's avatar

It looks like you didn't update the source list correctly, as it is still trying to pull from the outdated URL. Either that or you updated a different file than the one your homestead box is actually using.

in the URL: .../ondrej/php-7.0/ubuntu...

php-7.0 should be just php

gronpen's avatar

Same problem as here, none of the suggested things solved it for me.

armin8800's avatar

guys my problem was that i was using proxy!!!!!! disble your proxy,my problem solved with this!

orrd's avatar

A note for anyone having this problem with the latest Homestead, you now should do "sudo apt-get install mcrypt php7.0-mcrypt php7.1-mcrypt" because the latest Homestead now uses PHP 7.1.

3 likes

Please or to participate in this conversation.