LAMP with Yii1

Installing PHP

    sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

    Install php extensions

        sudo apt-get install php5-mysql
        sudo apt-get install php5-sqlite
        sudo apt-get install php5.6-mbstring
        sudo apt-get install libapache2-mod-php5.6

In most cases, we’ll want to modify the way that Apache serves files when a directory is requested. 
Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. 
We want to tell our web server to prefer PHP files, so we’ll make Apache look for an index.php file first.

To do this, type this command to open the dir.conf file in a text editor with root privileges:

sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:

    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

We want to move the PHP index file highlighted above to the first position after the DirectoryIndex specification, like this:

    DirectoryIndex index.php index.html index.cgi index.xhtml index.htm


Install Multiple PHP Versions on Ubuntu 16.04

Install PHP 5.6

Step 1: Update Apt-Get
apt-get update && apt-get upgrade
apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update

Step 2: Install PHP 5.6
apt-get install -y php5.6

Changing PHP Version for Apache (if your server have more than one php version)

a2dismod php7.0; a2enmod php5.6; service apache2 restart
a2dismod php5.6; a2enmod php7.0; service apache2 restart

Changing PHP Version for Ubuntu

update-alternatives --config php
and then choose one php version for command line ( Ubuntu )


Installing Apache Web Server

Step 1 — 
    sudo apt update
    sudo apt install apache2

Step 2 — Adjusting the Firewall

    sudo ufw app list
    sudo ufw allow 'Apache'
    sudo ufw status

    or custom port allow

    sudo ufw allow 8080
    sudo ufw reload

Step 3 — Checking your Web Server

    sudo systemctl status apache2

    hostname -I
    at command line : curl -4
    at browser : http://your_server_ip

Step 4 — Managing the Apache Process

    sudo systemctl stop apache2
    sudo systemctl start apache2
    sudo systemctl restart apache2
    sudo systemctl reload apache2
    sudo systemctl disable apache2
    sudo systemctl enable apache2

Step 5 — Setting Up Virtual Hosts (Recommended)

    sudo mkdir /var/www/your_domain
    sudo chown -R $USER:$USER /var/www/your_domain
    sudo chmod -R 755 /var/www/your_domain

    nano /var/www/your_domain/index.html
    and added some html code into index.html

    sudo nano /etc/apache2/sites-available/your_domain.conf

        ServerAdmin webmaster@localhost
        ServerName your_domain
        ServerAlias www.your_domain
        DocumentRoot /var/www/your_domain
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        ServerName ipaddress
        DocumentRoot /var/www/html/testwebsite
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

Allowing Rewrite rules to Apache2 Web Server at Ubuntu

    a2enmod rewrite
    systemctl restart apache2

Let’s enable the file with the a2ensite tool:

    sudo a2ensite your_domain.conf

Disable the default site defined in 000-default.conf:

    sudo a2dissite 000-default.conf

Next, let’s test for configuration errors:

    sudo apache2ctl configtest

You should see the following output:

Syntax OK

Restart Apache to implement your changes:

    sudo systemctl restart apache2

Checking Errors log at Apache Server



Installing MySQL to Manage Site Data

    sudo apt install mysql-server php5-mysql
    sudo mysql_secure_installation

Allow MySql without 'sudo' at command line
    sudo mysql
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> exit
and then, you can access mysql without sudo 'mysql -u root -p'

Adding new user and grant databases / only one database

    // Creating new database user
    CREATE USER 'YourUserName'@'localhost' IDENTIFIED BY 'YourPassword';
    CREATE USER 'YourUserName'@'%' IDENTIFIED BY 'YourPassword';

    // Granting the one user to all database
    GRANT ALL ON *.* TO 'YourUserName'@'localhost';
    GRANT ALL ON *.* TO 'YourUserName'@'%';

    // Granting the one user to one database
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'localhost';
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'%';


Installation and Configuration Guide for Orangescrum Community Edition ( Ubuntu 14.04 LAMP )

Ref :


  • A Server running Ubuntu 14.04
  • A Static IP Address for your server

Install Mysql

By default the mysql package is available in the Ubuntu 14.04 repository.

So, you can easily install mysql using the following command:

sudo apt-get install mysql-server

After this, start mysql service and enable mysql to start on boot.

sudo /etc/init.d/mysql start sudo update-rc.d mysql defaults

Install Php and Apache

After installing mysql, you will need to install PHP and Apache.

sudo apt-get install libapache2-mod-php5 php5 php5-cli php5-common php5-gd php5-mcrypt php5-mysql apache2

After this, start Apache service and enable Apache to start on boot.

sudo /etc/init.d/apache2 start sudo update-rc.d apache2 defaults

Download Orangescrum and Upload it to Apache Web root

You can download Orangescrum open source version from url

sudo wget

After downloading Orangescrum you will need to unzip

sudo unzip

After this, You will find the orangescrum-master directory.

Now, move this directory with name orangescrumPM to your Apache web root directory.

sudo mv orangescrum-master /var/www/html/orangescrumPM

Give proper permissions to the orangescrumPM directory.

sudo chown -R www-data:www-data /var/www/html/orangescrumPM sudo chmod -R 777 /var/www/html/orangescrumPM

Configure Mysql

In order to log into MySQL to secure it, you’ll need the current password for the root user. If you’ve just installed MySQL, and you haven’t set the root password yet, the password will be blank.

sudo mysql_secure_installation

Answer all the questions shown as below:

Enter current password for root (enter for none): **currentrootpasswd**
Set root password? [Y/n]: **Press Enter**
New password: **rootsqlpasswd**
Re-enter new password: **rootsqlpasswd**
Remove anonymous users? [Y/n]: **Press Enter**
Disallow root login remotely? [Y/n]: **Press Enter**
Remove test database and access to it? [Y/n] : **Press Enter**
Reload privilege tables now? [Y/n] : **Press Enter**

All done! If you’ve completed all of the above steps, your MySQL installation should now be secure. Now, You need login to mysql, create database and user for Orangescrum.

sudo mysql -u root -p

Create the database with the name Orangescrum:

mysql> create database orangescrum;

Create the user with the name orangescrum:

mysql> create user orangescrum;

Grant all privileges while assigning the password, chose a secure password and replace my-secret-password with your own:

mysql> grant all on orangescrum.* to 'orangescrum'@'localhost' identified by 'my-secret-password';

Exit from the mysql shell:

mysql> exit

Now, You will need to import the database from database.sql file located in /var/www/html/orangescrumPM directory.

First, change into the orangescrum directory:

sudo cd /var/www/html/orangescrumPM/

Now import the sql file:

sudo mysql -u orangescrum -porangescrum < database.sql

Next, by default STRICT mode is On in Mysql. So you need to disable it.

You can do this by editing my.cnf file:

sudo nano /etc/mysql/my.cnf

Add the following line at the end of file:


Save and close the file, restart mysql to reflect changes.

sudo /etc/init.d/mysql restart

##Configure PHP

Now, You wiil need to change the ‘post_max_size’ and upload_max_filesize to 200M in php.ini.

You can do this by editing the php.ini file:

sudo nano /etc/php5/cli/php.ini

Change the post_max_size and upload_max_size as shown below:


Save and close the file.

Configure Apache

The next step is to add orangescrumPM in the Apache default configuration file.

You can do this by editing apache2.conf file:

sudo nano /etc/apache2/apache2.conf

Add the following content:

``` language-bash

Options Indexes ExecCGI MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all

When you are finished, it is recommended to check the configuration for syntax errors.

`sudo apachectl configtest`

You should see following output if Apache configuration syntax is correct:

Syntax OK

After the syntax check is done you need to enable Apache headers and rewrite module.

You can do this by running:

`sudo a2enmod rewrite` `sudo a2enmod headers`

Now, restart Apache to reflect the changes:

`sudo /etc/init.d/apache2 restart`

## Configure Orangescrum

Now you need to update the database connection details in `database.php` file.

You can do this by editing `database.php` file.

`sudo nano /var/www/html/orangescrumPM/app/Config/database.php`

Change the following lines, not forgetting to substitute in your password instead of 'my-secret-password':


public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false,'host' => 'localhost', 'login' => 'orangescrum', 'password' => 'my-secret-password', 'database' => 'orangescrum', 'prefix' => '', 'encoding' => 'utf8', );}

Save and close the file when you are finished.

Next, you will need to provide an SMTP service for Orangescrum to send email from. In this example we use a Gmail account, but you can use any SMTP service such as Sendgrid or Mandrill.

Edit the Orangescrum `constants.php` file:

`sudo nano /var/www/html/orangescrumPM/app/Config/constants.php`

Change the following line:

    //Gmail SMTP
    define("SMTP_HOST", "ssl://");
    define("SMTP_PORT", "465");
    define("SMTP_UNAME", "");
    define("SMTP_PWORD", "**********");define('FROM_EMAIL_NOTIFY', ''); //(REQUIRED)
    define('SUPPORT_EMAIL', ''); //(REQUIRED) From Email
    define("DEV_EMAIL", ''); // Developer Email ID to report the application error

define('SUB_FOLDER', '/');


FROM_EMAIL_NOTIFY : All the tasks created/updated notification emails will be sent from this email address.

SUPPORT_EMAIL : All other emails and support related emails will be sent from this email address.

Save and close the file, when you are finished.

##Testing Orangescrum

From a remote machine, open your Firefox browser and type url http://your-server-ip-address

You will be asked to provide your Company Name, Email address and a Password to login and start using Orangescrum.

After this, you can see the orangescrum welcome page.

Setting up Laravel with Nginx and phpmyadmin on Ubuntu 14.04

1) Install the Backend Components
1.1) sudo apt-get update
1.2) sudo apt-get upgrade
1.3) sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt git
2) Modify the PHP Configuration
2.1) sudo nano /etc/php5/fpm/php.ini
2.2) cgi.fix_pathinfo=0 
2.3) sudo php5enmod mcrypt
2.4) sudo service php5-fpm restart
3) Configure Nginx and the Web Root
3.1) sudo mkdir -p /var/www/laravel
3.2) sudo nano /etc/nginx/sites-available/default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    #root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

3.3) sudo service nginx restart
3.4) if you want to setup virtual block
3.4.1) sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/
3.4.2) sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

sample for "/etc/nginx/site-availables/
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;

    #root /var/www/laravel_example_com/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;


3.4.3) sudo nano /etc/nginx/nginx.conf 
3.4.4) server_names_hash_bucket_size 64; 
3.4.5) sudo service nginx restart 
4) Create Swap File (Optional) 
4.1) sudo fallocate -l 1G /swapfile 2) sudo mkswap /swapfile 3) sudo swapon /swapfile 

5) Install Composer and Laravel 5.1) cd ~ 
5.2) curl -sS | php 
5.3) sudo mv composer.phar /usr/local/bin/composer 
5.4) sudo composer create-project laravel/laravel /var/www/laravel 
5.5) sudo composer create-project laravel/laravel /var/www/laravel 4.2 
5.6) sudo chown -R :www-data /var/www/laravel 
5.7) sudo chmod -R 775 /var/www/laravel/app/storage 
5.8) http://server_domain_or_IP

4) Install phpmyadmin
4.1) sudo apt-get install phpmyadmin
4.2) where is the site
cd /usr/share/nginx/html

4.3) sudo ln  -s /usr/share/phpmyadmin/ /usr/share/nginx/html
it will create a new link name “phpmyadmin” under /user/share/nginx/html
if you want to create custom phpmyadmin link, you can create by the following command
sudo ln  -s /usr/share/phpmyadmin_mycustom_name/ /usr/share/nginx/html
it will create a new link name “phpmyadmin_mycustom_name” under /user/share/nginx/html
And we can call it from browser by “http://ip_address/phpmyadmin; or “http://ip_address/phpmyadmin_mycustom_name;

4.3 ) sudo systemctl restart nginx


5) if there is “root /var/www/html” at /etc/nginx/sites-available/default, comment out it
eg ” # root /var/www/html ” and change server_name to
server_name localhost / ip_address;


6) if “cgi.fix_pathinfo = 0” at /etc/php/7.0/fpm/php.ini, pls change back to original “cgi.fix_pathinfo = 1”
sudo systemctl restart nginx   OR sudo service nginx restart


7) If you used the new port for the virtual host, you have to allow that ports to access from globally ( outside )sudo ufw allow 8000/tcp


8) To Create a New User and Grant Permissions in MySQL


Before we create and grant the permissions to the new user, we need to open the ( MySql port 3306 from firewall ).
To check firewall is active or inactive at unbuntu by the following command

ufw status

if reply ufw inactive, we need to open the ufw (firewall) by the following command

ufw enable

And then you can check which port are allow in our web server by the following command

ufw status
and it will reply all status.
If mysql is not allow, we need to allow it by the following command

ufw allow 3306/tcp

if port 3306 is not okay to access from the remote / other local pc, we need to change the mysql default por to ‘3360’ or as you wish.

to change the MySql port to ‘3360’,
go to the /etc/mysql
and edit the my.cnf

go to ‘[mysqld]’ part
chnage the default “bind_address” to “server_ip_address”
change the default “port” to “3360”

And then, restart the mysql service by the follwoing command
sudo service mysql restart

After it all, we need to check one thing
which ports are opening at our Web Server by the following

nmap localhost/ipaddress


login to mysql with root password
mysql -uroot -p
and then,

8.1) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

8.2) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;

8.3) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’ip_address’ IDENTIFIED BY ‘password’;

8.4) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’ip_address’;

8.5) Reload all privileges





How I configured sendmail for PHP on Ubuntu Server 14.04

Go to terminal and run the following command to install sendmail
aptitude install sendmail

I put “mysite.localhost” (mysite is my server name) to /etc/hosts so it looks like this: localhost.localdomain localhost mysite.localhost mysite

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Create one sample text file for test email (body.txt)

Subject: test mail to Some Address!
From: Me <>
first line of my message for testing


To test how sendmail works I used the following command:
/usr/sbin/sendmail -t -f -v -i < body.txt

Reference Site :