Skip to content

rmdstudio/anahita

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anahita social networking platform and framework

Women Life Freedom

We stand in solidarity with Iranian women!

#MahsaAmini #WomenLifeFreedom #IranRevolution

Anahita

Version: 4.8.2 Birth Release

Anahita is a platform and framework for developing open science and knowledge-sharing applications on a social networking foundation. Use Anahita to build:

  1. online learning and knowledge-sharing networks
  2. information access networks about people, places, and things
  3. open science and open data networks
  4. online collaboration environments
  5. cloud back-end for your mobile apps

Anahita provides nodes and graphs architecture for developing social networking apps.

Table of Contents

Concepts

Nodes

  1. actors: people, groups, or build your custom actor
  2. media: notes, topics, todos, photos, articles, or build your custom media
  3. hashtags: all actors, media, and comments are hashtaggable
  4. locations: all actors and media are geolocatable
  5. stories: updates created by actors for their followers

Graphs

  1. social graph: people and groups can be followed by others.
  2. hashtags: for actors, media, and comments
  3. mentions: tag people in media and comments
  4. locations: tag locations in media and actors and search nearby nodes
  5. notifications: a person receives email notification whenever a comment is posted on an item to which they are subscribed.
  6. votes: people can Like/Unlike media and comments

Stories

  • story feeds on dashboard and actor profiles
  • notifications

RAD Framework

  1. MVC rapid app development framework specialized for building social apps
  2. fully customizable theme and user interfaces
  3. extendable by social apps and components
  4. RESTful and JSON APIs (ideal to use Anahita as a back-end for mobile apps)
  5. Built using your favourite technologies such as PHP5, MySql, Bootstrap, JQuery, Grunt, Composer, LessCSS

Embryo and Birth releases

The code in the master branch is called the Embryo. It is what we use to power our website Anahita.io and is constantly changing and evolving. It may contain bugs that we are fixing, or we may add or remove experimental features. Whenever we reach a specific milestone, and the codebase is stable, we package it as a Birth release.

System Requirements

Before you start, please make sure that your server meets the following requirements:

  1. Linux or Unix server
  2. Nginx or Apache 2.0+
  3. MySql 5.7
  4. Redis (optional) any hosted and managed Redis service will do. For example AWS ElastiCache Redis.
  5. Use PHP version 7.4 to 8.0 for best results.
  6. Composer package management. You can download it following the instructions on http://getcomposer.org/ or just run the following command:

curl -s http://getcomposer.org/installer | php

Important Notes

If you have the Suhosin patch installed on your server, you might get an error. Add this line to your php.ini file to fix it: suhosin.executor.include.whitelist = tmpl://, file://

Anahita is installed and managed via shell CLI because this is the most reliable approach, especially after you accumulate large amounts of data in your database.

Installation on a development machine

Installing a stable package

We call the stable packages Birth releases. Use the following command to create an Anahita project called myproject. This command automatically downloads all the required files from the Anahita GitHub repository:

composer create-project anahita/project myproject

Now go to the myproject directory:

cd myproject

Continue with [Initiating Installation] (#initiating-installation) from this point.

Installing from the master branch

The master branch always contains the Embryo release. Using the following command, clone the Anahita repository from the master branch:

git clone [email protected]:anahitasocial/anahita.git myproject

change directory to myproject

cd myproject

Now run the composer command to obtain all the 3rd party libraries that Anahita requires:

composer update

Continue with Initiating Installation from this point.

Initiating Installation

If you type php anahita, you get a list of all commands available to manage your Anahita installation. If the command didn't work, perhaps the symlink to the Anahita command line tool isn't created. In this case, run the following command to create a symlink. Otherwise, move to the next step, initiating the installation process.

ln -s bin/anahita anahita

To initiate the installation process, run the following command and provide your database information when it asks you:

php anahita site:init

The installer creates an Anahita installation in the PATH-TO-YOUR-DIRECTORY/myproject/www directory. You need to configure your server to use this directory as the public directory.

Congratulations! You have installed Anahita successfully. Now you need to signup as a Super Administrator.

Signing Up The Super Administrator

The first person that is signing up with Anahita becomes the Super Administrator. Use the following command to create the first account:

php anahita site:signup

Provide a valid email and username. You can provide a password, or Anahita automatically creates a strong password for you.

Congratulations! You have created the first person and Super Admin account. Point your browser to your Anahita installation and login.

Next, you will configure your installation and install some apps.

Building an AWS EC2 server and installing Anahita

Prerequisites: you need to be familiar with AWS services such as Route53, Load Balancers (ELB), EC2 Servers, Identity & Access Management (IAM), and Relational Database Service (RDS).

Installing PHP

Amazon Linux comes with PHP pre-installed. All you need to do is to enable it using the following commands.

sudo amazon-linux-extras enable php8.0

sudo yum clean metadata

sudo yum install php-{pear,cgi,pdo,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip}

Now check to see if the PHP 8.0 is installed and working:

php -v

Installing NGINX

sudo amazon-linux-extras enable nginx1

sudo yum clean metadata

sudo yum -y install nginx

sudo systemctl enable --now nginx

systemctl status nginx

Configuring NGINX

The following is an example of a configuration file you can use for your EC2 server:

server {
  listen 80;
  server_name <your-anahita-project-server-name>;
  root /var/www/<your-anahita-project-name>/www;
  access_log /var/log/nginx/<your-anahita-project-name>_access.log;
  error_log /var/log/nginx/<your-anahita-project-name>_error.log; 

  location / {
     default_type application/json;
	   client_max_body_size 50M;
	   index index.php index.html;
     try_files $uri $uri/ /index.php?$args;
  }
  
  charset utf-8;
  gzip on;
  gzip_comp_level 3;
  gzip_disable "msie6";
  gzip_min_length 1000;
  gzip_proxied any;
  gzip_types text/xml text/plain application/xml application/json;
  
  location ~ /\. {
      access_log       off;
      log_not_found    off;
      deny             all;
  }
 
  location = /robots.txt {
       allow all;
       log_not_found off;
       access_log off;
  }
  
 location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
 }

  location ~ \.php$ {	  
	      try_files                 $uri =404;
        include                   /etc/nginx/fastcgi_params;
        fastcgi_read_timeout      3600s;
        fastcgi_buffer_size       128k;
        fastcgi_buffers           4 128k;
        fastcgi_param             SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass              unix:/run/php-fpm/www.sock;
        fastcgi_index             index.php;

	       client_max_body_size 50M;

         add_header "Access-Control-Allow-Origin" "https://<your-anahita-project-url>" always;
         add_header "Access-Control-Allow-Methods" "GET, POST, PUT, DELETE, HEAD" always;
         add_header "Access-Control-Allow-Headers" "Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With" always;
         add_header "Access-Control-Allow-Credentials" "true" always;
  }
}

You can run the command sudo nginx -s reload every time you edit the config file for the changes to be applied.

Installing a firewall

sudo yum install firewalld

sudo systemctl start firewalld

sudo systemctl enable firewalld

sudo systemctl status firewalld

sudo firewall-cmd --add-service={http,https} --permanent

sudo firewall-cmd --reload

sudo firewall-cmd --list-all

Configuring PHP FPM Service

Edit the www.confi file using vim:

sudo vim /etc/php-fpm.d/www.conf

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
pm = ondemand

Write and quite vim, and the run the following commands:

sudo systemctl enable php-fpm

sudo systemctl restart php-fpm

systemctl status php-fpm

Installing PHP Composer

Composer is a dependancy manager for PHP. This is how you install composer globally on your server:

cd ~

sudo curl -sS https://getcomposer.org/installer | sudo php

sudo mv composer.phar /usr/local/bin/composer

sudo ln -s /usr/local/bin/composer /usr/bin/composer

sudo composer install

Installing and configuring Git

We need git to be able to clone and pull Anahita code from the Github repository.

sudo yum install git -y

git version

Setup SSH key for Gihub

ssh-keygen -t ed25519 -C "[email protected]"

~ssh-add ~/.ssh/id_ed25519

sudo cat /root/.ssh/id_ed25519.pub

Setting up a mail server

Anahita sends out a lot of email notifications. The best way is to use a reliable and heavy-duty mail service such as Mailgun or Amazon Simple Email Service (SES). Once you setup your SMTP, you need to have the following values for configuring Anahita in the next step:

  • username
  • password
  • host
  • port

Initiating and configuring Anahita

You need to create a MySQL or MariaDB Amazon RDS instance. We don't cover the RDS creation and configuration in this document. Instead, you can read the AWS documentation: Configuring an Amazon RDS DB instance. Once you have your RDS instance ready, you need to have the following values:

  • endpoint
  • port
  • database
  • username
  • password

You can test the database connection from your server using the following command:

mysql -h <endpoint> -P <port> -u <username> -p

Enter the password, and then use standard MySQL commands to interact with the database. Once you manage to connect successfully, you can exit.

Installing Anahita on an EC2 instance is similar to installing Anahita on a development machine with variations. On EC2, you can clone Anahita under the var/www/ directory.

From the master branch of the Anahita repository:

git clone [email protected]:anahitasocial/anahita.git <your-anahita-project-name>

Or from your custom Anahita project repository:

git clone [email protected]:<your-anahita-project-repo-on-github>/<your-anahita-project-name>.git

Now change the permissions of your Anahita project directory:

sudo chown ec2-user:ec2-user <your-anahita-project-name> -R

Go in the directory and use composer to get all the required packages:

cd <your-anahita-project-name>

composer update

Now initiate Anahita; the initiation process asks you for several parameters such as database info, etc. Enter all the values that the prompt message asks you:

php anahita site:init

Now signup for the first user account. The first user has Super Admin privileges which is the highest within an Anahita installation:

php anahita site:signup

Editing the Configuration file

You can use a CLI text editor to edit the configuration.php file in the root directory. There are several parameters that you need to set in this file:

Parameter Value Example
$sitename Website/app name Anahita
$same_site_none Cookie same site none on/off 0
$client_domain base url to your client side webapp https://www.YourDomain.io
$sef_rewrite Set this to 1 1
$debug If true, Anahita will operate in debugging mode 0
$error_reporting Use -1 to turn it off or 30719 to show all warnings -1
$cors_enabled Use 1 and set the other cors value. This feature is best if you are using Anahita on your development machine and want to test it with a clientside app. For a production server, set the CORS in the nginx config file, instead. 0
$mailer We recommend smtp and using an SMTP provider such as Mailgun or AWS SES smtp
$mailfrom The email address used in the 'reply to' section of your email notifications [email protected]
$fromname A name that indicates where the origin of an email notification. Anahita Platform
$smtp_user Your SMTP service username [email protected]
$smtp_pass Your SMTP service password strongpassword
$smtp_host path to the SMTP service host smtp.mailgun.org
$smtp_secure Use ssl ssl
$smtp_port SMTP service port 587

Write and quit the editor. Now you can set up an AWS Load Balancer (ELB) for your installation and point it to, for example, https://api.YourDomain.io

Anahita Settings

Before using your Anahita for development or production server, you need to make some configurations. At this point, you need to connect to Anahita using a client-side app such as Anahita React. Once you have set up your client-side application, then you can access the Settings as follows:

  1. Log in to your Anahita installation as a Super Administrator
  2. On the main menu, click on the Settings

Here are the tabs under the Settings view:

  1. About: has basic information about your Anahita installation, such as creators and software version.
  2. Apps: configure installed Anahita apps for the entire site.
  3. Assignments: configure which actors (People, Groups, etc.) can use what apps (Topics, Photos, etc.)
  4. Plugins: configure Anahita plugins for the entire site.

Notifications

Anahita emails out a lot of email notifications. For the email notifications to get sent out, you can set up a cron job on your server to the yourdomain.com/components/com_notifications/process.php file. Make sure to go to Site Settings > Apps > Notifications and set Use Cron to Yes.

There are many articles on the web to show you how to set up a cron job. Depending on your site's number of users and activity, anywhere from 15-minute to 1-hour intervals will work. You will find a suitable interval after monitoring your Anahita installation for a while.

Installing Social Apps

Now it is time to extend your Anahita installation with some apps and components. Anahita comes with a list of social apps you can use as they are or use as blueprints for developing your custom apps.

To get a list of available apps, simply type the following command:

php anahita package:list

Now to install an app, for example, the Photos app, type the following command:

php anahita package:install photos

You can even provide a list of apps and components in one line. For example, to install the Groups, Topics, and Connect apps, use the following command:

php anahita package:install groups topics connect

Go to Site Settings > Assignments to define whether an app should optionally or always be available on actor profiles (people, groups, etc.). If an app is optionally available, it can be enabled on each actor profile under the Edit Profile > Apps by the actor profile admin or someone with a higher admin privilege on the Anahita installation.

Congratulations! You have just installed some apps and extensions on your Anahita installation.

Amazon S3 Storage

In most cases, you wouldn't want to store the uploaded files on your own server. They add up very quickly, making it very difficult to maintain or migrate your Anahita installation. Anahita provides a plugin that stores all uploaded files in the AWS or Amazon S3 cloud.

Go to Site Settings > Plugins and then from the type list select Storage. Edit and disable the Storage - Local plugin by clicking on its name. Edit the Amazon S3 plugin using the following settings:

  1. Enabled: set to yes
  2. The folder to store the data: use assets as the default setting
  3. Bucket: enter the name of your Amazon S3 bucket
  4. Access Key: enter your AWS access key
  5. Secret Key: enter your AWS secret key

Now click Update to store the settings. Try uploading your avatar in the front-end and see if it gets uploaded successfully. Check the image src to make sure it is an AWS URL.

Support

Anahita has an active and thriving tribe of hobbyists, developers, and entrepreneurs. They are helpful and friendly. So Join Us

Please Note: we do not answer questions in an email. If you have any questions, please join the Anahita tribe and post your questions on the Tribe Support group, where others can benefit from the answers too.

Reporting Bugs & Issues

There are so many ways that you can report a bug:

Contribute to Anahita

Anahita could never be possible without the help of people in our tribe. We need contributors who can help us with testing, finding and fixing bugs and coding. Here is a complete guideline of how you can contribute to Anahita.

Follow us, Like us

Follow us on Instagram anahita.io and like our facebook page Facebook.com/anahita.io

Credits

Anahita is developed and maintained by rmdStudio Inc., a software development company in Vancouver, Canada. We build client-server architecture applications for scientific, healthcare, and industrial sectors.

About

Anahita Source Code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%