LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-26-2012, 07:48 AM   #1
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Run php web project on apache2 using /var/www


I have ubuntu operating system. I want to run the php project using apache2.
My project name is mywebapp that is in /var/www. when I try to access this from browser using
Code:
http://localhost/mywebapp
I get the save as box, see the attachment.
i have installed php, apache2, mysql, perl all necessary things because I run bugzilla from /var/www successfully using http://localhost/bugzilla but I am not able to run this project.
The same project is running successfully using /opt/lampp/htdocs when I run through apache but I want to run it through apache2 thats why i am trying to run it through /var/www
If you want any other necessary info regarding this issue, please comment.
Attached Thumbnails
Click image for larger version

Name:	Screenshot.png
Views:	75
Size:	133.5 KB
ID:	9314  
 
Old 03-26-2012, 12:39 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You miss the apache php support. Did you install libapache2-mod-php5?

Regards
 
Old 03-27-2012, 12:03 AM   #3
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300

Original Poster
Blog Entries: 2

Rep: Reputation: 51
Quote:
Originally Posted by bathory View Post
You miss the apache php support. Did you install libapache2-mod-php5?
Yes i have installed this, but no luck.
The project is not started in browser by apache2.
Although apache2 is running fine. It shows me "it works' message. It is well connected with mysql too that is why Bugzilla is running fine.
But other projects are not able to run.
 
Old 03-27-2012, 01:41 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If you used your package manager to install the needed php packages, everything should be sorted
Anyway check the php.* files under /etc/apache2, or /etc/php5 to see if you have
Code:
AddType application/x-httpd-php .php .phtml
Regards
 
Old 03-29-2012, 03:18 AM   #5
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300

Original Poster
Blog Entries: 2

Rep: Reputation: 51
Quote:
Originally Posted by bathory View Post
If you used your package manager to install the needed php packages, everything should be sorted
Anyway check the php.* files under /etc/apache2, or /etc/php5 to see if you have
Code:
AddType application/x-httpd-php .php .phtml
Regards
I have added this line into apache.conf & httpd.conf that is inside /etc/apache2
but, it gives me the download link of .php
Although if i put .html file project which do not have .php file, it runs fine but it has problem with .php
 
Old 03-29-2012, 04:08 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
I have added this line into apache.conf & httpd.conf that is inside /etc/apache2
but, it gives me the download link of .php
Although if i put .html file project which do not have .php file, it runs fine but it has problem with .php
You still don't say if you used your distro's package manager to install the whole stuff. If you did then there should be no reason to add anything to the config files.
Note also that apache config file in ubuntu is /etc/apache2/apache2.conf, not apache.conf or httpd.conf (even though the latter is included in the configuration files)
Anyway, did you restart apache and clear your browser cache before testing? Or try with another browser

Regards
 
Old 03-29-2012, 07:34 AM   #7
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300

Original Poster
Blog Entries: 2

Rep: Reputation: 51
The problem is solved for me

I have found the solution of this problem. May be this can help for future users.
The html project was running fine. The problem was with php files. so I had to enable the php module using-
Code:
$ sudo a2enmod php5
but it was giving error
Code:
ERROR: Module php5 does not exist!
I tried to find php5.conf file in /etc/apache2/mods-available but it was not there. I made it myself and put the following code in it.
Code:
   <IfModule mod_php5.c>
     AddType application/x-httpd-php .php .phtml .php3
     AddType application/x-httpd-php-source .phps
   </IfModule>
Now there should be php5.load file in /etc/apache2/mods-available but it was not there too.I made it too myself and put the following code in it.
Code:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
Note:- i just checked that libphp5.so was available or not at its given path and my good luck, it was there.

Now I made links of php.conf & php.load and put links into /etc/apache2/mods-enabled
Code:
ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf
ln -s /etc/apache2/mods-available/php5.load /etc/apache2/mods-enabled/php5.load
Now I ran-
Code:
$ sudo a2enmod php5
This time it gave me message-
Code:
Enabling module php.
   Run '/etc/init.d/apache2 restart' to activate new configuration!
The problem is solved ,Now I could run my php-web-project through apache2. The path of php-web-project is /var/www/php-web-project

Note:- If the command $ sudo a2enmod php5 gives error. Change file name php5.conf to php.conf, php5.load to php.load and change the name of links respectively php.conf & php.load and run the command $ sudo a2enmod php

Now project should be run fine.
If you are not able to log-in. It means data base is not connected properly. Restart mysql server. If you are still not able to do this.
Open your config file of php-project and change host name 'localhost' to '127.0.0.1'.
Now it should work fine.

Last edited by fortran; 03-29-2012 at 07:37 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Install php web site project on apache2 fortran Linux - Server 5 03-30-2012 12:44 AM
Apache2 root server showing directory contents of a symbolic link in the /var/www dir rtoney5 Linux - Server 7 09-03-2010 07:50 PM
Site error: the file /var/www/hotel/index.php requires the ionCube PHP Loader ioncube muba Linux - Software 1 06-03-2010 10:38 AM
apache2 folder 'var/www' is not shareable; can not edit the index.html file mcanallyd Linux - Newbie 2 06-18-2009 05:46 PM
php move_uploaded_file() not working in /var/www/html jon23d Linux - Software 1 06-07-2006 10:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration