Sunday 7 February 2016

Installing PHP Pear Packages & Mail in Linux

In Linux we can setup Pear Packages & can directly send mail via SMTP & IMAP protocols.
First I will explain how to install Pear Packages in Linux.
Open Terminal, then type the following lines;-

sudo apt-get install php-pear
sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime

Actually this will only download the required packages & store in a folder. So we have to execute it by typing the code below.

sudo gunzip /build/php5-0LI9sl/php5-5.5.9+dfsg/pear-build-download/*.tar
sudo pear upgrade /build/php5-0LI9sl/php5-5.5.9+dfsg/pear-build-download/*.tar

Here Location will be different for different installation, so you just replace the location depend on your installation
Now just restart the apache server
sudo service apache2 restart

Next step is to install Imap package.Type below in the terminal
sudo apt-get install php5-imap
sudo php5enmod imap
sudo service apache2 restart

Now check..everything will work Perfectly..

Changing The root mysql Password in Linux

Unlike windows, In linux its mandatory to give Mysql root password,otherwise it will not allow us to enter into the database. I will explain step by step on how to do this.

1) Stop the running Mysql process. It by typing following command in the Terminal.
sudo /etc/init.d/mysql stop

2)Connect to Mysql server without password. For this type the following in the terminal.
sudo mysqld_safe --skip-grant-tables &

3)Connect to mysql user using mysql client

sudo mysql -u root

4) Now you will enter into mysql inter face, type following in the terminal
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where user='root';
flush privilages;
quit

5) stop Mysql server

sudo /etc/init.d/mysql stop


6) Now start the Mysql server and test it
sudo /etc/init.d/mysql start
mysql -u root -p

Setting up PHP Mysql in Linux

We are familiar with WAMP in windows for running PHP applications. Like wise it is Known as LAMP in Linux. LAMP stands for Linux Apache Mysql PHP

Below I will show step by step  instruction on how to install it.

1) First step is we have to install Apache. For this :-
Open Terminal(Applications->Accessories->Terminal)

sudo apt-get install apache2

Then it will ask you for password & type enter.

2) Test whether it is installed correctly or not. For this type http://localhost in the browser url. It will give a page if its correctly installed.

3) Next step is to install PHP. For this type the following in the Terminal & press enter

sudo apt-get install php5 libapache2-mod-php5

4) Now restart apache to make php compatible with apache. Type the following in terminal & press enter

sudo /etc/init.d/apache2 restart

5) Next step is to install Mysql. For this Type following in the terminal & press enter
sudo apt-get install mysql-server


6) Next step is to instal;l PHPmyadmin, which is an easy tool to edit our databases. For this type the following in terminal & press enter
sudo apt-get install libapache2-mod-auth-mysql  php5-mysql  phpmyadmin

7) Next step is to make mysql work with PHP , for this we have to open PHP configuration file and enable mysql extension in it.
gksudo gedit /etc/php5/apache2/php.ini

Find the Line
;extension=mysql.so   
Remove the semicolon which will look like this
extension =mysql.so

8) Now Just restart the apache
sudo /etc/init.d/apache2 restart

9) Now check if its working by typing localhost/phpmyadmin in your browser. if its giving error then
we have to edit apache2.config file .Type following Line & press enter
sudo gedit /etc/apache2/apache2.conf

Include the following line in the bottom of the page..

Include /etc/phpmyadmin/apache.conf


10) Now Just restart apache & check..

sudo /etc/init.d/apache2 restart

To find out strict mode status, run the below sql

SHOW VARIABLES LIKE 'sql_mode';

If the output value contains STRICT_TRANS_TABLES, then strict mode is enabled.

To disable strict mode, run the below sql

SET GLOBAL sql_mode = '';

To enable strict mode, run the below sql

SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES';

 


Now Everything will be working fine... Enjoy...



Installing Symfony in Windows

Symfony-The leading PHP framework to create websites and web applications. Built on top of the Symfony Components. Installation of symfony is slightly different from PHP's other frameworks. I will explain you step by step on how to set up your first Symfony application running in your windows PC.
1) Firstly make sure that curl is installed in your computer. If not then download it from here
Then Extract the folder & copy all the contents & paste it into the C:/Windows/System32 Folder.

2) Now its time to install Symfony. First open the Command prompt (type run insearch.,In it type cmd & press enter). Open it in administrator mode.

3) In the command prompt window just type
php -r "readfile('https://symfony.com/installer');" > symfony

2) Now symfony installation file will be automatically downloaded into your system.Now its time to move the downloded file to the working folder. For this type in the cmd like shown below , second argument will be location of the project. After that enter into the directory By typing cd & then executing PHP command.

3) Now its time to create the application. Now enter into the directory type the following command
php new my_project

4) To run the application, Enter into the project folder from cmd & then type
php app/console server:run
5) The  inorder to view our application go to the browser & type
localhost:8000/
6) To stop the application run,type following in the cmd
php app/console server;stop


c:\> move symfony c:\wamp\www\myapps\
c:\> cd wamp
c:\wamp> cd www
c:\wamp\www>cd myapps
c:\wamp\www\myapps\> php symfony  
c:\wamp\www\myapps\> php new my_project_name   /* project will be created*/
c:\wamp\www\myapps\> cd my_project_name        /*Navigate to project Directory */    
c:\wamp\www\myapps\my_project_name\> php app/console server:run  /* Running the application */