LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Migrating xampp website, but php form doesn't send email from new server (https://www.linuxquestions.org/questions/linux-server-73/migrating-xampp-website-but-php-form-doesnt-send-email-from-new-server-4175517304/)

anon091 09-03-2014 04:32 PM

Migrating xampp website, but php form doesn't send email from new server
 
Hi everybody. I've been working on migrating a current dying server running a website in xampp to a new server in a modern version of xampp. I think i'm almost there, but I'm having a problem with a .php webpage that's a form that (when working) emails the form data to someone.

The form displays ok, but for some reason the email doesn't send when I hit the submit button. Comparing to the dying server that still works, I don't see anything in /var/log/maillog on the new server like I do on the dying one, so I'm guessing it's not trying to send.

I know sendmail is working, because i can manually send an email via the command line.

But does anyone have a clue where I should look as to why from here? and sorry, I know this is a real vague question.

unSpawn 09-05-2014 06:39 AM

Quote:

Originally Posted by rjo98 (Post 5231974)
I've been working on migrating a current dying server running a website in xampp to a new server in a modern version of xampp.

Well, sorry to say but that's where you've gone wrong in the first place. As I've been saying for years, as the XAMPP documentation (which now seems to be tucked away so you'll only find it when you're really looking for it) has been saying for years XAMPP is not intended for use in Production Environments: see Is XAMPP production ready? *XAMPP is a "convenience" suite of software solely for development use, and then only for those that can't be (bothered to) learn how to set up LAMP properly. With all due respect people who can't be (bothered to) set up Apache, MySQL and PHP properly shouldn't be let near any public-facing server in the first place.


Quote:

Originally Posted by rjo98 (Post 5231974)
does anyone have a clue where I should look as to why from here?

Not where but who: if you're not a coder chances are you don't know safe coding standards. (Last time I looked your profile didn't read "PHP coder".) That said start by comparing the new environment (which I sure hope is on an isolated Staging machine and not in Production yet) with the old in terms of daemon configuration (including includes), users, file and directory access rights and phpinfo(). Note that there may be huge differences between deprecated and current PHP versions.
If that's not it craft a simple temporary mail form yourself that's been known to work and test with that.
If that's not it check if adding
Code:

<?php
 ini_set('display_errors', 'On');
 error_reporting(E_ALL);

to the "misbehaving" mail form helps.
If that's not it look into http://xdebug.org/.

*Note none of the above detracts from the fact you (or your client) choose to use XAMPP which you should not.

anon091 09-05-2014 08:15 AM

Thanks unSpawn. Yeah, definitely not a PHP coder, and no clue why they went with xampp to begin with (probably due to your too lazy to configure it properly), but they requested it in xampp again (I think because they think a .tgz backup of the entire thing is so easy).

And honestly, I've never really set up a web server before in general but i'm trying to learn. I did already create a php form I copied from a php tutorial to simply enter a few fields and send an email, but that didn't do anything either. Also, the existing form does work on the old server.

I'll try your couple suggestions and post back.

unSpawn 09-05-2014 08:34 AM

Hmmm. If you're "just a grunt" you could suggest they should not use XAMPP. On the other hand if you're hosting their web site you have a responsibility and you should tell them. After all then its your server that will be abused, IP address that will get a bad reputation or be blacklisted, your time that will be wasted mopping up...

anon091 09-05-2014 08:55 AM

I'd like to suggest to not use xampp, but with me not exactly knowing how to setup a web server in general, I'd feel kinda silly, know what I mean.

Really this site is just some html pages and a couple php forms that send emails out. and it's strictly an internal server/site.

anon091 09-05-2014 09:06 AM

Added that bit of php code to the test form I had, don't see any errors on the webpage itself, it acted like it worked, but didn't get any email. I hate xampp haha.

anon091 09-05-2014 09:08 AM

unSpawn, or anyone reading this, is there a good tutorial out there I can follow step by step to try to set this up in a "legit" way (not using xampp)? I'd love to give it a shot since xampp gets no love.

anon091 09-05-2014 10:34 AM

OK, think I found what may be a good article to try to give this a go sans xampp.

https://www.digitalocean.com/communi...-php-on-fedora

Does this sound about right to you guys? Then i just need to figure out where to put the .htm and .php files from the current site onto the new server, and I might be in good shape since sendmail is already working?

I know, kinda going off topic here, but i think this is the right way.

unSpawn 09-05-2014 10:48 AM

For one thing the database this site uses (if any, as it's plain HTML as you said) you can export and check for whatever is there. Then check php.ini, my.cnf and httpd.conf and includes and the vhost definition. Take another (virtual?!) machine, install a "base" install of CentOS 6.5 and configure it using https://www.centos.org/docs/ and http://wiki.centos.org/Documentation, http://wiki.centos.org/HowTos and http://wiki.centos.org/TipsAndTricks. Using the http://www.sans.org/score/checklists/linuxchecklist.pdf, https://people.redhat.com/sgrubb/fil...ning-rhel5.pdf and https://access.redhat.com/documentat...uide-en-US.pdf harden the OS. Install Apache, MySQL and PHP. Make backups of the original php.ini, my.cnf and httpd.conf and compare with the "old" ones. Leave default settings as much default as possible. With the httpd.apache.org/docs/, dev.mysql.com/doc/ and php.net/docs.php at hand edit in the changes you have verified this site requires. Rsync the docroot and test. Proceed by verifying using GNU/Tiger, https://benchmarks.cisecurity.org/downloads/ and https://www.owasp.org/index.php/Cate...op_Ten_Project. Top it off by running a remote OpenVAS scan, ensuring backup testing, auditing as well as regular software updates are in place.

Is it that easy?
Yes, it is! ;-p

anon091 09-05-2014 10:53 AM

I'm already loading up a base CentOS 6.5 in vbox, so at least I was on the right track before you posted :-)

Thanks for all those links! I'm going to give this a go. I'll post back if/when I run into any problems, or if I successfully do this on my own (fingers crossed).

Also, I asked and they said if there are any databases on there, their so old I don't have to worry about them. So maybe I don't even need MySQL installed, idk.

Habitual 09-05-2014 10:54 AM

Step 4 of that link has a clue.
Every host must have a DocumentRoot, and sometimes they even point to the same place on the host ;)

While it doesn't illustrate L.A.M.P. http://www.server-world.info/en is a great resource.

anon091 09-05-2014 11:00 AM

Thanks guys. I got my base CentOS installed, its updating now. Then i'll do my basic configs/tweaks, then see if I can get Apache, MySQL and PHP installed and at least displaying some pages. Here we go...

unSpawn 09-05-2014 11:13 AM

You're showing you're actively doing & learning stuff and that's commendable.

anon091 09-05-2014 11:20 AM

Thanks. I'm really trying to figure this out here. Have a quick question about php though. When I look at the current server and do a
rpm -qa |grep php-
php-4.3.9-3.36
php-ldap-4.3.9-3.36
php-odbc-4.3.9-3.36
php-mysql-4.3.9-3.36
php-pear-4.3.9-3.36

that's what I get. But does that necessarily mean those are things I need since before that was all in xampp, and now i'm trying to do it sans xampp? really I think the only php on this site is in forms to send emails, so i'm thinking maybe I give it a go with just php and not all the php-extras (also going under the impression I can skip MySQL).

anon091 09-05-2014 01:07 PM

Quick update. Got the base server where I needed it (mostly, didn't go too crazy cuz I didn't want to leave you guys hanging), installed apache and php, made a test php info file (stole idea from that link I posted) and a test mail form php file in /var/www/html, the php info file displays php info, and the mail form when I submit I see some action in /var/log/maillog. I didn't get the email, but maybe I have to configure something differently for it to work through the vm through my machine to the mail relay, but the fact that it's actually doing something in the log is a positive sign!

Now I need to figure out how to undo all the xampp stuff on my real replacement server, then go this route. Reading online it looks like supposedly all I need to do is a rm -rf /opt/lamp.

Actually, this is way easier than trying to get xampp going to. And here everyone told me xampp made things easier...


All times are GMT -5. The time now is 03:51 PM.