LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-14-2012, 05:06 AM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
invoke php from a self made webpage on my home computer


I have a form page, which should be sent to my email. Here is a bit of it:
<body>
<h1>Send Us Your Feedback!</h1>
<form action="send_mail.php" method="post">
<table>
<tr>
<td>Email Adress:</td>

I also have a php script.
But when I click send, it doesn't, up comes a window asking me if I want to 'open send_mail.php with gedit', or 'save the file'.

This is a problem with php.ini I think. What should I have there??

Found php.ini, edited it thus:

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail

But still don't work. I'll try a reboot.

Reboot didn't do it either!

Last edited by Pedroski; 07-14-2012 at 05:36 AM.
 
Old 07-14-2012, 06:27 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
What you see when you choose to "open with gedit"? If your php code then this is problem in webserver configuration (tell which you use), not parsing php files. If you see expected script execution result or empty file, then your server should send appropriate Content-Type header along with result (text/html for example).
 
Old 07-14-2012, 07:14 AM   #3
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
If I click on open, it opens the .php file as a text file. I wanted it to run it.

I added #!/usr/bin/php at the top of the .php file, to tell it where php is.

Any tips? How do I make sure the php script runs as a script. It is marked executable.

I am doing this at home on my computer, not on a host, just trying things out.

Oh yeah: I have apache2 installed. Do I need to tell apache what to do? In an .ini file??

Last edited by Pedroski; 07-14-2012 at 07:46 AM.
 
Old 07-14-2012, 09:28 AM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,487

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
Check your httpd.conf file to ensure that the line below is uncommented:

Quote:
Include /etc/apache2/mod_php.conf
Also need a line similar to the one below:

Quote:
AddType application/x-httpd-php .php .php3 .php4 .php5
A line similar to the one below should be uncommented:

Quote:
LoadModule php5_module lib/apache2/libphp5.so
 
Old 07-14-2012, 09:40 AM   #5
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
My /etc/apache2/httpd.conf is completely empty! That's not good! Do I need to run a 'set up apache' somehow?

Tried that, but no joy! Any further tips?
Also in /etx/apache2/sites-enabled is a file OOOO-default. It contains among other things this:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

Should I have a similar thing for php???

Last edited by Pedroski; 07-14-2012 at 10:08 AM.
 
Old 07-14-2012, 07:50 PM   #6
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
I've been reading about this, and I need libphp5.so, which is nowhere on my computer. I don't know if it is a file that belongs to apache2 and didn't get installed for some reason, or it comes with php and didn't get installed.


http://www.petefreitag.com/item/516.cfm Ok, so I changed php4 for php5, but the rest should stay the same.

I also do not have httpd on this machine.

pedro@pedro-bedro:~$ whereis httpd
httpd:
pedro@pedro-bedro:~$
 
Old 07-14-2012, 10:07 PM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,487

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
Which distribution of Linux are you using as the location of the directories/files varies somewhat. How did you install Apache? Do you get the IT WORKS page in Apache? Some of the more popular distributions allow you to do a LAMP install without installing separately, Apache, php/perl, mysql. I'm not sure how you would get an empty httpd.conf file if you have Apache installed.
 
Old 07-14-2012, 10:26 PM   #8
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
I use ubuntu 12.04 at the moment. I am connected to the net via China Telecom, so what I normally see runs through their server.
I am making a web page, and want to try things out at home before I put it anywhere, as I am only a beginner.

It must be possible to tell Firefox to open *.php with php.
 
Old 07-15-2012, 05:50 AM   #9
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
still struggling

I'm wondering if this can be done. I want to use apache2 on my own laptop, but my internet connection is through China Telecom. I tried booting without the dsl cable plugged in, made sure I had apache2 running,
pedro@pedro-bedro:~$ sudo /etc/init.d/apache2 restart
[sudo] password for pedro:
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]

then started Firefox,but I still get, well see screenshot.

I've been following the instructions here

https://help.ubuntu.com/10.04/serverguide/php5.html and on the previous page, but it still won't run the send_mail script, or the testing script
<?php
phpinfo();
?>

Can it be done on my own computer at home?? Can apache2 serve Firefox on this computer??
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2012-07-15 18:39:12.png
Views:	16
Size:	37.1 KB
ID:	10121  
 
Old 07-15-2012, 07:00 AM   #10
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
I thought of something: if I make a new internet connection with fixed ip 127.0.1.1, will my home based apache then serve Firefox and implement my php script??

Can I do that like that??

Maybe when I click the submit button, Firefox looks for apache/php on the China Telecom server, finds nothing, and asks me if I want to open the script as text.
 
Old 07-15-2012, 09:22 AM   #11
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
How do you display your html file? Through your server (e.g. http://localhost/yourpage.html)? Or by double-clicking it in a filemanager? You must serve your pages through your webserver for it to work.
 
Old 07-15-2012, 05:51 PM   #12
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thanks for that. It nearly worked.
Using Firefox if I enter,

localhost, I get apache2 default index.html, which just says 'It works' Good, but not quite what I wanted.

http://localhost/home/pedro/newwebpage gets me a 404 'not found on this server'
I checked this:
pedro@pedro-bedro:~$ sudo a2ensite mynewsite
[sudo] password for pedro:
Site mynewsite already enabled
pedro@pedro-bedro:~$


In /etc/apache2/sites-available/ I have default, defaultssl and mynewsite

mynewsite has among other things copied from default, this

DocumentRoot /home/pedro/newwebpage
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/pedro/newwebpage/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

which clearly points apache at /home/pedro/newwebpage But, it doesn't find it, and goes to default. Clearly, I have done something wrong, or forgotten to do something.

Any idea what??

Last edited by Pedroski; 07-15-2012 at 06:17 PM.
 
Old 07-15-2012, 07:29 PM   #13
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,487

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
Quote:
localhost, I get apache2 default index.html, which just says 'It works' Good, but not quite what I wanted.
That tells you Apache is working at least. Generally, these files (including the index.html IT WORKS file) are either in the /var/www directory/sub-directories or in a /home/user public_html directory. You could try putting your newwebpage file there to see if it is found.

I've not used the a2ensite program so I'm not sure if I'm reading this correctly. Your Document Root shows: /home/pedro/newwebpage which should be the folder you have the file in so what's the file?
 
Old 07-15-2012, 07:35 PM   #14
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
There are a few files, and I believe one should always have an index.html so of course I have that there too, and also my send_mail.php
but apache2 does not find it or anything, and defaults to, well, its default index.

There must be something wrong with my /etc/apache2/sites-available/mynewsite I think. But what??

a2ensite just configures apache for a new site. The docs say

The /etc/apache2/sites-available directory is not parsed by Apache2. Symbolic links in /etc/apache2/sites-enabled point to "available" sites.

I am no expert, but I don't think that is the right way to go, putting all files in /var/www It is possible and I think preferable to put them elsewhere. I know they work, I have tried them. Just the send_mail.php won't work.

Last edited by Pedroski; 07-15-2012 at 08:09 PM.
 
Old 07-15-2012, 10:07 PM   #15
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Put the question this way:

I have two virtual hosts: default and mynewsite. How do I tell apache which one I want, when I enter localhost in Firefox?

I presume this has to do with ServerName, so I gave mynewsite the ServerName pedro but that didn't work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
php cannot invoke msmtp gmail_cs Linux - Newbie 6 03-10-2011 07:41 PM
How to re-invoke dhcpd after changes were made to dhcpd.conf file. Azazwa Linux - Newbie 3 03-30-2009 04:44 AM
PHP webpage issue Dillius Linux - General 1 07-11-2006 05:07 PM
how to invoke Mozilla webpage in full screen when it is run taoweijia Programming 5 02-21-2004 04:45 PM
making a webpage server and home network server on the same computer ferretmanus Linux - Networking 1 09-11-2003 10:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:25 AM.

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