Pages

Thursday, July 9, 2015

Cakephp 2.0-Adding favicon to your website

I was able to add a favicon to my website using code mentioned.This one is trusted and working.

 echo $this->Html->meta('favicon.ico','img/favicon.ico',array('type' => 'icon'));  

You need to place your favicon.ico file in/webroot/img directory

Sunday, April 5, 2015

Cakephp 3.0-Where IN Condition with list

So here comes Cakephp 3.0 with all new syntax new ORM and many other changes.I find myself struggling with Cakephp this hard since I used cakephp 1.3 for the first time.

But here is My first struggle to help you with

  return $this->find('list',['keyField' => 'id', 'valueField' => 'name'])->where([  
          'id IN'=>$nearCitys  
       ])->toArray();  

Saturday, April 4, 2015

Cakephp 3.0-Installing from Composer

Recently I was trying to install cakephp 3.0 from composer which was throwing some cache errors as such my install was unsuccessfull

Here is what I did to correct the same

When you run composer to install something let us suppose cakephp 3.0 it creates a cache in your home directory.In my case location was

/home/gaurav/.composer

 This location has a cache folder which works for composer installation.This is not writable by default so this should b provided write permissions also Cakephp 3.0 requires
  • mbstring extension
  • intl extension
which must be installed in advanced(google it to get concerned installation repository for your distribution)

After that my Install went smooth.

Apache2-Forbidden You don't have permission to access /dir/ on this server

Recently on restarting my Apache Server on Ubuntu I came across following error

Forbidden You don't have permission to access /dir/ on this server

After a bit of google I solved this by granting permissions to my server directory and resetting my httpd.conf directory access levels as follows

Since I am working on Ubuntu I will be using Ubuntu locations your locations can very depending upon your linux distribution

In Ubuntu httpd.conf file is place under
/etc/apache2/sites-available directory

if you list directory contents you will find files like

000-default.conf   000-default.old   example.com~
000-default.conf~  default-ssl.conf

Out of these first one is the httpd.conf file in concern(this is how Ubuntu stores it)

First make a copy of the same as you can see I have made a copy of the same 000-default.old using following command

sudo cp 000-default.conf 000-default.old

Now Alter the 000-default.conf as follows

 <VirtualHost *:80>  
   ServerAdmin webmaster@localhost  
   DocumentRoot /var/www  
   <Directory />  
     Options FollowSymLinks  
     AllowOverride None  
   </Directory>  
   <Directory /var/www>  
     Options Indexes FollowSymLinks MultiViews  
     AllowOverride All  
     Order allow,deny  
     allow from all  
   </Directory>  
   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  
   <Directory "/usr/lib/cgi-bin">  
     AllowOverride None  
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch  
     Order allow,deny  
     Allow from all  
   </Directory>  
   ErrorLog ${APACHE_LOG_DIR}/error.log  
   # Possible values include: debug, info, notice, warn, error, crit,  
   # alert, emerg.  
   LogLevel warn  
   CustomLog ${APACHE_LOG_DIR}/access.log combined  
 </VirtualHost>  

Next grant permissions to your directory as

sudo chown -R $USER:$USER /var/www
sudo chmod -R g+rw /var/www
 
You will now be able to access your localhost directory 
 

Wednesday, March 25, 2015

Configuring External Apache Tomcat in Netbeans/Ubuntu or error : specify the server location (Catalina Home)) and error : could not read server-config.xml

Hi This posts counters the problem of configuration of external Apache Tomcat Server to Ubuntu..

It also deals with the errors
1. specify the server location (Catalina Home))
2. could not read server-config.xml

To Counter all this we need to do as follows

For First Problem create and link directories as follows.This will only occur if Netbeans thinks if you are using and older version of Tomcat Server.

cd /usr/share/tomcat7
sudo mkdir common
cd common
sudo ln -s ../lib lib

For Second Problem create and link directories as follows

cd /usr/share/tomcat7
sudo mkdir conf 
cd conf
sudo ln -s /etc/tomcat7/server.xml server.xml
sudo chmod o+rx /usr/share/tomcat7/conf 
 
Thats it give a username and Password and Apache server is configured on your Netbeans  


Saturday, December 13, 2014

Wordpress-Error:Allowed memory size of 41943040 bytes exhausted

This means that the maximum allowed memory of about 40M has been used and needs to be increased.
As such we write the following command into wp-config.php in order to increase allowed memory. 

In below example we are setting threshold to 64MB

('WP_MEMORY_LIMIT', '64M');

Wordpress-Bypass FTP credientials step for updates(Update on localhost)

If you want to bypass the step where wordpress asks for ftp credentials on update i.e you do not want wordpress to ask for ftp credentials on update specially helpful in updating on localhost

Then in wp-config.php add the following lines to the code
 
define('FS_METHOD','direct');

That's it and this will bypass the ask for ftp credientials

Friday, November 14, 2014

Ubuntu-Connect an Android device using MTP in Ubuntu 14.04 LTS

After Much of Fiddle I was able to connect my ASUS Zenfhone 5 to my ubuntu via MTP Here is How..

1. First we need to install some MTP Apps so run the following command

 sudo apt-get install libmtp-common mtp-tools libmtp-dev libmtp-runtime libmtp9  

Then run

 sudo apt-get dist-upgrade  

2. Then we're going to amend the fuse.conf file. FUSE is an application that aims to provide a secure method for non privileged users to create and mount their own file system implementations.

Run the following command

 sudo nano /etc/fuse.conf  

You will get following lines remove # before last line which allows other users to mount their own file systems

 # /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE)  
 # Set the maximum number of FUSE mounts allowed to non-root users.  
 # The default is 1000.  
 #mount_max = 1000  
 # Allow non-root users to specify the allow_other or allow_root mount options.  
 user_allow_other  

3. Now connect your device using MTP option and run following command
 lsusb  
You will get a list as follows
 Bus 002 Device 007: ID 413c:8160 Dell Computer Corp. Wireless 365 Bluetooth  
 Bus 002 Device 005: ID 413c:8162 Dell Computer Corp. Integrated Touchpad [Synaptics]  
 Bus 002 Device 004: ID 413c:8161 Dell Computer Corp. Integrated Keyboard  
 Bus 002 Device 003: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)  
 Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub  
 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
 Bus 001 Device 006: ID 0b05:5480 ASUSTek Computer, Inc.   
 Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub  
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  

I find the only device connected to my system of name  ASUSTek Computer is my ASUS mobile we need two parts from above line

0b05:5480

Make a note of these and now we will add these to another rules file

4. Run following command

sudo nano /lib/udev/rules.d/69-mtp.rules

Now add the following lines to the file see the idProduct and idVendor we have added change it in accordance with your device

# ASUSTek Computer, Inc.
ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

5. Now we need to add this information to another rules file

sudo nano /etc/udev/rules.d/51-android.rules
 
Now add the following lines to the open file
 ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", MODE=”0666"  

Remember to add correct idVendor and idProduct

6. Restart the service
 sudo service udev restart  

7. Reboot Device

 sudo reboot

That's It

Wednesday, November 12, 2014

PHP-Localize php.ini configs for any directory

Recently while installing Joomla 3.0 I came across a blocker My Hosting Provider's php.ini said

magic_quotes_gpc = on;

which was hindering my way in installation of Joomla on Hosting Space I had...

I was looking for a work around and here is what I did simply...

1. Created a file called php.ini(or php5.ini-to taste of your php installation) in my local directory and added 

magic_quotes_gpc = off;

2. Secondly I created .htaccess and added following lines of code to the same

 
 <IfModule mod_suphp.c>  
  suPHP_ConfigPath /home/blart/public_html/interiors  
  <Files php.ini>  
   order allow,deny  
   deny from all  
  </Files>  
 </IfModule>  

The following directory contains my php.ini file
/home/blart/public_html/interiors  


That's it and I had my  php.ini localized

Saturday, September 13, 2014

Ubuntu LAMP-Enable Curl and mcrypt

To EnaBLE CURL FIRST WE NEED TO DOWNLOAD AND INSTALL 
Curl Libraries for this enable the following command
 
 sudo apt-get install curl libcurl3 libcurl3-dev php5-curl  
 
To Enable Mcrypt we need to download and Install 
Mcrypt libraries
 
 sudo php5enmod mcrypt  
 
Mcrypt is already there and is just not enabled.
 
If its still not accessible locate "mcrypt.so" if you find the same 
 at a location like 
 
/usr/lib/php5/20121212/mcrypt.so
 
edit its path in mcrypt.ini and then run the command
 
"sudo php5enmod mcrypt"
 
That's it this enables both of these php extensions.