Category Archives: PHP

Installing GNU Social with SSL on Debian 7 Wheezy

Yesterday I got my instance of GNU Social up and running on a Debian 7 server and I thought to document the steps I took in order to have a functional GNU Social instance.

First make sure you have the GLAMP (GNU/Linux Apache MySQL PHP) stack installed, with php 5.5 or higher.

nano /etc/apt/sources.list

Then add the following lines:

deb http://packages.dotdeb.org wheezy-php55 all
deb-src http://packages.dotdeb.org wheezy-php55 all

save and run the following:

wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg

Then install the packages:

apt-get update
apt-get install apache2 php5 php5-mysql php5-gd php5-curl php5-intl mysql-server git sendmail-bin

Now it’s time to create a database and a user for our GNU Social instance.
Log in to mysql server:

mysql -u root -p

And execute the following SQL query:

CREATE DATABASE gnusocial;
GRANT ALL ON gnusocial.* to 'gnusocial' IDENTIFIED BY 'your_password_here';
FLUSH PRIVILEGES;

Now download GNU Social and place it in /var/www/gnusocial

git clone https://git.gnu.io/gnu/gnu-social.git /var/www/gnusocial

Then give the user www-data ownership to the gnusocial folder:

chown -R www-data:www-data /var/www/gnusocial

Now let’s create an apache2 virtual host for our instance

touch /etc/apache2/sites-available/gnusocial

and edit the configuration to match our installation

nano /etc/apache2/sites-available/gnusocial
<VirtualHost *:80>
  ServerAdmin email@example.com
  ServerName example.com
  DocumentRoot /var/www/gnusocial
  DirectoryIndex index.php
</VirtualHost>

And activate the php module and the site with the following commands

a2enmod php5
a2ensite gnusocial
service apache2 reload

Now you can try to access your website domain (e.g. http://example.com) and you will see a page that informs you that you need to make a configuration file and start the installer.
Before continuing the GNU Social installation we are going to enable fancy URLs and SSL
In order to enable Fancy URLs we have to use the provided .htaccess file

mv /var/www/gnusocial/htaccess.sample /var/www/gnusocial/.htaccess

In order to have SSL encryption we will use a Let’s Encrypt certificate generated by their automated script.
So let’s go to work.

cd ~
git clone https://github.com/letsencrypt/letsencrypt letsencrypt
cd letsencrypt
./letsencrypt-auto --help

Now run the following command and follow on-screen wizard to install the Let’s encrypt certificates.

./letsencrypt-auto --apache

If it complains about outdated libaugeas0 and augeas-lenses you can download and install the packages from jessie (I assune you’re runing on a X86_64 installation, otherwise just find the links on http://packages.debian.org) :

cd ~
wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6_2.19-18+deb8u3_amd64.deb
wget http://ftp.no.debian.org/debian/pool/main/a/augeas/libaugeas0_1.2.0-0.2+deb8u1_amd64.deb
wget http://ftp.no.debian.org/debian/pool/main/a/augeas/augeas-lenses_1.2.0-0.2+deb8u1_all.deb
dpkg -i *.deb

Then run again :

./letsencrypt-auto --apache

Now after all these steps are followed you can proceed with the GNU Social installation wizard by visiting the GNU Social installation page (e.g. example.com/install.php)

After that you may want to change the theme of GNU Social to neo-quitter by adding the following line to the config.php

$config['site']['theme'] = 'neo-quitter';

If you would like to follow me on GNU Social, please do so at the following address: https://social.serbanescu.dk

References:
https://www.dotdeb.org/instructions/
https://karp.id.au/social/admin/installing.html
https://levlaz.org/installing-gnu-social-on-a-debian-server/
https://letsencrypt.org/getting-started/
https://github.com/hannesmannerheim/neo-quitter
http://code.tutsplus.com/tutorials/revisiting-open-source-social-networking-installing-gnu-social–cms-22456

Setup XDebug with XAMPP and NetBeans in GNU/Linux

Here is a quick step by step guide on how to get XDebug running with NetBeans IDE.

After you have setup XAMPP and Netbeans it’s time to install XDebug.

Firstly I’ll recommend using the wizard provided by XDebug. Just open your xampp web control panel and go to the phpinfo() tab then select the whole output and copy it. Paste the information about the php setup into the wizard provided by XDebug.

Then follow the steps provided by the wizard with a slightly change. Namely whenever asked to run the phpize command you’ll have to use xampp’s phpize command:   /opt/lampp/bin/phpize

So, to sum up the required steps:

  1. download XDebug (latest version at the time of writing is 2.2.4)
  2. extract XDebug : tar -xvzf xdebug-2.2.4.tgz
  3. navigate to the XDebug folder: cd xdebug-2.2.4
  4. run  /opt/lampp/bin/phpize
  5. check if the API numbers match the ones provided by XDebug Wizard. The following applies for xdebug-2.2.4
    Configuring for:
    ...
    Zend Module Api No:      20121212
    Zend Extension Api No:   220121212
  6. Run ./configure then make in order to compile XDebug
  7. After compiling is done, copy the compiled extensions into xampp libraries folder: cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20121212
  8. Then edit the xampp’s php.ini file: /opt/lampp/etc/php.ini
  9. Append the following at the end of the file:
    [zend]
    zend_extension=”/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so”
  10. Then append the XDebug configuration for working with Netbeans:
    [xdebug]
    xdebug.extended_info=1
    xdebug.max_nesting_level=1000
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 1
    xdebug.remote_enable=1
    xdebug.remote_host = "127.0.0.1"
    xdebug.idekey="netbeans-xdebug"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    xdebug.remote_mode = "req"
    xdebug.remote_log="/opt/lampp/logs/xdebug.log"
    xdebug.show_local_vars=1
    xdebug.trace_output_dir = "/opt/lampp/tmp"
    xdebug.var_display_max_data=1000
    xdebug.var_display_max_depth=-1
    

And now you can start debugging your PHP code in NetBeans. Have fun!