2018

Apache2 MPM ITK on debian 9

This is a secure solution for having a web server for many sites. With this you can specify which server user will be used for which site so apache will execute the code (mainly php) with that user preventing file system access to bad code.

On a fresh Debian 9 installation (with just SSH Server installed) let’s do:

apt-get install libapache2-mpm-itk libapache2-mod-php7.0

We’ll now enable that modules that could be useful and the one necessary:

a2enmod mpm_itk
a2enmod rewrite

Now let’s configure a virtualhost:

cd /etc/apache2/sites-available
touch my_website.conf
nano my_website.conf

and put this inside the file (obviously you can change settings as you need):

<VirtualHost *:80>
        ServerName my_website
        ServerAdmin paolo@my_website
        DocumentRoot /home/www/my_website/home/
        <IfModule mpm_itk_module>
                AssignUserId my_username my_usergroup
        </IfModule>
        <Directory /home/www/my_website/home/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
</VirtualHost>

Let’s activate my_website:

a2ensite my_website

At this point we need to create the user and the group we indicate into the file:

useradd -d /home/www/my_website -s /usr/sbin/nologin my_username

and the folders onto the path:

mkdir /home/www
mkdir /home/www/my_website
mkdir /home/www/my_website/home
cd /home/www/my_website
chown -R my_username:my_username home/

At this point we have a virtualhost that points to a folder path where apache will run scripts as my_username user.

Therefore it’s possibile to configure mysql o any other service to make this webserver richer of functions.

FTP shortcut into Windows Explorer

  1. Open Windows Explorer
  2. Right-click on “My Computer” in the navigation panel on the left
  3. Choose “Add new network location”
  4. Use the wizard to create a new network location for your FTP site
  5. The FTP site will now show up in My Computer as a network location. You can make shortcuts from there by right-clicking on the connection and choosing “send to” > “desktop (as shortcut)”.

Quering AS400 From Powershell via ODBC

Connection String for quering an odbc AS400 database via powershell:


$query = "SELECT * FROM my_table"
$conn = New-Object System.Data.Odbc.OdbcConnection
$conn.ConnectionString = "Driver={iSeries Access ODBC Driver};System=my-as400-server;Uid=User;Pwd=Password;"
$conn.Open()
$cmd = New-Object System.Data.Odbc.OdbcCommand($query, $conn)
$cmd.CommandTimeout = 15
$ds = New-Object system.Data.DataSet
$da = New-Object system.Data.odbc.odbcDataAdapter($cmd)

[void]$da.fill($ds)
$conn.close()

$result = $ds.tables[0]


foreach ($Row in $ds.Tables[0].Rows) {
write-Output "$($Row.field1)"
write-Output "$($Row.field2)"
}