8 Replies - 2142 Views - Last Post: 09 August 2012 - 03:38 PM

#1 kwimble  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-August 12

PHP not working (apache2 server)

Posted 08 August 2012 - 10:41 PM

I'm making a website and I've set up a mysql database on my apache2 server. I tried to get the 'create account' feature working and it has horribly failed. I saw a YouTube video tutorial on this and I used the code (which worked in the tutorial). When I tested it in the browser, all the php code showed up as plain text in the page. I checked the PHP tags, and they are all in the proper position. I tried this code in both a '.php' file and a '.html' file.

Anyone know why it's not working?

Is This A Good Question/Topic? 0
  • +

Replies To: PHP not working (apache2 server)

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: PHP not working (apache2 server)

Posted 08 August 2012 - 10:44 PM

did you register .php files to be handled by the PHP interpreter in the Apache configuration?
Was This Post Helpful? 2
  • +
  • -

#3 StefanOnRails  Icon User is offline

  • D.I.C Head

Reputation: 35
  • View blog
  • Posts: 106
  • Joined: 31-July 12

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 01:15 AM

My advice is to uninstall both Apache & MySQL, and then download and install Wamp 2 Server (it's a great tool for beginners and you don't have to worry about configuration). After that go to www directory, delete those files and put your website instead (be carefull your website is running as long as your Wamp server is running).

Or if you're more a youtube guy check this video on how to install Wamp server (note: he is making a new folder instead of deleting all the files in www, you can do that too if you want to access the phpmyadmin via Wamp's homepage).

View Postkwimble, on 09 August 2012 - 07:41 AM, said:

I tried this code in both a '.php' file and a '.html' file.

PHP code works only in .php files located on a server.
Was This Post Helpful? 2
  • +
  • -

#4 kwimble  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-August 12

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 08:09 AM

View PostDormilich, on 08 August 2012 - 10:44 PM, said:

did you register .php files to be handled by the PHP interpreter in the Apache configuration?


How do you register .php files?
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,273
  • Joined: 12-June 08

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 08:12 AM

Okay let's back up.. what OS is this installed on? Are you using something like WAMP/XAMPP/LAMP?

Is the apache server running right? What happens when you open a browser to "localhost"?
Was This Post Helpful? 1
  • +
  • -

#6 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5395
  • View blog
  • Posts: 27,389
  • Joined: 10-May 07

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 09:01 AM

This question has nothing to do with the php language, & was even specified in the topic as an Apache error.

Moving topic to Web Servers & Hosting.

View Postkwimble, on 09 August 2012 - 01:41 AM, said:

When I tested it in the browser, all the php code showed up as plain text in the page

Under httpd.conf you need to add the php file type :

AddType application/x-httpd-php .php

& you have to load your php module so file.

Once you've done both of these, restart your apache server.

For future reference, YouTube tutorials make for poor reference points. I suggest you read Apache's documentation, since they wrote the service.
Was This Post Helpful? 0
  • +
  • -

#7 kwimble  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-August 12

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 09:33 AM

View Postmodi123_1, on 09 August 2012 - 08:12 AM, said:

Okay let's back up.. what OS is this installed on? Are you using something like WAMP/XAMPP/LAMP?

Is the apache server running right? What happens when you open a browser to "localhost"?


The apache2 server is installed on Ubuntu. It says "can't connect to server" when I search ' http://localhost/ ' in the url.
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5395
  • View blog
  • Posts: 27,389
  • Joined: 10-May 07

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 09:45 AM

At the command prompt type ps aux | grep httpd & make sure it's running.
Was This Post Helpful? 0
  • +
  • -

#9 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: PHP not working (apache2 server)

Posted 09 August 2012 - 03:38 PM

If it's not, service httpd start and make sure it's in init.d for startup as a daemon.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1