elearn
By:
elearn

How to change port 80 into 8080 on my wordpress?

September 4, 2015 27.8k views
Nginx WordPress

I have installed LEMP +wordpress on my 127.0.0.1/wp.
Now i want to make 80 into 8080,let 127.0.0.1:8080/wp can be visited.

  1. edit nginx configuration
    server {
    listen 8080;
    servername 127.0.0.1;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    location / {
    try
    files $uri $uri/ =404;
    }
    errorpage 404 /404.html;
    error
    page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /var/www/html;
    }
    location ~ .php$ {
    tryfiles $uri =404;
    fastcgi
    pass unix:/var/run/php5-fpm.sock;
    fastcgiindex index.php;
    fastcgi
    param SCRIPTFILENAME $documentroot$fastcgiscriptname;
    include fastcgi_params;
    }
    }

  2. edit wordpress configuration.
    vim /var/www/html/wp/wp-config.php

    to add tow lines at the end of the file.

    define('WPSITEURL','http://localhost:8080/wp/');
    define('WP
    HOME','http://localhost:8080/wp/');

3.change the mysql
update wpoptions set optionvalue='http://localhost:8080' where option_name='siteurl';

update wpoptions set optionvalue='http://localhost:8080' where option_name='home';

Why htpp://127.0.0.1:8080/wp can get nothing ?

1 comment
3 Answers

Perhaps a stupid question, but you did restart Nginx after you've made the changes?
Is the main nginx.conf also listening at 8080?

@Martijns Indeed did you restart nginx? Also a simple one; are you running any firewall / did you portforward the port?

No firewall ,nothing.

I met a big trouble!I try to set nginx configuration to test and test, install and uninstall many times.
My os messed up.
root@pengsir:/home/debian8# dpkg -l nginx
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii nginx 1.6.2-5 all small, powerful, scalable web/pro
root@pengsir:/home/debian8# service nginx start
root@pengsir:/home/debian8# service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: active (running) since Sun 2015-09-06 21:32:33 HKT; 1min 17s ago
Process: 15457 ExecStart=/usr/sbin/nginx -g daemon on; masterprocess on; (code=exited, status=0/SUCCESS)
Process: 15455 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master
process on; (code=exited, status=0/SUCCESS)
Main PID: 15458 (nginx)
CGroup: /system.slice/nginx.service
├─15458 nginx: master process /usr/sbin/nginx -g daemon on; master...
├─15459 nginx: worker process
├─15460 nginx: worker process
├─15461 nginx: worker process
└─15462 nginx: worker process

It seems like that nginx is in good status,an error info occur when to input 127.0.0.1:8080

Unable to connect

Iceweasel can't establish a connection to the server at 127.0.0.1:8080.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Iceweasel is permitted to access the Web.
Have another answer? Share your knowledge.