How do i execute php programs in linux?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
sanjith
Forum Newbie
Posts: 3
Joined: Sat Jun 27, 2009 11:51 pm

How do i execute php programs in linux?

Post by sanjith »

Hi All,
I'm a fresher in php programming and linux.

With Windows, this is what i do. I start the WAMP server and store my php files under c:\wamp\www\Sanjith. And when i go to http://localhost, i get the list of php programs and can run any one of them.

But i dont know how to do something similar in linux.

In linux, I installed and started apache and mysql. Edited the /srv/www/htdocs/index.html file and went to http://localhost to confirm if it was working. And it was. The contents of index.html was shown. But I was wondering.... where do i have to place my php programs so that i can access them from localhost??

I dont know where to store my php programs so that they can be accessed. As in windows, I hope i would be able to access them from localhost itself.

Please help.

With Regards
Sanjith
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: How do i execute php programs in linux?

Post by Doug G »

In Fedora 9 you'll find your httpd.conf file in /etc and in that file you'll see where your document root is and where any virtual hosts may be too.

Without any changes, out of the box Fedora the root of your web files is /var/www/html/ You can add <Directory> and/or <Alias> directives to locate files elsewhere in the filesystem if you wish.
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: How do i execute php programs in linux?

Post by wpsd2006 »

which linux distribution you use ?

in ubuntu it's in the /var/www/
centos /var/www/html/
other i don't know

I'm not sure whether you can change this directory or not
apache should be able to do it

don't forget to install php first
sanjith
Forum Newbie
Posts: 3
Joined: Sat Jun 27, 2009 11:51 pm

Re: How do i execute php programs in linux?

Post by sanjith »

I'm using opensuse11.1.
Currently I'm accessing the files by placing them under /home/sanjith/public_html/<myapps>/
And then typing http://localhost/~sanjith/ in the browser.

Now there seems to be another problem.

I am not able to login to my phpMyAdmin. The root user password is blank and when i try to login, I get #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured).

What should i do??

Regards
Sanjith
marty pain
Forum Contributor
Posts: 105
Joined: Thu Jun 11, 2009 5:32 am
Location: Essex

Re: How do i execute php programs in linux?

Post by marty pain »

get #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured).
I had this when I first started. It's probably because MySQL isn't running. Some Linux distros don't start MySQL on boot. Start MySQL manually and then try phpMyAdmin. If that works then add MySQL to start up.
sanjith
Forum Newbie
Posts: 3
Joined: Sat Jun 27, 2009 11:51 pm

Re: How do i execute php programs in linux?

Post by sanjith »

How do i start mysql manually??
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How do i execute php programs in linux?

Post by VladSun »

If

Code: Select all

pgrep mysqld
return nothing then MySQL daemon is not running.
Try to start it with:

Code: Select all

rcmysql start
If it says "command not found" then you need to install the MySQL package.

http://en.opensuse.org/MySQL
There are 10 types of people in this world, those who understand binary and those who don't
thewebhostingdir
Forum Newbie
Posts: 18
Joined: Fri Jul 17, 2009 1:15 am

Re: How do i execute php programs in linux?

Post by thewebhostingdir »

sanjith wrote:I'm using opensuse11.1.
Currently I'm accessing the files by placing them under /home/sanjith/public_html/<myapps>/
And then typing http://localhost/~sanjith/ in the browser.

Now there seems to be another problem.

I am not able to login to my phpMyAdmin. The root user password is blank and when i try to login, I get #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured).

What should i do??

Regards
Sanjith

Yes, you need to restart MySQL. In windows, I hope you know, we can restart it from the small icon in toolbars.
AccuWebHosting.Com - Windows VPS Hosting
ASP.NET 3.5 | SQL 2005 Database | US Based Hosting Company | 24 X 7 Support | Daily Backups | Uptime Guarantee | Affiliates - $50 Per Sale |
Brick7.com | TheWebHostingDir.com
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

Re: How do i execute php programs in linux?

Post by lipun4u »

execute the following commands one by one in the terminal
sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart
after that, apache+php will already be installed...now put the html and php files in /var/www/ folder.
Post Reply