Codeigniter nginx configuration in PHP 7.1 on Ubuntu server

I assume you have already nginx on your computer or server. And this is the configuration for your codeigniter application. This is the nginx configuration for your application.

server {
listen 8890;
server_name localhost;
root /usr/share/nginx/html/simpad;
autoindex on;
index index.php;

error_log /var/log/nginx/simpad-error.log;

location / {

try_files $uri $uri/ /index.php;

location = /index.php {

fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/ci$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 256 16k;
fastcgi_buffer_size 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}

location ~ \.php$ {
return 444;
}
}

And then Restart your nginx : /etc/init.d/nginx restart.

Open your Codeigniter application configuration file on : application/config/config.php for update some configuration.

Change this configuration like this code :

$config[‘base_url’] = “”;

$config[‘index_page’] = “”;

And then run your codeigniter application on your browser.

if you have an error like this : Only variables should be assigned by reference on Loader.php on your codeigniter core you must open file on system/core/Common.php and change like this code :

function &is_loaded($class = ”)

If you have a question about the configuration please leave your comment.

Thank you

automount ntfs partition in your ubuntu 14.04

Do you want to automatically mount windows partition in ubuntu? read this tutorial to show how to do it.

For the first, open you terminal to check your system partition with run this command :

sudo blkid

blkid

And then you will see the device id and file system on your PC.

Next, run the command below to open the fstab with your favorite  editor. In this case, my favorite editor is nano, so i will type this command like this :

fstab

fstab-open

Next, add this line

UUID=xxxxxxxxxxx /mnt/ntfs-data ntfs users,defaults 0 0

ntfs-data is the name of directory used for your partition, you can give another name what you want. in this case i give name ntfs-data for the directory.

fstab-line-uuid

Save the fstab file.

After that, go to /mnt directory, and make a directory with name ntfs-data or  your own name of directory.

mkdir

Next, change the owner of the mount point by running this command :

sudo chown <username> /mnt/ntfs-data

Replace <username> with your username in your PC

chown

And then restart your PC and open your terminal and go to /mnt/ntfs-data to access your data from the other partition.

If you have any question or you have already succeeded to do this tutorial in your machine, give a comment for this post. 🙂 . Thank you.

How to reset your ubuntu password

If you forgot your ubuntu password, don’t be panic 😀 .. Ubuntu have a method for recovery a password.

The first, you must calm down :), and then boot up or reboot your computer, and when prompted, choose *Advanced options for Ubuntu :

ubuntu-advanced-option-boot

And then you will see the prompted like this, after that you choose root, and press Enter.

ubuntu-advanced-option-boot-2

 

Next, remount the shell with read and write option with type this in your shell prompt :

mount -rw -o remount /

after running the above command, the shell should be remounted with read and write permission for file system.

And now, you can set your new password with run passwd command in your shell.

passwd username

for example my username is legolas, i used this command :

passwd legolas

Ubuntu Server

 

after changing your password, using this command for reboot your ubuntu system. The sync commands makes sure to write out data to your disk before system reboot.

sync

reboot -f

And now you can use your ubuntu with a new password..

Have a nice day ^_^

how to create custom breadcrumb widget in yii framework

To make a custom breadcrumb in yii framework, try this step :

  1. we must create a new file BreadCrumb.php in your project folder, example :
    my-project\protected\components\BreadCrumb.php. And insert this code into the BreadCrumb.php file :

    class BreadCrumb extends CWidget {
    
         public $crumbs = array();
         public $delimiter = ' / ';
    
         public function run() {
          $this->render('breadCrumb_view');
         }
    }
    
  2. then create a new folder views in : my-project\protected\components\.

  3. make a new file breadCrumb_view.php in my-project\protected\components\views and insert this code to breadCrumb_view.php.

    <ul class="breadcrumb">
     <?php
         foreach($this->crumbs as $crumb) {
            if(isset($crumb['url'])) {
                echo "<li>".CHtml::link($crumb['name'], $crumb['url'])."</li>";
            } else {
                echo "<li>".$crumb['name']."</li>";
            }
            if(next($this->crumbs)) {
                echo $this->delimiter;
            }
        }
     ?>
    </ul>
    

    in this example i use ul html tag for the breadcrumb. you can change the ul and li html tag to another html tag.

  4. and then you can use the breadcrumb in your view with insert this code :
    <?php
    	$this->widget('application.components.BreadCrumb', array(
    	  'crumbs' => array(
    	    array('name' => 'Home', 'url' => array('site/index')),
    	    array('name' => 'Login'),
    	  ),
    	  'delimiter' => '&nbsp;', // if you want to change it
    	));
    ?>
    

    and you can custom your delimiter in your breadcrumb.

 

if you have a question you can leave the message in this post 🙂

Easy installing for Yii Framework

I have been working with yii framework in one year. But i think it’s very easy to install and to use it. And what make me surprise in yii framework is a generator for CRUD.

This is the step of yii installation, it’s very easy (i use Windows 7 OS) :

Step 1 : Download yii framework in : http://www.yiiframework.com/

Step 2 : Unzip yii framework in your workspace (ex: my workspace in c:\xampp\htdocs).  after that, you can rename it with yii.

Step 3 : Before you use the command line in windows OS, you must register the path of your PHP in : my computer->(right click)Properties -> advanced system setting -> (tab) advanced -> Environment variable -> in system variable choose Path, click edit, and add your PHP path and klik OK, ex: in my computer ‘c:\xampp\php\bin’

Step 4 : open the window command line (cmd) and go to the workspace, and run :

yii/framework/yiic webapp mywebapp

This will create a directory with name mywebapp

Step 5 :  Then we will configure your Yii application. Open your web application in directory C:xampp/htdocs/mywebapp/protected/config/main.php in your favourite text editor and make the following changes some configuration :

Enabled gii with Un-comment the ‘gii’ section in the ‘modules’ array.
Enabled clean urls with Un-comment the ‘urlManager’ section in the ‘components’ array.
Set up the database connection: if you want to use Mysql database,Un-comment the mysql configuration database and comment the sqlite database. Then change the database name, username and password for mysql database.
Set up the admin email contact: Update the ‘adminEmail’ parameter in the ‘params’ array.

Then run in your browser : http://localhost/mywebapp
That’s it, your first web application in yii framework has been installed, just in a few minutes.

And may be this tutorial can help you ^_^.
If you want to learn another tutorial, you can go to :
http://www.yiiframework.com/tutorials/