Thursday, January 10, 2013

Wordpress stopped working after changing Apache server's port number

My Wordpress stopped working after I changed Apache server's port number.

My Apache server was using its default port number 80. But I had to change it to something else (8000) because I wanted to use the port for Nginx server. After the change, I found my Wordpress no longer working even when I specified the new port like "http://localhost:8000/wp".

I found that what I was supposed to do was to change URL settings in Wordpress configuration before actually changing the Apache server's port.

It is probably easiest to fix the problem if I change the port back to the default 80 temporarily and use Wordpress admin page to change its URL settings.

1. Resources

"Wordpress wont load after changing ports"
"Changing Apache port number"


2. Change Apache Server port back to default 80, temporarily

Stop Nginx server, which is using the port 80.

 $ sudo /etc/init.d/nginx stop

Change Apache server port back to 80, temporarily.
Open ports.conf file.

 $ sudo gedit /etc/apache2/ports.conf

Change

 NameVirtualHost *:8000
 Listen 8000

to


 NameVirtualHost *:80
 Listen 80

Next, to change virtual host's port, edit the file 000-default.


$ sudo gedit /etc/apache2/sites-enabled/000-default

Change


 <VirtualHost *:8000>

to


 <VirtualHost *:80>



Then restart the Apache server.

 $ sudo /etc/init.d/apache2 restart

3. Change URL settings in Wordpress admin window 

Logon to the Wordpress as Administrator.
Goto Settings on the side bar and select General.
And change:

WordPress Address (URL): http://localhost/wp
Site Address (URL): http://localhost/wp

to


WordPress Address (URL): http://localhost:8000/wp
Site Address (URL): http://localhost:8000/wp



4. Now Undo the Temporary Change made above (2)


Change the ports.conf back to


 NameVirtualHost *:8000
 Listen 8000



and change the 000-default back to

 <VirtualHost *:8000>


5. Restart Servers

$ sudo /etc/init.d/apache2 restart
$ sudo /etc/init.d/nginx start