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.
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.
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
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>
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