Install Nextcloud on Ubuntu 16

In this post, we will setup a server and install Nextcloud on it. My distribution of choice is Ubuntu Server, version 16.04 LTS. I happen to like the non-GUI interface, so everything will be done in the terminal. I will make this as short as possible. Let’s start!

The server has 1 virtual processor and 1 GB of memory. More than enough for a home test server running Nextcloud. Use the default settings during install. At the end, when asked about packages to add, choose these three:

When asked, set a password for MySQL root user and remember it.

After installation, update the server:

sudo apt update
sudo apt upgrade

There is a good idea to set up a static IP for the server. Open and edit this file:

sudo nano /etc/network/interfaces

Replace this:

iface [your adapter name] inet dhcp

with this:

iface [your adapter name] inet static
address 192.168.1.10 (or whatever IP you wish to assign to it)
netmask 255.255.255.0
gateway 192.168.1.1 (the address of your router)
dns-nameservers 192.168.1.1

Save and close the file with Ctrl-O and Ctrl-X. Reboot the server to reflect the changes.

Next, we are going to create a MySQL database for Nextcloud:

sudo mysql -u root -p
create database nextcloud;
GRANT ALL ON nextcloud.* TO ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘password’;
flush privileges;
exit

Choose your own database name, user and password. We will need them later.
A good practice is to secure the mysql installation. Run this command:

sudo mysql_secure_installation

Answer no the the first two questions and yes to the rest.

Next, we need to install a set of php modules needed by Nextcloud:

sudo apt-get install php-gd php-json php-curl php-mbstring
sudo apt-get install php-intl php-mcrypt php-imagick php-xml php-zip

Also, enable two additional Apache mods and restart Apache to make them available:

sudo a2enmod rewrite headers

sudo service apache2 restart

We are ready now to download and install Nextcloud. We will use the following commands:

cd /var/www/html
sudo wget https://download.nextcloud.com/server/releases/latest-13.tar.bz2
sudo tar -jxvf latest-13.tar.bz2
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo rm latest-13.tar.bz2

All done in the command line. Reboot the server and then open the IP address in a browser, like this:

192.168.1.10/nextcloud  (or whatever IP you assigned to it earlier)

You will see the initial configuration for Nextcloud.

Create a user and a password in the first window and enter the database details in the second one. Leave the Data folder as is. Click on Finish setup.

Create a shortcut with Group Policy

In this post, we will create a shortcut to an internet address and place it on the desktop for all the users in a Windows  domain.

First, connect to the Domain Controller, and open Group Policy Management. Right click on the domain name, and select Create a GPO in this domain and link it here.

Give it a name and click OK. Then, right click on the newly created GPO and select Edit.

Navigate to User Configuration – Preferences – Windows Settings – Shortcuts and select New Shortcut.

Then, populate the fields to match your requirements: the name of the shortcut, the target type (URL), the location where it will appear on user’s computers, and, if you have a customized icon, the file path for it.

Also, in the Common tab, make sure to select Run in logged-in user’s context.

Click OK, close GPO Management and restart your computer, NOT the domain controller.

Map a shared folder with Group Policy

In this post, we will see how we can map a shared folder for all the users in an Active Directory domain, using Group Policy Objects.

First, we need to have a domain controller and a computer join to the domain.

Next, we create the shared folder, that must be on the DC itself or on another server joined to the domain. A standard way to allocate the sharing permissions is to give domain users Read/Write rights and domain admins Full rights. Both tabs, Permissions and Share, should have the same two entries.

Next, connect to the Domain Controller, and open Group Policy Management. Right click on the domain name, and select Create a GPO in this domain and link it here.

Give it a name and click OK. Then, right click on the newly created GPO and select Edit.

Navigate to User Configuration – Preferences – Windows Settings – Drive Maps

Select New – Mapped Drive and click OK.

Type the location of the shared folder, chose a letter for the drive and select Show this drive, on the left side.

After that, go to the Common tab, and select Run in logged-on user’s context.

Click OK, close, and restart the computer, NOT the domain controller.

Install WordPress on Ubuntu 16

In this post,  we will setup a server and install WordPress on it. My distribution of choice is Ubuntu Server, version 16.04 LTS. I happen to like the non-GUI interface, so everything will be done in the terminal. I will make this as short as possible. Let’s start!

The server has 1 virtual processor and 1 GB of memory. More than enough for a home test server running WordPress. Use the default settings during install. At the end, when asked about packages to add, choose these three:

When asked, set a password for MySQL root user and remember it.

After installation, update the server:

sudo apt update
sudo apt upgrade

There is a good idea to set up a static IP for the server. Open and edit this file:

sudo nano /etc/network/interfaces

Replace this:

iface [your adapter name] inet dhcp

with this:

iface [your adapter name] inet static
address 192.168.1.10 (or whatever IP you wish to assign to it)
netmask 255.255.255.0
gateway 192.168.1.1 (the address of your router)
dns-nameservers 192.168.1.1

Save and close the file with Ctrl-O and Ctrl-X. Reboot the server to reflect the changes.

Next, we are going to create a MySQL database for WordPress:

sudo mysql -u root -p
create database wordpress;
GRANT ALL ON wordpress.* TO ‘wordpressuser’@’localhost’ IDENTIFIED BY ‘password’;
flush privileges;
exit

Choose your own database name, user and password. We will need them later.
A good practice is to secure the mysql installation. Run this command:

sudo mysql_secure_installation

Answer no the the first two questions and yes to the rest.

Next, edit the Apache configuration file:

sudo nano /etc/apache2/apache2.conf

Copy and paste the following block of text at the end of the file:

<Directory /var/www/html/>
AllowOverride All
</Directory>

Ctrl-O to save the changes, and Ctrl-X to close the file.
Next step is to enable mod_rewrite module:

sudo a2enmod rewrite
sudo systemctl restart apache2

Now comes the beautiful part of installing WordPress:

wget -c http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

After downloading and unzipping the files, we will copy everything in the web directory:

sudo rsync -av wordpress/* /var/www/html/

Give the right permissions for the web directory:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

We need to rename the sample configuration file and edit it:

cd  var/www/html
sudo mv wp-config-sample.php wp-config.php
sudo nano var/www/html/wp-config.php

Put the values that you choose earlier for your database_name, db_user and db-password. Leave everything else as it is.

Save and close the file.

One more thing: remove the index.html file from the web directory, since wordpress uses an index.php to run.

sudo rm index.html

Reboot.

After reboot, open the IP address of your server in a browser, fill out the required fields, click on Install WordPress and start blogging !