• Resolved satimis

    (@satimis)


    Hi all

    Local server
    OS – Ubuntu 14.04 desktop 64bit
    LAMP is running

    On browser run – 192.168.0.xxx starting Apache2 default page.

    Please advise;
    1) Whether I need to install WordPress on local server.
    2) Which is the right document for me to follow?
    On googling I found many documents including;
    Moving WordPress
    https://codex.www.ads-software.com/Moving_WordPress

    Thanks

    Regards
    satimis

Viewing 15 replies - 1 through 15 (of 17 total)
  • Yes you need to install WordPress on your local server.
    I suggest that you install your site as a “VirtualHost” rather than using a localhost address.

    To setup your site as a virtualhost:

    * add local name lookups in /etc/hosts
    127.0.0.1 wpB.local

    * add VirtualHost directives in /etc/apache2/sites-enabled/001-local

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

    Start with the detailed instructions from here:
    https://codex.www.ads-software.com/Installing_WordPress

    Suggest that you use a plugin like DUPLICATOR and use the article you found “Moving WordPress”

    Thread Starter satimis

    (@satimis)

    Hi,

    Thanks for your advice and links.

    Please advise:

    1)
    regarding /etc/hosts
    if the local website is under /var/www/html/mywebsite
    then edit the line as;
    127.0.0.1 mywebsite.localhost ?

    What about 127.0.1.1 ?
    I’m now editing the line as;

    127.0.1.1 vm_name

    2)
    /etc/apache2/sites-enabled/001-local

    <VirtualHost *:80>
    DocumentRoot /var/www/html/mywebsite
    ServerName mywebsite.localhost
    </VirtualHost>
    ?

    I have experience cloning/copying live website to local server running on VM of Oracle Virtualbox. On VM browser evoking https://localhost/mywebsite it starts the local website without problem, working same as the live website.

    But on host browser evoking https://192.168.0.xxx/localhost/mywebsite unable to start the local website. I have tried hours and hours unable to figure out the problem. Can you help?

    Thanks in advance.

    Regards
    satimis

    I confirm that you want this in /etc/hosts
    127.0.0.1 mywebsite.localhost

    As for 127.0.1.1 there is an explanation here:
    https://www.linuxquestions.org/questions/linux-networking-3/what-does-127-0-1-1-mean-623421/
    In short some software wants to be able to resolve your computer’s hostname as an ip address. So the advice is “just leave it alone”.

    All of https://localhost/ https://127.0.0.1/ https://192.168.0.xxx/ resolve to “/var/www” which is not where your website lives. You could get there by adding “/html/mywebsite” but it is still a poor alias, the address you should use is the one in your “site address” and “website address” fields which should be “https://mywebsite.localhost&#8221; .

    So browse to: https://mywebsite.localhost/

    I routinely renovate websites by bring down their files and databases to my PC, and set their exact name into my hosts file, I also recreate the database name, user and password from the “wp-config.php” file, this way the website barely knows that it has moved, when I have fixed it the exact same files and database can be uploaded with zero changes.

    Thread Starter satimis

    (@satimis)

    Hi,

    Thanks for your advice in re the entry on /etc/hosts

    In respect of /var/www/html folder I just followed it on Godaddy server. My live websites are installed and running on their server residing on /var/www/html/domain_folder/ On local server I can create them under /var/www/domain_folder if it can resolve my problem mentioned on previous posting?

    Thanks

    Regards
    satimis

    No need to move the folder, just make the name match the one specified in the VirtualHost block.

    For instance I do my webdev work in a sub directory of my home folder, so if the client is “Gone Fishing” the directory name in the VirtualHost block is: “/home/ross/web/GoneFishing/wp”

    Thread Starter satimis

    (@satimis)

    Hi,

    Performed following test:-

    Live site on Godaddy – hymn.satimis.com (subdomain)
    Domain registered with and hosted on Godaddy

    Local server running Virtualbox
    Host – Ubuntu 14.04 desktop
    Bridge connection – router connected to static/fixed IP

    VM (local site) – Ubuntu 14.04 desktop, Lamp and WordPress running
    Local IP – 192.168.0.xxx

    VM Document root /var/www/html/hymn/
    $ ls /var/www/html/hymn/

    cgi-bin          wp-admin              wp-config-sample.php  wp-login.php
    error_log        wp-blog-header.php    wp-content            wp-mail.php
    index.php        wp-comments-post.php  wp-cron.php           wp-settings.php
    license.txt      wp-config.php         wp-includes           wp-signup.php
    style.css        wp-links-opml.php     wp-trackback.php	     wp-activate.php
    wp-load.php      xmlrpc.php

    $ cat /etc/hosts

    192.168.0.xxx   hymn.satimis.com
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

    On VM browser – https://192.168.0.xxx/hymn
    starts the local site of hymn.satimis.com which is similar to the live site running on Godaddy server

    On host – https://192.168.9.xxx/hymn
    also starts the local site but in complete disorder. I couldn’t resolve WHY? (unfortunately I can’t find a way to post the snapshot here)

    1) How can I fix this problem?
    2) If I make the subdomain on Godady server pointing at the static/fixed IP of the router what files shall I edit so that visitors can browse the website on local server?

    Please help. Thanks in advance.

    Regards
    satimis

    You have to choose which server runs your website as you develop it. It can run on godaddy OR it can run on your localhost. It can not run on both.

    If you want to run on godaddy:
    – remove or comment out (# prefix) the “hymn.satimis.com” line in your /etc/hosts
    – do NOT have your subdomain point to your router
    – edit the files at godaddy

    If you want to run on localhost:
    – change the line in /etc/hosts to:
    127.0.0.1 hymn.satimis.com
    – In your apache configuration have the document root line:
    DocumentRoot /var/www/html/hymn/
    – whenever you change the apache configuration run:
    sudo /etc/init.d/apache2 graceful
    – edit the files on your local computer
    – If you want to view the localhost website from other computers on your LAN, then to the hosts file on THAT computer add:
    192.168.0.xxx hymn.satimis.com

    The reason that the wrong address brings up a deranged site is that even though your browser can load the main web page, attempts to load images + css files + links to other pages all result in your browser sending the request to the wrong address.

    Thread Starter satimis

    (@satimis)

    Hi,

    I’m prepared performing 2 tests;

    1) to run on localhost
    and
    the localhost can be viewed by other computer on the LAN

    2) after the test 1) having been successfully completed I’ll make the subdomain on Godaddy point to the static/fixed IP of the router

    Steps performed
    1) /etc/hosts of local server (VM)
    127.0.0.1 hymn (hymn.satimis.com can’t work)
    127.0.1.1 computer_name

    On host (another computer)
    /etc/hosts
    192.168.0.xxx hymn

    On VM browser running – https://192.168.0.xxx/hymn
    The website can be browsed without problem.

    On host (another computer)
    on browser running – https://192.168.0.xxx/hymn
    still a deranged site is displayed.

    2)
    I’ll make the subdomain on Godaddy point to the static IP of the router.

    What other steps I have to perform on the local server?

    Do I need forwarding port 80 to 192.168.0.xxx on router?

    Thanks

    satimis

    1127.0.0.1 hymn (hymn.satimis.com can't work)

    Why do you think that it can’t work ?
    I do this all the time.
    Do you know of an RFC specification ?

    This is the first you have mentioned a VM browser. Where is it running, how is its network configured ?

    With regard to “2)”
    If you really want to have the world accessing your localhost server, then you must set the router to port forward.

    What is crucial is that your WordPress settings for “Site Address” and “WordPress address” MUST enable the browser to fetch files from your server.

    Thread Starter satimis

    (@satimis)

    I created this local site >1 year ago. It was cloned on the live site, hymn.satimis.com

    I performed following steps creating this local site;

    1) Download the database hymn.sql file from Godaddy to Download folder

    2) Created database hymn
    grant all on hymn.* to ‘wordpress’@’localhost’ identified by ‘db_passwd’;

    3) On terminal ran;
    $ mysql -uroot -p hymn < Downloads/hymn.sql

    4) Download ~/hymn/* from Godaddy to /var/www/html/hymn/ (VM)

    5) Edited /var/www/html/hymn/wp-config.php
    change;
    define(‘DB_USER’, ‘hymn’);
    to;
    define(‘DB_USER’, ‘wordpress’);

    change;
    define(‘DB_PASSWORD’, ‘old_db_passwd’);
    to;
    define(‘DB_PASSWORD’, ‘db_passwd’);

    Change:
    define(‘WP_HOME’,’https://hymn.satimis.com&#8217;);
    define(‘WP_SITEURL’,’https://hymn.satimis.com&#8217;);
    To:
    define(‘WP_HOME’,’https://localhost/hymn&#8217;);
    define(‘WP_SITEURL’,’https://localhost/hymn&#8217;);

    6)
    -> Permalinks
    (check) Default

    On VM browser run;
    ‘localhost/hymn’
    starts the local site of hymn.satimis.com

    Now I wonder how to change ‘localhost/hymn’ back to ‘192.168.0.xxx/hymn.satimis.com’ to browse the local site.

    Performed following steps without result;

    1)on wp-config.php
    Change:
    define(‘WP_HOME’,’https://localhost/hymn&#8217;);
    define(‘WP_SITEURL’,’https://localhost/hymn&#8217;);

    Back To:
    define(‘WP_HOME’,’https://hymn.satimis.com&#8217;);
    define(‘WP_SITEURL’,’https://hymn.satimis.com&#8217;);

    2) on /etc/hosts add;
    192.168.0.xxx hymn.satimis.com

    3) on hymn database;
    grant all on hymn.* to ‘wordpress’@’hymn.satimis.com’ identified by ‘db_passwd’;

    On VM browser run;
    https://192.168.0.xxx/hymn.satimis.com
    Not Found
    The requested URL /hymn.satimis.com was not found on this server.
    Apache/2.4.7 (Ubuntu) Server at 192.168.0.xxx Port 80

    https://192.168.0.xxx/
    starts
    Apache2 Ubuntu Default Page

    Also https://hymn.satimis.com
    starts
    Apache2 Ubuntu Default Page

    NOT the live site

    Any suggestion? Thanks

    satimis

    Steps 1,2,3,4 all ok
    5)
    in wp-config.php change DB_USER and DB_PASSWORD – ok
    NB: YOu also have to have the database name set correctly.
    BUT, DO NOT change WP_HOME or WP_SITEURL, these names are put into the page sent to the browser, the browser uses them to fetch support files like css and images etc. The browser uses these names to find and talk to the webserver. The network uses the list in “/etc/hosts” and failing it the DNS mechanism to translate names into network addresses.

    6) It is not sufficient to just have the correct setting, you need to click the SAVE button so that the “.htaccess” file actually gets written.

    AND now you start talking about “VM browser” what is it ? Which machine is it running on ? What is in the “/etc/hosts” file on that computer. This is a serious question, I have asked this question before. If you cannot answer this question, then I cannot help you.

    NOW YOU START at 1) again !!!
    1) The correct settings are:

    define('WP_HOME','https://hymn.satimis.com');
    define('WP_SITEURL','https://hymn.satimis.com');

    2) on /etc/hosts add on the computer hosting the webserver;
    127.0.0.1 hymn.satimis.com
    on the other machine on the LAN (even the VM)
    192.168.0.xxx hymn.satimis.com

    3) grant ….
    Not required, the apache server will be using a localhost connection to the mySQL server.

    Any suggestion?

    * ANSWER the question about the mystery VM browser ????
    (If you do not answer this question I will not be responding to you ever.)

    * What are the settings in the apache2 “virtual host” configuration ?
    Whenever you change the apache2 config you need to restart the apache2 service:
    sudo /etc/init.d/apache2 graceful

    Thread Starter satimis

    (@satimis)

    Hi,

    Thanks for your advice.

    BUT, DO NOT change WP_HOME or WP_SITEURL, these names are put into the page sent to the browser …

    OK, I’ll change them back to their origianl settings.

    AND now you start talking about “VM browser” what is it ? Which machine is it running on ?

    Sorry. I meant the local server running on a VM

    On local server;

    cat /etc/hosts
    127.0.0.1       hymn.satimis.com
    127.0.1.1       computer_name
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

    I can’t post the whole file /etc/apache2/apache2.conf here.

    $ cat /etc/apache2/apache2.conf

    PidFile ${APACHE_PID_FILE}
    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 5
    
    # These need to be set in /etc/apache2/envvars
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    
    HostnameLookups Off
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    
    # Include module configuration:
    IncludeOptional mods-enabled/*.load
    IncludeOptional mods-enabled/*.conf
    
    # Include list of ports to listen on
    Include ports.conf
    
    # access here, or in any related virtual host.
    <Directory />
    	Options FollowSymLinks
    	AllowOverride None
    	Require all denied
    </Directory>
    
    <Directory /usr/share>
    	AllowOverride None
    	Require all granted
    </Directory>
    
    <Directory /var/www/>
    	Options Indexes FollowSymLinks
    	AllowOverride None
    	Require all granted
    </Directory>
    
    AllowOverride
    
    AccessFileName .htaccess
    
    <FilesMatch "^\.ht">
    	Require all denied
    </FilesMatch>
    
    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 generic snippets of statements
    IncludeOptional conf-enabled/*.conf
    
    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf

    ? sudo /etc/init.d/apache2 status
    * apache2 is running

    Other advice noted. Thanks

    satimis

    Thanks for posting the “conf” file. Crucial lines are:

    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf

    In this directory you want to add a file “001-local.conf” with a block like this:

    <VirtualHost *:80>
    DocumentRoot /var/www/html/hymn
    ServerName hymn.satimis.com
    </VirtualHost>

    Thread Starter satimis

    (@satimis)

    ? sudo find / -name sites-enabled
    /etc/apache2/sites-enabled

    ? ls /etc/apache2/sites-enabled/
    000-default.conf

    ? cat /etc/apache2/sites-enabled/000-default.conf

    <VirtualHost *:80>
    ......
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    .....
    </VirtualHost>

    ? sudo gedit /etc/apache2/sites-enabled/001-local.conf
    add following lines on the file;

    <VirtualHost *:80>
    DocumentRoot /var/www/html/hymn
    ServerName hymn.satimis.com
    </VirtualHost>

    ? sudo service apache2 restart

    * Restarting web server apache2
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
       ...done.

    ? sudo gedit /etc/apache2/apache2.conf
    Add following line at the bottom of the file;
    ServerName localhost

    ? sudo service apache2 restart

    * Restarting web server apache2
       ...done.

    https://192.168.0.xxx/hymn.satimis.com
    Not Found

    https://hymn.satimis.com/
    starts Apache2 default page

    https://localhost/hymn
    it starts its website on local server

    Edit
    ====
    ? ls /var/www/html/
    bible hymn index.html wordpress

    Should I rename /hymn as /hymn.satimis.com ?

    “bible” is another website running on this local server

    https://192.168.0.xxx/wordpress
    start WordPress default page for creating new website

    satimis

    Thread Starter satimis

    (@satimis)

    Hi Ross

    Your steps work here.

    I was confused by the live and locate sites because they are identical. Finally I edited the local site adding “local site” on “Visit Us/Contact Us” page respectively.

    After making the subdomains;
    hymn.satimis.com
    bible.satimis.com

    pointing to the Static IP of the router now the local sites are working and can be accessed on Internet.

    Port 80 is forwarded to 192.168.0.xxx

    For bible.satimis.com
    I added another file /etc/apache2/sites-enabled/002-local.conf

    <VirtualHost *:80>
    DocumentRoot /var/www/html/bible
    ServerName bible.satimis.com
    </VirtualHost>

    For multiple sites whether I need to create several files such as;
    003-local.conf
    004-local.conf
    005-local.conf
    etc.

    for each website? Or I can add all contents in ONE file, say “001-local.conf”?

    My next exploration will be to configure Godaddy server so that when the local server is UP visitors will browse the websites on local server. When the local server is DOWN visitor will browse the websites on Godaddy server. My subscribing plan is provided with this feature. I’ll contact Godaddy Support later.

    Lot of thanks for your advice and time spent.

    Regards
    satimis

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘How to move live WP site on Godaddy to local server’ is closed to new replies.