Support » Localhost Installs » Fresh Linux Mint 19.2 Install

  • Brand new fresh install onto Linux Mint 19.1, with a fresh LAMP. All went well. Then, when trying to browse from anywhere, it immediately redirects to ‘http://127.0.0.1/wordpress… then the error ‘This site can’t be reached…127.0.0.1 refused to connect’.

    I’ve tried a gazillion of ‘solutions’ to this found online, including:
    – Disable plugins
    – Browser history (happens across the web..multiple machines)
    – Removing .htaccess
    – Modifications to wp-config.php

    DEETS:—-
    wp-config.php:
    <?php^M
    /**^M
    * The base configuration for WordPress^M
    *^M
    * The wp-config.php creation script uses this file during the^M
    * installation. You don’t have to use the web site, you can^M
    * copy this file to ‘wp-config.php’ and fill in the values.^M
    *^M
    * This file contains the following configurations:^M
    *^M
    * * MySQL settings^M
    * * Secret keys^M
    * * Database table prefix^M
    * * ABSPATH^M
    *^M
    * @link https://wordpress.org/support/article/editing-wp-config-php/^M
    *^M
    * @package WordPress^M
    */^M
    ^M
    // ** MySQL settings – You can get this info from your web host ** //^M
    /** The name of the database for WordPress */^M
    define( ‘DB_NAME’, ‘wordpress’ );^M
    ^M
    /** MySQL database username */^M
    define( ‘DB_USER’, ‘wpuser’ );^M
    ^M
    /** MySQL database password */^M
    define( ‘DB_PASSWORD’, ‘space’ );^M
    ^M
    /** MySQL hostname */^M
    define( ‘DB_HOST’, ‘localhost’ );^M
    ^M
    /** Database Charset to use in creating database tables. */^M
    define( ‘DB_CHARSET’, ‘utf8’ );^M
    ^M
    /** The Database Collate type. Don’t change this if in doubt. */^M
    ‘wp-config.php’ [readonly] 90 lines, 2889 characters
    ——————————————
    .htaccess:

    # BEGIN WordPress
    # The directives (lines) between ‘BEGIN WordPress’ and ‘END WordPress’ are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.

    RewriteEngine On
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /wordpress/
    RewriteRule ^index.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]

    # END WordPress

    apache2.conf:
    # This is the main Apache server configuration file. It contains the
    # configuration directives that give the server its instructions.
    # See http://httpd.apache.org/docs/2.4/ for detailed information about
    # the directives and /usr/share/doc/apache2/README.Debian about Debian specific
    # hints.
    #
    #
    # Summary of how the Apache 2 configuration works in Debian:
    # The Apache 2 web server configuration in Debian is quite different to
    # upstream’s suggested way to configure the web server. This is because Debian’s
    # default Apache2 installation attempts to make adding and removing modules,
    # virtual hosts, and extra configuration directives as flexible as possible, in
    # order to make automating the changes and administering the server as easy as
    # possible.

    # It is split into several files forming the configuration hierarchy outlined
    # below, all located in the /etc/apache2/ directory:
    #
    # /etc/apache2/
    # |– apache2.conf
    # | `– ports.conf
    # |– mods-enabled
    # | |– *.load
    # | `– *.conf
    # |– conf-enabled
    # | `– *.conf
    # `– sites-enabled
    # `– *.conf
    #
    #
    # * apache2.conf is the main configuration file (this file). It puts the pieces
    # together by including all remaining configuration files when starting up the
    # web server.
    #
    # * ports.conf is always included from the main configuration file. It is
    # supposed to determine listening ports for incoming connections which can be
    # customized anytime.
    ‘apache2.conf’ 227 lines, 7253 characters
    # viewed by Web clients.
    #

    Require all denied

    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive.
    #
    # These deviate from the Common Log Format definitions in that they use %O
    # (the actual bytes sent including headers) instead of %b (the size of the
    # requested file), because the latter makes it impossible to detect partial
    # requests.
    #
    # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
    # Use mod_remoteip instead.
    #
    LogFormat ‘%v:%p %h %l %u %t ‘%r’ %>s %O ‘%{Referer}i’ ‘%{User-Agent}i” vhost_combined
    LogFormat ‘%h %l %u %t ‘%r’ %>s %O ‘%{Referer}i’ ‘%{User-Agent}i” combined
    LogFormat ‘%h %l %u %t ‘%r’ %>s %O’ common
    LogFormat ‘%{Referer}i -> %U’ referer
    LogFormat ‘%{User-agent}i’ agent

    # Include of directories ignores editors’ and dpkg’s backup files,
    # see README.Debian for details.

    # Include generic snippets of statements
    IncludeOptional conf-enabled/*.conf

    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf
    ServerName fredcolclough.com
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

    Apr 28, 2021 12:10 am#3670858REPLY

    oxynite
    Member
    Well…I sort of found the “answer/solution”:

    found the reference in /sites-available/wp-config.php:

    DocumentRoot = /var/www/html

    I CHANGED IT to point to the wordpress folder below it:

    DocumentRoot = /var/www/html/wordpress

    BUT>….. now the site is all messed up!!!!!! IT’s full of broken stuff…. try it:
    http://fredcolclough.com

    I’m wondering if I need to actually move all the wordpress files into the /var/www/html root folder. ?? (Then maybe change DocumentRoot back??)

    Thanks!
    -Oxy.
    ——–
    MORE:

    Well…I sort of found the “answer/solution”:
    
    found the reference in /sites-available/wp-config.php:
    
    DocumentRoot = /var/www/html
    
    I CHANGED IT to point to the wordpress folder below it:
    
    DocumentRoot = /var/www/html/wordpress
    
    BUT>….. now the site is all messed up!!!!!! IT’s full of broken stuff…. try it:
    http://fredcolclough.com
    
    I’m wondering if I need to actually move all the wordpress files into the /var/www/html root folder. ?? (Then maybe change DocumentRoot back??)
    
    Thanks!
    -Oxy.

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter oxynite

    (@oxynite)

    Sorry for the multiple posts…not sure you can see the forest thru the trees w/ all that config data.

    Bottom-iine here: http://localhost on linux box,
    Without changing DocumentRoot (stay at/var/www/html vs /var/www/html/worldpress
    —> localhost LOADS NOTHING
    —> localhost/wordpress DOES WORK WITH PERFECT FORMATTING!
    —> all external browsers do a redirect to 127.0.0.1 and get ‘cannot connect’

    So I try changing DocumentRoot to /var/www/html/wordpress
    —> YES: localhost now loads (with no subdir), BUT IT’s MISSING FORMATTING!

    So…trying to get both back! Needs to load full site at default dir, AND not have the 127.0.0.1 redirect)

    Thoughts?

    Thanks.
    –Oxy.

    It seems you run the WordPress installer with the URL http://127.0.0.1/wordpress/, which is now stored in the database. And this URL, of course, won’t resolve anywhere other than the localhost.

    Please follow the support article below to change your WordPress site address stored in the database to your actual domain.

    Changing The Site URL

    Thread Starter oxynite

    (@oxynite)

    Thanks for the quick reply!

    So I tried Option 1 Fix per the article you sent, which is:
    ———-
    Edit wp-config.php
    It is possible to set the site URL manually in the wp-config.php file.

    Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.

    define( ‘WP_HOME’, ‘http://fredcolclough.com&#8217; );
    define( ‘WP_SITEURL’, ‘http://fredcolclough.com&#8217; );`
    ———-
    and it FIXED the redirect, but NOT the broken site! See http://fredcolclough.com to see.

    Thanks
    -Oxy.

    Thanks for the update.

    But evidently you didn’t read the full article, especially the Additional items of note part.

    I’ll highly recommend you read the full page, as the solution to your problem is there 😀 (tl;dr: the old address is all over the place, and you need to run a “search and replace” on the database, and that’s in addition to changing the WordPress address.)

    Thread Starter oxynite

    (@oxynite)

    Hello George,

    Thanks so much for the assist here!

    Apologies, but I read the beginning, skimmed the rest, and understood it to mean any ‘one’ of the fixes would do the trick.

    I’ll go through it again and see if I can hit them all.

    -Oxy.

    To my eye it seems that the problem yet to be addressed is that the browser redirects ALL addresses to localhost.
    Suggest that you look at a core apache2 configuration file, probably a file with a location like:
    /etc/apache2/sites-enabled
    There will be various configuration blocks like for example:

    <VirtualHost *:80>
    DocumentRoot /var/www/wpB
    ServerName wpB.local
    ServerAlias www.wpB.local
    </VirtualHost>

    My guess is that an overly general block is directing all traffic to your WordPress server.

    • This reply was modified 1 week, 3 days ago by RossMitchell.
    Thread Starter oxynite

    (@oxynite)

    If I need to do ALL of those things, I’m better off installing wordpress again, but this time getting it to the root /var/www/html (vs /var/www/html/wordpress).

    Do you know where I went awry? I followed the “Installing WordPress on Linux Mint 19” on idroot.

    Thanks.
    -Oxy.

    Thread Starter oxynite

    (@oxynite)

    Ross: thanks. I checked for that & didn’t find anything.

    Having trouble with a new install: it keeps going to /wordpress, and I get the 127.0.0.1 redirect as well.

    I’ve been through that document again George and I’m reasonably sure I hit everything, but no change. Grrrrr. I must be missing something.

    -Oxy.

    Thread Starter oxynite

    (@oxynite)

    Now it’s worse than before… can’t get WordPress to come up at all, either at the root /localhost, nor at /localhost/wordpress

    I get this lovely error:
    There has been a critical error on this website.

    Learn more about troubleshooting WordPress.

    Thread Starter oxynite

    (@oxynite)

    completely killed wordpress on server… & reintalled…

    Now I’m back where I was:
    localhost still brings up UBUNTU test pg
    localhost ON SERVER opens site correctly

    Using IP or domain on external system: (fredcolclough.com) redirects to 127.0.0.1 and “refused to connect.”

    I’ve been through the “Changing the Site URL” document three times, each time with the same result. I’m simply using these steps to install wordpress:

    cd /var/www/html
    wget -c http://wordpress.org/latest.tar.gz
    tar -xzvf latest.tar.gz
    sudo rsync -av wordpress/* /var/www/html/
    sudo chown -R www-data:www-data /var/www/html/
    sudo chmod -R 755 /var/www/html/
    sudo mysql -u root -p
    mysql> CREATE DATABASE wordpress;
    mysql> GRANT ALL PRIVILEGES ON wordpress.* TO ‘your_username_here’@’wpuser’ IDENTIFIED BY ‘***’;
    mysql> FLUSH PRIVILEGES;
    mysql> EXIT;

    sudo mv wp-config-sample.php wp-config.php
    sudo vi wp-config.php
    **Set as:

    // ** MySQL settings - You can get this info from your web host ** //^M
    /** The name of the database for WordPress */^M
    define( 'DB_NAME', 'wordpress' );^M
    ^M
    /** MySQL database username */^M
    define( 'DB_USER', 'wpuser' );^M
    ^M
    /** MySQL database password */^M
    define( 'DB_PASSWORD', '**' );^M
    ^M
    /** MySQL hostname */^M
    define( 'DB_HOST', 'localhost' );^M


    That’s it. Simple. Thoughts? Thanks in advance!!

    -Oxy.

    Thread Starter oxynite

    (@oxynite)

    *******SOLUTION********

    So I figured it out:

    wp-config.php file:
    define( ‘DB_HOST’, ‘localhost’ );^M
    define( ‘WP_HOME’, ‘http://fredcolclough.com&#8217; );^M
    define( ‘WP_SITEURL’, ‘http://fredcolclough.com&#8217; );^M
    ^M

    Had to use the complete URL, not just “fc.com”.

    Same thing in the wp db:
    siteurl
    wp_home

    Crazy…I figured it was something simple. Thanks for the inputs Gents!

    -Oxy.

    define( ‘WP_HOME’, ‘http://fredcolclough.com/; );
    define( ‘WP_SITEURL’, ‘http://fredcolclough.com/; );

    Note that the WP_HOME and WP_SITEURL defined in the wp-config.php file override what’s defined in the database (and editable in SETTINGS => GENERAL in the dashboard).

    If you have the correct URLs in the database, you don’t need to add these lines in the configuration file as well. But after adding them here, the fields in SETTINGS => GENERAL will be greyed out and cannot be edited any longer.

    So after you’ve set up SSL/HTTPS for your site, remember to return to the config file to switch these two URLs to HTTPS.

    In fact, I’ll recommend you set up SSL/HTTPS now before proceeding any further. If you don’t do that now, all media files you upload will be using HTTP, and you’ll later need to run a search and replace query on your database again to change all URLs to use HTTPS.

    Thread Starter oxynite

    (@oxynite)

    Thanks for that additional info George! I’m working on it! 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.