Home > Installation / SQL Server On Linux
The following is a guide for installing SQL Server on Ubuntu Linux (20.04 LTS). Since this guide was created other distributions may be supported, so please check that distribution documentation.
Common Commands:
sudo systemctl restart apache2
azuredatastudio --disable-gpu
Links:
https://support.rackspace.com/how-to/set-up-apache-virtual-hosts-on-ubuntu/
Specific to Ubuntu
https://graspingtech.com/apache-virtual-hosts-ubuntu/
#
Apache
#
sudo apt install apache2
We can install our web content (RackForms and so on) wherever we like, but typically this would be in /var/www or in my case, the ~/Documents folder (because I'm on the Desktop version of Ubuntu). Regardless of where it is, we first want to update our RackForms folder permissions. To do so use the Terminal to navigate to the folder that contains our extracted rackforms.zip file and run:
sudo chgrp -R www-data ./rackforms/
sudo chmod -R 755 ./rackforms/
Next, update permissions on these three files and locations using the command: sudo
chmod -R 775 ->
/output/
/app/config.php
/app/movefiles/config.php
Understanding These Commands:
To serve content Apache must first access that content on the local drive. As our files and folders all have prmissions attached, we first need to know what the Apache process runs as.
To do this, first, find our Apache user, which is defined in /etc/apache2/envvars:
This Gives us:
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
Thus, when Apache serves content it will do so as the user www-data. This is why we updated the Documents folder to use www-data as it's group above.
Of course in the code above we're exporting a value, we actually connect this to an
Apache instance in /etc/apache2/apache2.conf via: User
${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
So as far as permissions are concered we should be set, it's just nice to know where and how these values are set!
Next, create the Directory entry for our web content location in /etc/apache2/apache2.conf:
Critically, these next few steps need to be updated to match your host name. In my case I'm using pro, your value will be different. Thus, anywhere you see the text pro, replace it with your site name or this will not work!
<Directory /home/<your user name>/Documents/htdocs/rackforms/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Enable virtual site:
Navigate to:
/etc/apache2/sites-available/
# Copy the existing default file to create a new virtual host file:
sudo cp 000-default.conf pro.conf
Update this file to point to the proper DocumentRoot, and uncomment the ServerName directive and set it's value to your sites host name. For example, my vhst file is:
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port t> # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName pro ServerAdmin webmaster@localhost DocumentRoot /home/grdinic/Documents/htdocs/rackforms
sudo a2ensite pro
service apache2 reload
The last step in this process, depending on how we're setting up our host name, is to make
sure we have an entry in the /etc/hosts
file. So in my case I have a local
install using the host name pro, so I open the hosts file and add a line:
127.0.0.1 pro
sudo systemctl restart apache2
#
MySQL (Optional)
#
sudo apt-get install mysql-server
root user password: <as you set it, always rememeber to write it down!>
#
PHP Items
#
Important: When you see a reference to php7.4 in this code, please note you must change that to whatever version you're using.
Base Install:
sudo apt-get install php libapache2-mod-php php-mysql php-xml php-mbstring
php-gd
If PHP isn't enabled after this step, do so with:
sudo a2enmod php7.4
systemctl restart apache2
Note our php.ini (config) should be at: /etc/php/7.4/apache2/php.ini
At this point we should have a working PHP web server. Test this by navigating to your given host in the web browser, the RackForms installer should show.
#
SQL Server
#
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add
-
sudo add-apt-repository "$(wget -qO-
https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
sudo apt install mssql-server
The above commands should work on Ubuntu 18 and higher, though just in case you get stuck here are a few links with more detail:
After the install comples, run sudo /opt/mssql/bin/mssql-conf setup
, and enter
(2) for local installs:
Edition: (2) Developer
u: SA
p: <set a password>
Be sure to save your admin password somwehere safe!
Next, we'll install the SQL Server tools. At this point it's wise to follow the links above for Ubuntu 16.x and 18.x, these instructions assume 20.04:
sudo apt install curl
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/19.10/prod.list >
/etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo ACCEPT_EULA=Y apt install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Connect Via Command Line Tools:
sqlcmd -S localhost -U SA -P '<your password>'
-- Commands --
The command structure here is a bit strange, we need to enter a command and then hit enter. Then type the word GO and hit enter again. Thus, when you see the first line to CREATE DATABASE, take that as
CREATE DATABASE rackforms; <hit enter> GO
CREATE LOGIN rackforms WITH PASSWORD = 'test101!'; <hit enter> GO
CREATE USER rackforms for login rackforms; <hit enter> GO
Use rackforms; <hit enter>
GO
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name =
N'rackforms')<hit enter>
BEGIN <hit enter>
CREATE USER [rackforms] FOR LOGIN [rackforms] <hit enter>
EXEC sp_addrolemember N'db_owner', N'rackforms' <hit enter>
END; <hit enter>
GO
#
Azure Data Studio
#
Point your browser to this direct download link: https://go.microsoft.com/fwlink/?linkid=2151506
cd ~
sudo dpkg -i ./Downloads/azuredatastudio-linux-<version string>.deb
azuredatastudio
#
SQL Server ODBC:
#
/etc/odbcinst.ini
#
Install PHP SQL Server Driver
#
sudo apt-get install php-pear
sudo apt-get install php7.4-dev
sudo pecl install sqlsrv
Note: In our case, the php.ini file is located at:
/etc/php/7.4/apache2/php.ini
Open thedocument using sudo, and look for the block of items that star with
;extension=bz2
, then add the following lines below the last entry:
Add "extension=sqlsrv.so"
to php.ini
Add "extension=pdo_sqlsrv.so"
to php.ini
Finally, run: sudo service apache2 reload
At this point our install should be complete, we can now run the RackForms installer, making sure to select MSSQL from the Database Vendor dropdown.