Dec 23

A Comprehensive Guide To Run Yii Framework On XAMPP In Linux

Yii is professional PHP framework best for developing Web 2.0 applications. This guide elaborates on how to set up the Yii framework in XAMPP under a Linux environment.

First you need to download and install XAMPP as indicated in the XAMPP guide in http://www.apachefriends.org/en/xampp-linux.html. Then you need to get write permissions to the /opt/lampp/htdocs folder (where all the websites will be stored). First look at who is owning /opt/lampp/htdocs .

 Bash |  copy code |? 
1
ls -ld /opt/lampp/htdocs

This should return something like

 Bash |  copy code |? 
1
drwxr-xr-x. 5 root root 4096 Dec 22 22:55 /opt/lampp/htdocs

drwxr-xr-x. denotes the file permissions of the folder. The part root root specifies the owner of the directory and the owning group of the directory. Let’s first change the owning group of the folder. Let’s create a group called www and change the group ownership of the folder to www.

 Bash |  copy code |? 
1
sudo groupadd www
2
sudo chgrp -R www /opt/lampp/htdocs

Now a ls -ld should return something like the following

 Bash |  copy code |? 
1
drwxr-xr-x. 5 root www 4096 Dec 22 22:55 /opt/lampp/htdocs

Now the XAMPP server should be configured to run using the group www. Open the /opt/lampp/etc/httpd.conf file.

 Bash |  copy code |? 
1
sudo vim /opt/lampp/etc/httpd.conf

Then find the entry,

 Bash |  copy code |? 
1
User daemon
2
Group daemon

(yours might be slightly different). Change the User entry to your user name and Group entry to www. Now you need to set the permissions of the /opt/lampp/htdocs folder.

 Bash |  copy code |? 
1
sudo chmod 2775 /opt/lampp/htdocs
2
usermod -aG www <username>

You’ll need to logout and log in to the system since group memberships are read at login time. But before doing that, let’s carry out another task that will require a logout. We need to add PHP to our PATH. So open your .bashrc as follows.

 Bash |  copy code |? 
1
vim /home/<username>/.bashrc

Then add the following lines to the end of that file.

 Bash |  copy code |? 
1
##Adds XAMPP bin to PATH
2
export PATH=/opt/lampp/bin:$PATH

Now logout and login. Then extract the Yii framework to a folder named yii in the /opt/lampp/htdocs folder, start the XAMPP server and go to the address http://localhost/yii/requirements/index.php to check whether Yii is working. Then to create a Yii application, follow the following commands. I have used the test name blog.

 Bash |  copy code |? 
1
cd /opt/lampp/htdocs/
2
php ./yii/framework/yiic webapp blog

After completing the creation, visit http://localhost/blog/ to verify the functionality of the created Yii application…!.

References :

  1. http://superuser.com/questions/268987/cant-create-any-folder-in-htdocs-on-ubuntu
  2. http://stackoverflow.com/questions/14318699/xampp-virtual-host-access-denied
  3. http://www.yiiframework.com/forum/index.php/topic/1838-install-yii-on-xampp-on-linux/page__p__10296__hl__yii+linux+in+tallation#entry10296
  4. http://www.yiiframework.com/doc/blog/1.1/en/start.testdrive
Share Button
Jan 18

Create custom error pages in cPanel

As we know, when we connect to a web server, if some error occurs, the server will show us some error message. As an example if the web page we are requesting is not available in the server it will generate a 404-page not found error. But as you have noticed, in most cases this error page is just a simple page which most probably has a white background with some simple text formatting. But do you know that you can customize those error pages as you like? Give it a theme( as an example, the theme of the webs site it self)? In this article I’m going to show you how to customize these error pages in a web server where you have access to cPanel. There are two methods to do this.

1st method:

Log in to cPanel. Then go to Advanced → Error pages . There you will find a list of various error pages that cPanel currently has. Click on any one of them and you will be directed to a page where you can customize the page using usual html syntaxes .

2nd method:

If you want to replace the error page with a page that you have already designed, the easiest way to do so is to upload it to the server and replace the relevant file. The relevant files for the error pages can be found in the public_html folder. These files have the .shtml extension. So make sure that you rename the .html file that you are uploading to the .shtml extension. Here are some names of the error pages.

  • 400.shtml : Bad request
  • 401.shtml : Authentication required
  • 403.shtml : Forbidden
  • 404.shtml : Page not found
  • 500.shtml : Internal server error

You will be able to find an example customized 404 page in http://ishans.info/wrongURL

Share Button
Jan 17

Weird WordPress problem: Wp-admin redirects to localhost

Have you experienced this weird problem? It most probably occurs when you develop your wordpress blog in your local server and upload the blog to your Internet web server. I too faced this problem when I uploaded my blog to my Internet server. Here’s how I got around it.

To rectify this problem in my way ( ;) ) you need access to the database which is used by your blog. I used phpMyAdmin to access the database of the blog. You can use any other tool you like. You need to edit an entry in a table of the database to rectify the problem.

First access the database and go to the table named wp_options ( sometimes this could be named as options too). There , you will find an entry named siteurl . You will see that this entry has the value( option_value) http://localhost/yourWpFolder . You need to edit this entry to your blogs URL. As an example, in my case I edited it as http://blog.ishans.info . After setting the value, click on Go and you’ll get a message saying the change was successfully done. Now you’ll see that “http://mySite.xxx/wp-admin” address is working.

But it’s not over yet. You need to set another setting in wordpress settings too. Log in as the Administrator to the wordpress dash board and go to Settings . In here you’ll see that the entry WordPress address (URL) is set to “http://mySite.xxx” , but the entry Site address (URL) is still http://localhost/yourWpFolder . So you need to set the Site address (URL) entry to “http://mySite.xxx” .

Thats it…!. Now save your settings and you’ll see that the whole site is working perfectly ( If it doesn’t have any other errors of course ;) )…..! :D

Share Button