-
-
Save einnar82/2c343e0867a20825a596d5d512812da2 to your computer and use it in GitHub Desktop.
SQLSRV PHP 7.2 Drivers that work for Laravel Homestead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Best if added to `after.sh` so that this gets run every time the box is provisioned | |
# composer won't be able to download updates with an active proxy, and will hang trying to get the newest file | |
# You may want to comment this out based on your network configuration | |
sudo bash -c 'echo "export NO_PROXY=*" >> ~/.profile' | |
sudo add-apt-repository ppa:ondrej/php -y | |
sudo apt-get update | |
sudo apt-get install php7.2-dev php7.2-xml mcrypt php-pear php-mbstring unixodbc unixodbc-dev -y --allow-unauthenticated | |
# Set up some pecl information so that it's forced to use php 7.2 instead of defaulting to newest | |
# This is also done with the "-d php_suffix=7.2" on the pecl commands below | |
# Use the below three commands to change it for the whole pecl environment | |
#sudo pecl config-set php_ini /etc/php/7.2/cli/php.ini | |
#sudo pecl config-set php_bin /usr/bin/php7.2 | |
#sudo pear config-set php_suffix 7.2 | |
sudo pecl -d php_suffix=7.2 install sqlsrv-5.3.0 | |
sudo pecl -d php_suffix=7.2 install pdo_sqlsrv-5.3.0 | |
sudo bash -c 'echo "extension=sqlsrv.so" > /etc/php/7.2/mods-available/sqlsrv.ini' | |
sudo bash -c 'echo "extension=pdo_sqlsrv.so" > /etc/php/7.2/mods-available/pdo_sqlsrv.ini' | |
# Link new ini to fpm | |
sudo bash -c 'ln -s /etc/php/7.2/mods-available/sqlsrv.ini /etc/php/7.2/fpm/conf.d/20-sqlsrv.ini' | |
sudo bash -c 'ln -s /etc/php/7.2/mods-available/pdo_sqlsrv.ini /etc/php/7.2/fpm/conf.d/30-pdo_sqlsrv.ini' | |
# Link new ini to cli | |
sudo bash -c 'ln -s /etc/php/7.2/mods-available/sqlsrv.ini /etc/php/7.2/cli/conf.d/20-sqlsrv.ini' | |
sudo bash -c 'ln -s /etc/php/7.2/mods-available/pdo_sqlsrv.ini /etc/php/7.2/cli/conf.d/30-pdo_sqlsrv.ini' | |
sudo service php7.2-fpm restart | |
sudo bash -c 'curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -' | |
### CHOOSE ONE FROM BELOW BASED ON VERSION | |
#Ubuntu 14.04 | |
#sudo bash -c 'curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list' | |
#Ubuntu 16.04 | |
#sudo bash -c 'curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list' | |
#Ubuntu 17.10 | |
#sudo bash -c 'curl https://packages.microsoft.com/config/ubuntu/17.10/prod.list > /etc/apt/sources.list.d/mssql-release.list' | |
#Ubuntu 18.04 | |
sudo bash -c 'curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list' | |
sudo apt-get update | |
sudo ACCEPT_EULA=Y apt-get install msodbcsql17 | |
# Change the default php cli command to point to 7.2 instead of newest | |
sudo update-alternatives --set php /usr/bin/php7.2 | |
# Install Imagick (in case you need it) | |
#sudo apt-get install -y imagemagick php7.2-imagick | |
# Enable PDF for Imagick -- disabled due to security concerns | |
#sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/g' /etc/ImageMagick-6/policy.xml | |
#sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/g' /etc/ImageMagick/policy.xml | |
sudo service php7.2-fpm restart | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment