Install Phalcon PHP framework in Fedora

In my last article i discussed that how to install phalcon framework in openSUSE, and i guess it was quite fun and easy. Today i am extending the installation to Fedora. I installed it on Fedora 19, 20 and i hope there would be no problems for anyone, it will be quite simple and easy to install. As we know, we don’t have any repo or RPM at the moment for Fedora, so we will build it from source. Don’t worry it will not be scary. Read this for the dependencies 1st.

Fire up the terminal and i assume that you are in your home dir ([user@localhost ~]$). But no worries, you can change the dir to any where you want like your backup drive etc. Let’s go with home in this article. We need to clone the phalcon repository from github and create the extension from source.

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”3″ tab_size=”4″]
[user@localhost ~]$ git clone git://github.com/phalcon/cphalcon.git
[user@localhost ~]$ cd cphalcon/build
[user@localhost ~]$ sudo ./install
[/cc]

That will do the necessary for now, one last thing now. Open php.ini in terminal or whatever GUI editor you prefer(i will use vim):

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
[user@localhost ~]$ sudo vim /etc/php.ini
[/cc]

And add this line:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
extension=phalcon.so
[/cc]

Save and that’s it. Time to restart the server:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”1″ tab_size=”4″]
[user@localhost ~]$ sudo service httpd restart
[/cc]

Download any of the app from the phalcon repo like invo OR vokuro etc, and give it a try.

Enjoy!

Install Phalcon PHP framework in openSUSE

Phalcon is a web framework implemented as a C extension offering high performance and lower resource consumption”. From the benchmark page, “The compiled nature of Phalcon offers extraordinary performance that outperforms all other frameworks measured in these benchmarks”. Personally i find it very easy to work with, less dirs and files for the project. And it’s documentation is quite organized and useful. Installation in Linux distros is quite easy for most of the parts. Let’s install in openSUSE 12.3 and 13.1. 1st of all let’s thank Mariusz Łączak for his useful work to provide repositories. Fire up a terminal and become root by su – .

If you are on openSUSE 12.3, add this repo:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ar -f http://download.opensuse.org/repositories/home:/mruz/openSUSE_12.3/ Phalcon

[/cc]

For openSUSE 13.1:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ar -f http://download.opensuse.org/repositories/home:/mruz/openSUSE_13.1/ Phalcon

[/cc]

zypper-add-repo-phalcon

Refresh the repos:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper ref

[/cc]

It will ask for the key to trust for the new repo, just type a to trust always. We are almost there.

Before installation of phalcon, we need to make sure that these dependencies are installed: mbstring, mcrypt, opensll, pdo/MySQL

If not, no worries install it by using this command:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper in php5-mbstring mcrypt openssl php5-pdo

[/cc]

Time to install phalcon:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

zypper in php5-phalcon

[/cc]

And that’s it, but before jumping to your web dir to start a demo project, restart apache:

[cc lang=”bash” escaped=”true” nowrap=”false” noborder=”true” line_numbers=”false” lines=”2″ tab_size=”4″]

systemctl restart apache2.service

[/cc]

Phalcon documentation are self explanatory and easy to follow. Start here for a test project.

Speed up your website loading time by using PHP APC [Part-5]

In some cases if you are running WordPress OR some other database extensive application on micro instance, you will experience slow page loading on various occasions.
There is a nice solution to that, install PHP APC to cache most the PHP code for fast loading.

I assume that you are already on the server console through SSH:

sudo su

1st let’s install few needed dependencies with php pear:

yum install php-pear httpd-devel php-devel

Now time to install APC by pecl command:

pecl install apc

Add a line to apc.ini to load the module:

echo “extension=apc.so” > /etc/php.d/apc.ini

Restart the httpd server:

service httpd restart

And that’s it, you will notice quite a difference now. The execution time per page will now reduce dramatically. I have tested it on a micro instance for a WordPress site, and i can confirm that the site loads fast now.

Continuation:

Part-1: Setup web server on Amazon AMI or CentOS

Part-2: Backup MySQL data into CSV

Part-3: Backup MySQL data into CSV with PHP

Part-4: Backup and Restore MySQL databases

Setup web server on Amazon AMI or CentOS [Part-1]

If you are using Amazon aws with ec2 instances, then i assume you already have the pem file to connect to the instances. Normally you will have different instances for your projects. I normally setup either Amazon AMI or Cent OS, prefer Amazon AMI as it is also based on Cent OS. Cent OS is best and easy OS for servers. I love the configuration and level of interaction it provides.
Let’s say you want to install a web server with MySQL and PHP, run the following command:

sudo yum install httpd mysql-server php php-mysql mysql php-xml php-pdo php-odbc php-soap php-common php-cli php-mbstring php-bcmath php-ldap php-imap php-gd mod_ssl

That will install all the necessary modules and packages to run a fully functional server.
In some cases we don’t need/want a web server, just database server will do it:

sudo yum install mysql-server mysql

That will only install database server on the instance.
Now let’s say we dont need either PHP or MySQL:

sudo yum install httpd

Some time we don’t need database server on the same web server instances:

sudo yum install httpd php php-xml php-mysql php-pdo php-odbc php-soap php-common php-cli php-mbstring php-bcmath php-ldap php-imap php-gd mod_ssl

That will install all necessay packages excluding MySQL.

Now if you have a MySQL server, for sure you would like to make it secure, that is easy:

sudo /usr/bin/mysql_secure_installation

The above command will ask you some questions, answer the questions carefully and you will get through it.
Don’t forget to remove anon users and test database while running the above command.

If you have .htaccess file and want to utilize mod rewrite, enable it in /etc/httpd/conf/httpd.conf in the server directory section:

AllowOverride None
to
AllowOverride All

To auto restart your server and database server in case the system is restarted:

sudo chkconfig httpd on
sudo chkconfig mysqld on

Manually start the servers:

sudo service httpd start
sudo service mysqld start

Some interesting information i will share in upcoming articles: Load balancer for multiple instances, configuring SSL on load balancer, creating databases and changing password, Dumping databases and saving table/database to csv and save only database schema. And separating your database server from web servers with load balancer and adding the instances to database for security purpose to read/write into database instance.

So stay tune, there are more and plenty to come.

Continuation:

Part-2: Backup MySQL data into CSV

Part-3: Backup MySQL data into CSV with PHP

Part-4: Backup and Restore MySQL databases

Part-5: Speed up your website loading time by using PHP APC

Enable mod_rewrite on openSUSE 11.3 [Linux]

UPDATE (31-08-2013):  This article can also be used for openSUSE 11.4 , openSUSE 12.1, openSUSE 12.2, openSUSE12.3 and Sles 11(server). 🙂

Last night i installed vanilla forum the latest version(2.0.16), but before that i got into trouble like ‘cannot install vanilla forum because the database host provided is wrong’ some thing like that type of error. Which was basically by .htaccess file. I finally installed it but after some time figuring out the mod_rewrite ghost. Actually it’s quite easy to enable it, there was one thing missing, which took some of my time to figure it out. Lets start how to enable the ghost.

Section-I

1- Open Konsole and become root by su – .

2- I will use vim for editing in konsole, you can use other IDE or GUI application. We need to edit this file /etc/sysconfig/apache2 .

3- Type

vim /etc/sysconfig/apache2

Now apache2 file is open and we need to do some changes in it.

Note: If you are not familiar with vim commands, read it here and be careful to use it. You will need few commands like how to insert(i key), how to quit insert mode(Esc key), how to save the file(:wq [w=write, q=quit]), how to exit the file without save(:q). The link i provided is for reference.

4- Search for APACHE_MODULES and you will see a line some thing like:

APACHE_MODULES=”actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5″

Now we will add rewrite at the end of the line and it will become:

APACHE_MODULES=”actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5 rewrite”

Save and quit the file with :wq command.

5- Run SuSEconfig to update the Apache configuration files.

6- Restart the server with:

/etc/init.d/apache2 restart

You can check it from PHP info page, create a info.php file and look for rewrite word:

<?php phpinfo(); ?>

If you got it in info.php page, now you can check it with any application you have like WordPress, Vanillaforum, your own files etc. If it works, then skip section-II , Section-III and enjoy.

Section-II

Oh…not working…getting access forbidden page etc etc… don’t panic, there are a little more to change. We need to enable custom Apache .htaccess mod_rewrite now. As you are familiar with vim now, so i am not going to deep now, just the steps which will get you started rewrite.

1- I assume konsole is open in root mode, we need this file to edit now: /etc/apache2/default-server.conf .

2- Type

vim /etc/apache2/default-server.conf

3- Search for AllowOverride , it will be below <Directory “/srv/www/htdocs”> . /srv/www/htdocs can be changed, if you changed your sever root before to some other directory.

4- And change AllowOverride None to AllowOverride All , which will allow you to create custom .htaccess rules.

Save and exit.

5- Run SuSEconfig to update the Apache configuration files.

6- Restart the server with:

/etc/init.d/apache2 restart

That’s all, now you can test it again. If it works, then skip Section-III, if have problems follow section-III which will make sure that now every thing is under control and you can use mod_rewrite.

Section-III

Now time to elaborate that one thing which took my time, it was FollowSymlinks in default-server.conf file. From Section-II step 3(between <Directory ….> tags), search there Options if you see it like Options FollowSymlinks OR Options indexes FollowSymlinks , then its fine, but if not just add this FollowSymlinks , and it will become Options FollowSymlinks .

Follow step 5 and 6 above to restart the server and update the files.

That’s it. Have a lot of fun!