Skip to content

Instantly share code, notes, and snippets.

@elcheco
Last active August 31, 2022 10:57
Show Gist options
  • Save elcheco/d7eebcaa8bb2b8afb6171a9ce24e923a to your computer and use it in GitHub Desktop.
Save elcheco/d7eebcaa8bb2b8afb6171a9ce24e923a to your computer and use it in GitHub Desktop.
Laravel Homestead - how to compile openssl on apple silicon m1 - arm64 - add this at the end of your after.sh file
#!/bin/bash
OPENSSL_VERSION=$(openssl version)
if [[ $OPENSSL_VERSION == *"OpenSSL 1.1.1m"* ]]; then
sudo DEBIAN_FRONTEND=noninteractive echo 'OpenSSL already compiled to the correct version' ;
else
cd /home/vagrant
mkdir build
mkdir build/openssl
wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz.sha256
tar -zxf openssl-1.1.1m.tar.gz --directory build/openssl
cd build/openssl/openssl-1.1.1m/
./config --prefix=/opt/openssl --openssldir=/opt/openssl/ssl
make
sudo make install
sudo mv /usr/bin/openssl /usr/bin/openssl.old
sudo mv /usr/bin/c_rehash /usr/bin/c_rehash.old
sudo ln -s /opt/openssl/bin/openssl /usr/bin/openssl
sudo ln -s /opt/openssl/bin/c_rehash /usr/bin/c_rehash
sudo touch /etc/profile.d/openssl.sh
sudo chmod +x /etc/profile.d/openssl.sh
sudo tee -a /etc/profile.d/openssl.sh > /dev/null <<EOT
#!/bin/sh
export LD_LIBRARY_PATH=/opt/openssl/lib:${LD_LIBRARY_PATH}
EOT
echo "Updating configs"
echo "source /etc/profile.d/openssl.sh" | sudo tee -a /etc/bash.bashrc
echo "source /etc/profile.d/openssl.sh" | sudo tee -a /etc/zsh/zprofile
cd /home/vagrant
rm openssl-1.1.1m.tar.gz
rm openssl-1.1.1m.tar.gz.sha256
fi
@skliarovartem
Copy link

mv: rename /usr/bin/openssl to /usr/bin/openssl.old: Operation not permitted
mv: rename /usr/bin/c_rehash to /usr/bin/c_rehash.old: No such file or directory
ln: /usr/bin/openssl: Operation not permitted
ln: /usr/bin/c_rehash: Operation not permitted
touch: /etc/profile.d/openssl.sh: No such file or directory
chmod: /etc/profile.d/openssl.sh: No such file or directory
tee: /etc/profile.d/openssl.sh: No such file or directory
Updating configs
source /etc/profile.d/openssl.sh
tee: /etc/zsh/zprofile: No such file or directory
source /etc/profile.d/openssl.sh
./install_openssl: line 33: cd: /home/vagrant: No such file or directory
rm: openssl-1.1.1m.tar.gz: No such file or directory
rm: openssl-1.1.1m.tar.gz.sha256: No such file or directory

@elcheco
Copy link
Author

elcheco commented Feb 11, 2022

On which Linux distro are you using it? On Vagrant?

@skliarovartem
Copy link

MacOS Monterey

@elcheco
Copy link
Author

elcheco commented Feb 11, 2022

Laravel Homestead - is a pre-build virtual machine using Linux Ubuntu 20.04 for ARM64 - the issue is that OpenSSL doesn't work inside this VM. - i's not code which works on macOS, but in VM running on macOS...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment