elearn
By:
elearn

Why can't change nginx port from 8080 into 80 for the wordpress?

September 18, 2015 7.4k views
Nginx

The wordpress is been built on nginx ,the port is 8080 ,it can be visited at the form of
http://127.0.0.1:8080/wp/?p=4.

In my wordpress database:

select guid  from wp_posts limit 2 ;
+-------------------------------+
| guid                          |
+-------------------------------+
| http://127.0.0.1:8080/wp/?p=4 |
| http://127.0.0.1:8080/wp/?p=8 |
+-------------------------------+

Now i want to change the port of nginx from 8080 into 80.

1.edit /etc/nginx/nginx.conf
from

server {
    listen 8080;
    server_name localhost;

#irrelated  content omitted 

into

server {
    listen 80;
    server_name localhost;

2.edit /var/www/html/wp/wp-config.php

from

define('WP_SITEURL','http://localhost:8080/wp/');
define('WP_HOME','http://localhost:8080/wp/');

into

define('WP_SITEURL','http://localhost:80/wp/');
define('WP_HOME','http://localhost:80/wp/');

3.login into my wordpress database to execute the sql commands.

UPDATE wp_posts SET post_content = replace(post_content, 'http://127.0.0.1:8080/wp', 'http://127.0.0.1/wp'); 
UPDATE wp_options SET option_value = replace(option_value, 'http://127.0.0.1:8080/wp', 'http://127.0.0.1/wp'); 
UPDATE wp_posts SET guid = replace(guid, 'http://127.0.0.1:8080/wp', 'http://127.0.0.1/wp'); 
UPDATE wp_posts SET pinged = replace(pinged, 'http://127.0.0.1:8080/wp', 'http://127.0.0.1/wp'); 
update wp_options set option_value='http://localhost:80' where option_name='siteurl';
update wp_options set option_value='http://localhost:80' where option_name='home';

Now restart ngix.

service nginx restart

when i input http://127.0.0.1:80/wp/?p=4 in the browser.
http://i.stack.imgur.com/buZrc.png

Where the problem appear?

1 Answer

I would suggest looking your error logs to see the problem, also if your site is running on port 80 you do not need to put :80 to access your site, it will default to 80.

Have another answer? Share your knowledge.