• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

WordPress host IP changed not able to open wp-admin and site page looks scattered

June 6, 2013 by Sharad Chhetri 4 Comments

WordPress host IP changed not able to open wp-admin and site page looks scattered

Today I was working on my Virtual Machine in my laptop and was trying to check some theme options.In Virtual Machine I have set ip address to be taken dynamically from DHCP server.Today my wifi change the ip address of Virtual machine and all of sudden the demo wordpress site in VM (Virtual Machine) was not working .
In below screenshot it is showing how the page is scattered . I was not able to login in wp-admin after this.

wordpress4

OK I will put some detail which make the scenario more clear.

Previous Virtual Machine IP = 10.10.0.6
Current Virtual Machine IP = 10.10.0.8

How to Solve this problem

Okay I will give some roadmap of what we are going to do.

  • We will change the hostname of Virtual Machine which is in my Virtual Box, eg. ubuntu.example.com
  • I will update the wp_options table in wordpress database in Virtual Machine from where my wordpress is running
  • In my laptop I will make entry of hostname of my Virtual Machine in /etc/hosts file.So that whenever the ip will change I only have to update my /etc/hosts file with new IP
  • Lets start now.

    Step 1: I login into Virtual Machine , New IP Address is 10.10.0.8 (from DHCP) ,Wordpress database name is wordpress also.Going to change Hostname of Virtual machine which is Ubuntu 12.04 LTS.

    I edited the line and gave the value like this “127.0.1.1 ubuntu.example.com ubuntu” . See in below code viewer.

    sudo vi /etc/hosts
    127.0.0.1	localhost
    127.0.1.1       ubuntu.example.com ubuntu
    
    # 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
     

    Now edited the /etc/hostname file and gave hostname “ubuntu”

    sudo vi /etc/hostname 
    ubuntu

    Restart the service called hostname so that hostname of Virtual Machine will take effect.

    sudo service hostname restart
    

    Now check if hostname of Virtual machine is set or not.

    `hostname` command is only to see host name
    `hostname -f` is to see FQDN (Fully Qualified Domain Name)

    linux@ubuntu:~$ hostname
    ubuntu
    linux@ubuntu:~$ hostname -f
    ubuntu.example.com
    linux@ubuntu:~$

    Step 2: Now updating the mysql

    Here,

    Database Name: wordpress
    Note: Replace the value of ubuntu.example.com/wordpress with your wordpress link.

    mysql -u root -p
    
    mysql> use wordpress
    
    mysql> Select * from wp_options where option_id = 1 OR option_id = 39;
    
    mysql> update wp_options set option_value='http://ubuntu.example.com/wordpress' where option_id = 1;
    
    mysql>

    exit

    Step 3:

    Because example.com we generally use for testing. To open the wordpress demo site ubuntu.example.com I edited the file /etc/hosts and added the new line with new assigned DHCP ip correspond to ubuntu.example.com

    vi /etc/hosts
    127.0.0.1	localhost		
    10.10.0.8       ubuntu.example.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
    
     

    Now whenever the ip address of machine was changing I was only updating my laptop /etc/hosts file.

    Now I opened the URL from my laptop http://ubuntu.example.com/wordpress
    Done.

    wordpress-final

    Share this:

    • Twitter
    • Facebook
    • More
    • Print
    • Email
    • LinkedIn
    • Reddit
    • Tumblr
    • Pinterest
    • Pocket
    • Telegram
    • WhatsApp
    • Mastodon

    Related posts:

    1. SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
    2. Setup varnish cache server for wordpress site
    3. Setup htpasswd on WordPress wp-admin running on nginx
    4. master admin password openerp 7.x
    5. How to put slider shortcode only in home page in WordPress
    6. Root Is Not Able To Login In Red Hat And CentOS
    7. The best Linux and Open Source Magazine from India
    8. hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
    9. Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!
    10. VirtualBox Error: Failed to open/create the internal network

    Filed Under: Linux, Tips And Tricks Tagged With: wordpress

    Reader Interactions

    Comments

    1. Filip says

      August 12, 2017 at 8:44 pm

      Thanks!! it works

      Reply
    2. Zeeshan says

      December 17, 2016 at 11:33 am

      Hello Sharad,

      First of all it was a nice and pretty helpful article. Secondly, i am new to linux, mysql, wordpress and webhosting, it would be nice of you if you could suggest me a book which will help me learn promptly all the above

      Reply
    3. alex says

      April 25, 2015 at 1:53 pm

      Thanks for the tutorial , was searching for something like this for a few hours now….. i purged wordpress installation deleted everything….except for the database that i created for the previous installation .

      Don’t know a lot of sql queries so i went in phpmyadmin and edited the table wp_option -> line siteurl

      Good thing i was accesing my wordpress site from mozilla that was showing me that it tried to access the old ip 192.168.1.65 instead of the new one 192.168.0.65

      Thanks again

      Alex

      Reply
      • sharad chhetri says

        April 25, 2015 at 2:26 pm

        Thankyou Alex,

        Your comment give me some confidence that this issue could be common for many readers.
        Happy to see your positive feedback, which is definitely a helpful one for our blog readers.

        Regards
        Sharad

        Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Primary Sidebar

    Our Social Media Presence

    • Facebook
    • GitHub
    • Twitter

    Linux Command

    What is Linux Internal And External Command

    Linux Basic Commands With Examples For Every Beginner

    tr command to convert lines to space , tab and vertical tab

    smbpasswd command not found on CentOS 7 and RHEL 7

    Solution : semanage command not found

    Unix / Linux : How to print duplicate lines from file

    More Posts from this Category

    You Might Like These Articles!

    simplecodesyntax wordpress plugin

    SimpleCodeSyntax : My Another WordPress Plugin

    Install Nginx

    How To Install Nginx On Ubuntu 22.04 LTS

    Install Latest Git package in Ubuntu Operating System

    How To Always Install Latest Git Package In Ubuntu Operating System

    Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

    Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

    libfuse

    dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

    Failed to open/create the internal network

    VirtualBox Error: Failed to open/create the internal network

    Always Useful Tips And Tricks

    send email after mysql backup through bash script in simple way

    How to change login banner message in GUI mode in CentOS 6 or above version.

    How to configure ethernet in CentOS 6 after installing in Virtual Box

    Keep logs of user after sudo su – : Secondary Logging

    How to convert rpm file into deb file

    How to backup and restore iptables on Linux systems

    curl command to check the http status

    Explore 90+ Article On "Linux Tips And Tricks"

    Copyright © 2023 ยท
    The material in this site cannot be republished either online or offline, without our permission.
    Proudly Blogging From Bharat.

    • Contact
    • About Me
    • My WordPress plugins
    • Privacy Policy