<\/span><\/h2>\nLog in to your Debian 9 server with SSH as the root user, or as a user that has sudo privileges:<\/p>\n
ssh root@IP_Address -p Port_number<\/pre>\nBefore we can start with the installation of Open Web Analytics, we have to make sure that all Debian OS packages installed on the server are up-to-date. We can do this by running the following commands:<\/p>\n
sudo apt-get update\r\nsudo apt-get upgrade<\/pre>\n<\/span>Step 2: Install Apache<\/span><\/h2>\nApache is a user-friendly and highly popular web server available on almost all Linux distributions. This is the web server we will be using for this tutorial.<\/p>\n
First, check whether Apache is already installed and running on your Debian server:<\/p>\n
ps aux | grep apache2<\/pre>\nWe can also check if there are Apache2 packages installed on the server:<\/p>\n
dpkg -l | grep apache2<\/pre>\nIf Apache is already installed on the server, we can skip the Apache installation steps and proceed with step 4, which is installing PHP.
\nIf Apache is not installed on your system, we can install it using:<\/p>\n
apt-get install apache2<\/pre>\nOnce installed, start the Apache server and enable it to start on server boot:<\/p>\n
systemctl start apache2\r\nsystemctl enable apache2<\/pre>\n<\/span>Step 3: Enable the Apache ‘Rewrite’ Module<\/span><\/h2>\nEnable Apache’s rewrite<\/code> module, if not already enabled:<\/p>\na2enmod rewrite<\/pre>\nRestart the Apache service for the changes to take effect:<\/p>\n
systemctl restart apache2<\/pre>\n<\/span>Step 4: Install PHP and Required PHP extensions<\/span><\/h2>\nThe default PHP version available from the official Debian 9 repository is PHP 7.0. Install PHP 7.0, along with some PHP extensions that are required for Open Web Analytics to function correctly:<\/p>\n
sudo apt-get update\r\nsudo apt-get install php7.0 php7.0-common php7.0-curl php7.0-gd php7.0-curl php7.0-dom php7.0-mysql php7.0-intl\r\nsudo a2enmod php7.0<\/pre>\n<\/span>Step 5: Configure PHP<\/span><\/h2>\nLocate the PHP configuration file:<\/p>\n
php -c \/etc\/php\/7.0\/apache2\/ -i |grep \"Loaded Configuration File\"<\/pre>\nThe output should be something like this:<\/p>\n
Loaded Configuration File => \/etc\/php\/7.0\/apache2\/php.ini<\/pre>\nEdit the php.ini<\/code> configuration file using your preferred text editor:<\/p>\nvi \/etc\/php\/7.0\/apache2\/php.ini<\/pre>\nAdd\/modify the following options:<\/p>\n
memory_limit = 256M \r\nfile_uploads = On\t\r\nallow_url_fopen = On\r\nallow_url_include = Off\r\npost_max_size 32M\r\nupload_max_filesize = 8M\t\r\nmax_execution_time = 300\r\ndefault_charset = \"UTF-8\"\r\ndate.timezone = \"America\/Chicago\"<\/pre>\n<\/span>Step 6: Create a Virtual Host in Apache<\/span><\/h2>\nIn order to be able to access Open Web Analytics using a domain name, we need to create a virtual host in Apache for your domain.<\/p>\n
Note:<\/strong> you must already have a domain registered and set up for your server.<\/p>\nOpen the file using your preferred text editor:<\/p>\n
vi \/etc\/apache2\/sites-available\/your-domain.com<\/span>.conf<\/pre>\nThen add the following content to the file:<\/p>\n
<VirtualHost *:80>\r\n\r\nServerAdmin admin@your-domain.com<\/span>\r\nServerName your-domain.com<\/code>\r\nServerAlias www.your-domain.com<\/code>\r\nDocumentRoot \/var\/www\/html\/your-domain.com<\/span>\r\n\r\n<Directory \/var\/www\/html\/your-domain.com<\/span>>\r\n Options Indexes FollowSymLinks\r\n AllowOverride All\r\n Require all granted\r\n<\/Directory>\r\n\r\nErrorLog ${APACHE_LOG_DIR}\/your-domain.com<\/span>_error.log \r\nCustomLog ${APACHE_LOG_DIR}\/your-domain.com<\/span>_access.log combined \r\n<\/VirtualHost><\/pre>\nRemember to replace ‘your-domain.com’ with your actual domain name.<\/p>\n
To enable the virtual host that we have just created, run the following command:<\/p>\n
a2ensite your-domain.com<\/span>.conf<\/pre>\nThen, disable the default Apache configuration:<\/p>\n
a2dissite 000-default.conf<\/pre>\nRestart Apache service for the changes to take effect:<\/p>\n
systemctl restart apache2<\/pre>\n<\/span>Step 7: Install MariaDB<\/span><\/h2>\nWe will use MariaDB as a database engine. We can install MariaDB server from the Debian 9 base repository using the following commands:<\/p>\n
sudo apt-get install mariadb-server-10.1 mariadb-server-core-10.1<\/pre>\nIf desired, you can further improve the security of your MariaDB server by running a command that will go through a few questions.<\/p>\n
mysql_secure_installation<\/pre>\nWe suggest answering every question with the character ‘Y’ for yes.<\/p>\n
<\/span>Step 8: Create a Database for OWA<\/span><\/h2>\nCreate a MySQL database for the Open Web Analytics website:<\/p>\n
mysql -u root -p<\/pre>\nMariaDB [(none)]> CREATE DATABASE owa;\r\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON owa.* TO 'owa'@'localhost' IDENTIFIED BY 'Password';\r\nMariaDB [(none)]> FLUSH PRIVILEGES;\r\nMariaDB [(none)]> exit;<\/pre>\nDon\u2019t forget to replace \u2018Password\u2019 with an actual strong password.<\/p>\n