jdm34's avatar
Level 4

Fresh Install of MacOS High Sierra (13.1) with Laravel Valet, PHP, and Oracle (OCI8)

I documented the steps for my fresh install of High Sierra. Getting Oracle working can be a pain, hopefully this is helpful to someone.

Setting Up Laravel Development Environment On MacOS High Sierra (13.1) with Laravel Valet, PHP, and Oracle (OCI8)

Composer

Follow install instructions at https://getcomposer.org/download/

Make composer available globally

mv composer.phar /usr/local/bin/composer

Make sure the ~/.composer/vendor/bin directory is in your system's "PATH".

nano ~/.bash_profile

Add export PATH="~/.composer/vendor/bin:$PATH"

Homebrew

Follow install instructions at https://brew.sh/

MySQL

brew install mariadb

brew services start mariadb

Login (enter blank password)

mysql -u root -p

Set Password

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

Install Sequel Pro https://sequelpro.com and make sure you can connect:

Host: 127.0.0.1
Username: root
Password: MyNewPass

PHP 7.1

From https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions

brew tap homebrew/php

brew update

brew install php71

sudo chown -R `whoami`:admin /usr/local/share

brew link php71

Install PECL/PEAR

https://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/

curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
  1. Type 1 and press return.
  2. Enter: /usr/local/pear
  3. Type 4 and press return.
  4. Enter: /usr/local/bin
  5. Press return

To verify PEAR, you should be able to type: pear version

Oracle InstantClient

From:

Download:

  • instantclient-basic-macos.x64-12.2.0.1.0.zip
  • instantclient-sqlplus-macos.x64-12.2.0.1.0.zip
  • instantclient-sdk-macos.x64-12.2.0.1.0.zip

Create and unzip all theses files into a the directory ~/lib

sudo ln -s ~/lib/sdk/include/*.h /usr/local/include/
sudo ln -s ~/lib/sqlplus /usr/local/bin/
sudo ln -s ~/lib/*.dylib /usr/local/lib/
sudo ln -s ~/lib/*.dylib.12.1 /usr/local/lib/
sudo ln -s /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib

Install autoconf

brew install autoconf

Install extention with pecl

sudo pecl install oci8

At the prompt enter: instantclient,/usr/local/lib

Add the following line to your php.ini /usr/local/etc/php/7.1/php.ini

extension=oci8.so

Run php -m to display loaded modules. Installation is successful if you see:

oci8

Laravel Valet

https://laravel.com/docs/5.5/valet

  • Install Valet with Composer via composer global require laravel/valet.
  • Run the valet install command. This will configure and install Valet and DnsMasq, and register Valet's daemon to launch when your system starts.

Fix NGINX 504 Gateway Time-out Error

Edit: /usr/local/etc/nginx/valet/valet.conf

Under server {, add

    client_max_body_size 128M;
    client_header_timeout 3000;
    client_body_timeout 3000;
    fastcgi_read_timeout 3000;
    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;

Restart with

valet stop
valet start
0 likes
6 replies
aurawindsurfing's avatar

Hey @jdm34 Thank you so much! I had some issues with setting it up but finally up and running now! Thanks again for this tutorial!

1 like
jdm34's avatar
Level 4

@aurawindsurfing I apologize for the delay responding! I'm glad this was helpful. What were the issues and fixes you ran across?

aurawindsurfing's avatar
Level 50

Hi @jdm34

I was trying to match my version of Oracle XE which is 10.2 and my pecl installation was not working properly, then I tried to use the latest 12.2 and it worked with 10.2 DB, that was the first issue.

Second was to actually test the connectiion, I use additional ssh tunell so I used sqlplus and tested the connection that way. This allowed me to tick those boxes and move on to another oci8 module. The trick is that valet restart does not work as expected and I had to do valet start/stop and also brew services php71 restart to actually enable oci8 extension

Finally when I was sure I have oci8 is running I added yajra/laravel-oci8.

That is it more less. I have to say that I wrote tutorial for myself and will probably appreciate it in few months ;-)

Thank you again for documenting the steps!

1 like
jdm34's avatar
Level 4

Thanks for the update! Hope we help this guy...

relevant xkcd

1 like
aurawindsurfing's avatar

If anyone find himself needing this again here is a new tutorial how to do the same thing but for Mac with Apple Silicon: https://gist.github.com/syahzul/d61d8ccea7c5959a84ed52d14159d8a9

It was not possible to do this as Oracle was missing arm64 client for MacOS. Not the process is much simpler with no symlinks needed.

Thanks to that I also managed to have oci8 installed and compiled and then linked to Herd version of PHP which is precompiled https://herd.laravel.com/docs/1/advanced-usage/php-extensions so now I have oci8 running without even using brew installed version of php ;-)

Please or to participate in this conversation.