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! |
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).
|
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?? |
Check your httpd.conf file to ensure that the line below is uncommented:
Quote:
Quote:
Quote:
|
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??? |
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:~$ |
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.
|
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. |
still struggling
1 Attachment(s)
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?? |
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. |
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.
|
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?? |
Quote:
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? |
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. |
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. |
All times are GMT -5. The time now is 04:13 AM. |