OwnStaGram, build your own instagram server

Instagram is probably the most popular photo sharing app allowing you to easily share all your photos to your friends and family. However the TOS have changed quite a lot and you may fear some security, anonymity and ownership concerns to share all your life to this company.

If this the case, few alternatives exists with a strong focus on privacy or even allowing you to run your own instance of Instagram-like on your server to keep full ownership of your pictures. And this is what OwnStaGram is providing.

ownstagram screenshot

OwnStaGram is a self-hosted photo sharing-platform, written in PHP and under GPLv3 license. It allows you to upload your pictures to the website or directly with a dedicated Android app, then you can simply share the URL of your pictures to your friends, family, etc…
You can have a look here as an example.


You will need to have a working LAMP server. If it is not the case, please follow this article.

1) Clone the git repository under your /var/www folder

cd /var/www
git clone https://github.com/mad5/ownstagram

2) Make sure ownstagram folder is writable

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

3) Create a database

You can use phpmyadmin to do so (Or adminer)

I called it ownstagram and created a dedicated user (ownstagram)

4) Import/run the SQL-File “DATABASE.sql

If you use phpmyadmin, the easiest is to copy the content of the DATABASE.sql to ownstagram–>SQL and run the code.

5) Configure the inc.var.php file

You will need to rename the inc.var.php.dist into inc.var.php

cd ownstagram
mv inc.var.php.dist inc.var.php

and insert your database credentials into your inc.var.php

nano inc.var.php

and set the host (localhost probably), user, pass and name.

You will also need to modify the “ownStaGramAdmin” with the email address you want to use as admin user.

Note that you can also set the MailSender, site name and timezone.

When done, simply save the file with CTRL +X (then Y)

6) Register with the admin email address previously created

Simply go to http://yourip/ownstagram and register your admin user, previously set into your inc.var.php file.

ownstagram register

When done, it will recognize the admin account and will skip the activation step.

You are now ready to upload photos, add users, create groups, etc… but also to install the android app and to point it to your ownstagram instance.

ownstagram android mobile app screenshot


And if you want to have a more friendly URL, like mygram.domain.tld or even to set up SSL connection, follow below instructions


Virtualhost configuration

What you will need:

1) Create a A redirection in your DNS server/registrar with mygram.domain.tld to your IP

2) Have SSL certificate ready. If not you can read this tutorial. (Optional)

3) Create your virtualhost as following:

In /etc/apache2/sites-enabled/, create a file called ownstagram (In root):

nano /etc/apache2/sites-enabled/ownstagram

and paste the following content:

<VirtualHost *:80>
        ServerAdmin webmaster@domain.tld
        ServerName mygram.domain.tld
        Redirect / https://mygram.domain.tld

<IfModule mod_ssl.c>
<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/myblog.pem
        SSLCertificateKeyFile /etc/ssl/private/myblog.key

        ServerAdmin webmaster@domain.tld
        ServerName mygram.domain.tld

        DocumentRoot /var/www/ownstagram
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        <Directory /var/www/ownstagram>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

Adapt the content (Servername, webmaster, SSL certificate and directory).

When done, save the file (CTRL+X then Yes) and reload apache: (In root)

/etc/init.d/apache2 reload

Now your ownstagram should be fully working will SSL certificate and using a easier to remember URL.

instagram funny comics xkcd


Loves to discover web-based apps to install on his own server@home and write articles about it


Add a comment


i want likes so thats y i want server
Written on Mon, 04 Jun 2018 05:22:28 by abhinav kalra
Written on Wed, 23 May 2018 08:21:49 by pintubhai86
Written on Thu, 10 May 2018 16:35:50 by Ansh blackbelt
Build a server
Written on Tue, 06 Mar 2018 17:34:06 by Sameer