Results 1 to 8 of 8

Thread: ubuntu 18.04 as webserver question

  1. #1
    Join Date
    Apr 2019
    Beans
    42

    ubuntu 18.04 as webserver question

    First, some background. Running 18.04 as a web server. The web pages were developed on a Mac using the iWeb package. After publishing the pages to a directory called Dirname, the directory is copied to the Ubuntu machine and placed in /var/www/html/Dirname. Using Firefox as the browser, using the URL 'localhost' brings up the Home page. On this Home page there are links to other pages (.html files). One such page (Form-page) uses an html snippet to present a form for user input. Upon submitting this form the action is to invoke another file (form.php) to process the input information.
    This is all normal web processing so far. The problem is that the URL displayed when the .php file is invoked is wrong and therefore cannot be found.
    When the Home page is displayed the URL is 'localhost/Dirname/Home.html'.
    When the Form-page is displayed the URL is 'localhost/Dirname/Form-page.html'.
    But, when the form processing .php file is invoked the URL is
    'localhost/Dirname//Form-page-files/form.php'.
    It should be noted that in Dirname there is a directory named 'Form-page-files' as well as a file named 'Form-page.html'.
    The relevant form coding is:

    <FORM NAME="info" METHOD="POST" ACTION="form.php" onsubmit="return Validate()">
    <P>
    Last Name..........<INPUT NAME="Lastname" TYPE="TEXT" SIZE=30>
    <BR>
    First Name..........<INPUT NAME="Firstname" TYPE="TEXT" Size=30>
    <BR>
    Address..............<INPUT NAME="Address" TYPE="TEXT" SIZE=50>
    <BR>
    City....................<INPUT NAME="City" TYPE="TEXT" SIZE=30>
    <BR>
    State...................<INPUT NAME="State" TYPE="TEXT" SIZE=15>
    <BR>
    Email.................<INPUT NAME="Email" TYPE="TEXT" SIZE=50>
    <P><P><P>
    <CENTER>
    <INPUT TYPE="SUBMIT" VALUE="Submit">
    <INPUT TYPE="RESET" VALUE="Reset">
    </CENTER>
    <p><p><p><p>
    </FORM>

    Why are there two /'s after the Dirname and why is the directory name in the URL before the .php file name instead just the .php file name after localhost.

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: ubuntu 18.04 as webserver question

    Sounds like you need to post links to the config files to get help here. First, the guys will need to know which if 20 different web servers you might be using.

    Probably don't want to be using localhost either. Use the real hostname, so it works correctly from other systems on the LAN. If the first web server says localhost and you use another desktop, it will look on that desktop for the flies. Probably not what you want.

    Double slashes don't matter in URLs, BTW.

  3. #3
    Join Date
    Apr 2019
    Beans
    42

    Re: ubuntu 18.04 as webserver question

    I am using a LAMP stack consisting of apache2, mysql & php7.2.
    The Postfix config file is:
    # See /usr/share/postfix/main.cf.dist for a commented, more complete version


    # Debian specific: Specifying a file name will cause the first
    # line of that file to be used as the name. The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname

    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    biff = no

    # appending .domain is the MUA's job.
    append_dot_mydomain = no

    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h

    readme_directory = no

    # See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
    # fresh installs.
    compatibility_level = 2

    # TLS parameters
    smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    smtpd_use_tls=yes
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.

    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    myhostname = dv7
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    mydestination = dv7.com, sigmadeltapi.club, dv7, localhost.localdomain, localhost
    relayhost =
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all
    home_mailbox = Maildir/
    virtual_alias_maps = hash:/etc/postfix/virtual

    What other config files would be needed?

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: ubuntu 18.04 as webserver question

    I'm confused. What does postfix have to do with any web server?

    I can't help with php or apache or mysql. Sorry. We don't use those.

  5. #5
    Join Date
    Apr 2019
    Beans
    42

    Re: ubuntu 18.04 as webserver question

    I guess I haven't conveyed enough things to make sense of what I am looking for.
    The webserver's php software is supposed to interface with Postfix to mail a filled out form to an email address.
    the webserver processing gets as far as filling out the form and is attempting to invoke the .php coded file to mail the information, interfacing with the OS mail software - Postfix. It never gets that far because the URL to the .php file is not correct. The Postfix file has nothing to do with anything at this point. SO, what configuration files would TheFu suggest are needed?

  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: ubuntu 18.04 as webserver question

    Quote Originally Posted by TheFu View Post
    I can't help with php or apache or mysql. Sorry. We don't use those.
    All system-level config files are in /etc/ by default, unless you've put them somewhere else. Each will need to be configured for your specific needs. The Ubuntu Server Guide has instructions for trivial setups. Google will find it easily. We stopped using apache and mysql about a decade ago and never used php. In general, there is a config file for the DBMS and 1 config file for each of the web-server virtual hosts which needs to be setup. Probably in /etc/apache*/sites-enabled/ the name has a specific required nomenclature, I think. The web-server we use works differently, has different settings, different config files, but basically works in a similar layout. apache.org probably has detailed guides and information about any specific settings.

    If you need specific help with apache or mysql, someone else will need to jump in.

    As for interfacing with any MTA like postfix, it is a network interface on port 25/tcp, just like every other SMTP server in the world. If you can telnet to port 25 and send an email that way, then postfix is working as expected. The issue is on the SMTP-client side. SMTP is a bonehead network protocol without any authentication and little validation. There are lots of examples found via google for using telnet to test any MTA.

  7. #7
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: ubuntu 18.04 as webserver question

    The relevant page is the one that invokes form.php, which appears to be Form-page.html. We need to see more code than just the form. For instance, is there a "BASE HREF" specified in Form-page.html? The form you show uses just "form.php" so it's relative to the current URL unless that URL is redirected somehow.

    Your problem has nothing to do with Postfix. The URL generated to which the form POSTs is simply wrong. You could try to correct that, or you could copy form.php into the Dirname directory.

    There are a number of ways to get the wrong number of slashes in a directory reference. As TheFu says, they are ignored. Same holds true for directories in Linux as well.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  8. #8
    Join Date
    Aug 2017
    Beans
    178

    Re: ubuntu 18.04 as webserver question

    Let's start from scratch. I **believe** you possibly have something awkward in your httpd.conf or an .htaccess or something doing a redirect. Don't worry about postfix or mail right now, PHP has its own internal mail mechanism but it depends entirely on the contents of form.php - that is your first task, get the form submit to hit form.php.

    Whenever I hear the word "publish" it opens a whole can of worms - there is no telling what your publish software is doing in the background, which **may** explain how you're getting from "form.php" to '/Dirname//Form-page-files/form.php'. So if you can, open a file browser and look at the directory Dirname.

    On that topic, be Very. Careful. with U & LC. Home.html and home.html are two separate files.

    So we should be here
    localhost/Dirname/Form-page.html
    Which in your file structure is actually here

    Code:
    /var/www/html/Dirname/Form-page.html
    Is that correct? And your form HTML contains a method of post with a relative url - since there is no path specified, that would mean it is posting to /var/www/html/Dirname/form.php

    Code:
    <FORM NAME="info" METHOD="POST" ACTION="form.php" onsubmit="return Validate()"> 


    (BTW although it's irrelevant, the name attribute is only used to capture elements server-side, use ID for DOM manipulation.)

    And yet when you submit, it is redirecting to
    Code:
    localhost/Dirname//Form-page-files/form.php
    Something is redirecting, and I would venture to guess a missing element or undefined variable is the cause of the double slash. So the first thing is, in your file browser show hidden files. .htaccess files are hidden by default.



    Edit: None of my images ever load on this forum and it totally sucks. The above is a capture of where to tell the file browser to show hidden files. It should be the hamburger icon in the upper right of the file browser.

    Do you see any .htaccess files? If yes, open them in a plain text editor and post the contents here, or prepend any lines that appear to be executing a redirect with a pound sign, like

    Code:
    # this line is now commented out and will do nothing
    If not there, the configs files they are referring to in the above posts are Apache server config files. I'm not going down that road right now because it's more complex and I don't think there is anything in the server config causing this, I believe it's your publishing software.

    No .htaccess files? See if you can force the form post to do what you tell it to! Given that you have this directory structure,

    Code:
    /var/www/html/Dirname/Form-page.html
    /var/www/html/Dirname/form.php
    Per your form code above, What you have is a relative link : action='form.php' The POST **should** post in the same directory "Dirname" but for whatever reason it is not. It is always recommended to specifically post links that begin at the document root - in your case that appears to be /var/www/html. From a web page, that is simply '/'. So try this:

    Code:
    <FORM NAME="info" METHOD="POST" ACTION="/Dirname/form.php"> 
    That may not work as there may be some redirect mechanism capturing requests to the Dirname directory, but it's one thing to eliminate.

    You will notice I have also removed the return Validate(). Although in most cases a validation routine simply validates the form and says "okay, go ahead and submit" or stops the submit if there are errors. It is entirely possible that this Validate() may also be responsible for the redirect (I've seen much worse. )

    So let's nail down those two things before proceeding. We've covered two specific possibilities, a redirect cause by the "publish" software and Javascript mucking about with where it's actually posting to.
    Last edited by sdsurfer; January 27th, 2020 at 04:59 PM. Reason: too many typos

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •