Cannot Access the Sen2Agir web interface, tried starting httpd but failed


#1

Hi,

Is there a way to check start the httpd service so that I can access the Sen2Agri web interface?

sytemctl status httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2018-01-17 18:00:26 +08; 17min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9255 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 9253 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9253 (code=exited, status=1/FAILURE)

Jan 17 18:00:26 ESSCGeo-Sen2Agri httpd[9253]: (98)Address already in use: AH00072: make_sock: could not bind...]:80
Jan 17 18:00:26 ESSCGeo-Sen2Agri httpd[9253]: (98)Address already in use: AH00072: make_sock: could not bind...0:80
Jan 17 18:00:26 ESSCGeo-Sen2Agri httpd[9253]: no listening sockets available, shutting down
Jan 17 18:00:26 ESSCGeo-Sen2Agri httpd[9253]: AH00015: Unable to open logs
Jan 17 18:00:26 ESSCGeo-Sen2Agri systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 17 18:00:26 ESSCGeo-Sen2Agri kill[9255]: kill: cannot find process ""
Jan 17 18:00:26 ESSCGeo-Sen2Agri systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 17 18:00:26 ESSCGeo-Sen2Agri systemd[1]: Failed to start The Apache HTTP Server.
Jan 17 18:00:26 ESSCGeo-Sen2Agri systemd[1]: Unit httpd.service entered failed state.
Jan 17 18:00:26 ESSCGeo-Sen2Agri systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

As I try to start it, this result showed:

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

This question might be related to this post since this is the one I’m working recently.


#2

What does

sudo ss -pantl | grep :80

show?


#3

here are the results:

LISTEN     0      128          *:80                       *:*                   users:(("nginx",pid=1855,fd=7),("nginx",pid=1854,fd=7))
LISTEN     0      128         :::8080                    :::*                   users:(("node",pid=2317,fd=11))
LISTEN     0      128         :::80                      :::*                   users:(("nginx",pid=1855,fd=8),("nginx",pid=1854,fd=8))
LISTEN     0      128         :::8000                    :::*                   users:(("node",pid=2319,fd=12))

#4

It looks like you’re already running a web server on that system. I would suggest:

  1. Changing the Apache port to e.g. 8001 or something else that’s available (you can check with ss as above) in /etc/httpd/conf/httpd.conf.
  2. Starting Apache (http) as described above.
  3. Adding an nginx server that points to Apache. I’m not sure if you have it configured in /etc/nginx/nginx.conf or some sort of /etc/nginx/sites-available/foo.conf, but in either case, you’ll probably need a section similar to this (untested):
upstream sen2agri {
    server 127.0.0.1:8001 fail_timeout=0;
}

server {
    listen 80;
    server_name sen2agri.host.domain; # it might be easier to place it on a subdomain to avoid needing rewrite rules
    root /dev/null;
    location / {
            proxy_read_timeout 300;
            proxy_connect_timeout 300;
            proxy_redirect off; # you might need to change this or play with rewrite rules
            proxy_set_header Host $host;
            proxy_pass http://sen2agri;
    }
}

In the latter case, you should make a new file under sites-available and make a symlink to it under sites-enabled. If you have doubts, consider contacting your system administrator and passing them this post.

After configuring nginx you can test the new configuration with sudo nginx -t and reload it with sudo systemctl reload nginx.

For more information about setting up a reverse proxy, consult the nginx documentation.


#5

Hello,

I’m assuming that I had compromise my sen2gri system due to repeated uninstall and install processes of sen2agri (both in manual and automatic mode), which resulted to these problems. (or perhaps due to inactive slurm services which is related to mariadb, that I’m trying to figure out in my other post?, I really don’t know)

Anyway, I’m accessing this machine of mine through remote desktop (xrdp). We’re trying to maximize the specs of the said remote desktop, as we are limited by download speed, CPU and memory here in my country) I’m suggesting to my administrator to reinstall the CentOS itself, and then installing again the latest version of Sen2Agri. I’ll inform you of my updates and hopefully it will work.

Cheers and again, much thanks.


#6

Hi,

The issue is that you’re already running a web server on that system. To find out what it’s doing, you can simply open http://localhost/ from a Remote Desktop session. That web server was not installed by the Sen2Agri installer, and does not come with the system by default. I can’t tell why it’s there, but there must be a (good) reason.

But yes, you can indeed pass this on to the system administrator if you have one.

Again, sorry for the inconvenience.


#7

Hi,

I seemed that our system administrator installed Only Office web server, being used by our institute.

I’ll try to see what can I do about this.

Thank you.


#8

Hello again,

I followed your instruction and here’s the results.

Screenshot at 2018-01-23 11-25-42

This is somewhat confusing for me. Is this preferring to /etc/nginx/nginx.conf? or do I need to create a new directory?

And lastly, these are the results of:

sudo nginx -t

nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/nginx.conf:35
nginx: configuration file /etc/nginx/nginx.conf test failed

sudo systemctl reload nginx (ok, no error)

Regards.


#9

Starting Apache (http) as described above.

All right. There’s a warning (it doesn’t know the hostname), but it’s fine to ignore it.

This is somewhat confusing for me. Is this preferring to /etc/nginx/nginx.conf? or do I need to create a new directory?

Yes, you should put that snippet in a file like /etc/nginx/conf.d/sen2agri.host.domain.conf. The error you’re getting is because the upstream and server blocks should be placed inside http. If you move it to a file in will be included there (see the include /etc/nginx/conf.d/*.conf; line. The advantage of this is that it’s easier to make modifications to a site without affecting the others.

And you should replace sen2agri.host.domain with something more appropriate, like the server name (e.g. sen2agri.esscgeo-sen2agri.localdomain). You’ll either need a DNS entry (contact your network administrator for that) or, you’re accessing it from few computers you can add it to the hosts file. In the latter case, edit /etc/hosts (on Linux) and add a line with IP sen2agri.host.domain. Replace IP with the server’s IP address and sen2agri.host.domain with the name you chose before.

sudo systemctl reload nginx (ok, no error)

nginx -t reported an error (because of the misplaced upstream block), so after the reload I suspect that nginx and Only Office are no longer working. To fix that, remove the two blocks you added and run systemctl reload nginx again.


#10

Hi again,

I followed all your advices, just want to share the outcomes.

Here’s the result for the command sudo nginx -t:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Reloading of nginx is also ok. However, I still wasn’t able to access the system’s web interface.
I am sharing this post to my network administrator and update you in this post.

Regards.


#11

All right. As a note, after the steps above, the web UI should be accessible at e.g. http://sen2agri.host.domain/.


#12

Hi there,

My apologies for bothering you again in this thread. Our system administrator already uninstalled the only office web server. I also reinstall the whole sen2agri system (system ad’s request). However, as I tried to see the status of httpd, these results appeared:

[brentf@ESSCGeo-Sen2Agri conf.d]$ systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-02-06 14:21:18 +08; 8min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 10512 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 10510 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 10510 (code=exited, status=1/FAILURE)

Feb 06 14:21:17 ESSCGeo-Sen2Agri httpd[10510]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Feb 06 14:21:17 ESSCGeo-Sen2Agri httpd[10510]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Feb 06 14:21:17 ESSCGeo-Sen2Agri httpd[10510]: no listening sockets available, shutting down
Feb 06 14:21:17 ESSCGeo-Sen2Agri httpd[10510]: AH00015: Unable to open logs
Feb 06 14:21:18 ESSCGeo-Sen2Agri systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Feb 06 14:21:18 ESSCGeo-Sen2Agri kill[10512]: kill: cannot find process ""
Feb 06 14:21:18 ESSCGeo-Sen2Agri systemd[1]: httpd.service: control process exited, code=exited status=1
Feb 06 14:21:18 ESSCGeo-Sen2Agri systemd[1]: Failed to start The Apache HTTP Server.
Feb 06 14:21:18 ESSCGeo-Sen2Agri systemd[1]: Unit httpd.service entered failed state.
Feb 06 14:21:18 ESSCGeo-Sen2Agri systemd[1]: httpd.service failed.

And here are the results of sudo ss -pantl | grep :80

LISTEN     0      128          *:80                       *:*                   users:(("nginx",pid=4351,fd=7),("nginx",pid=1854,fd=7))

Also, the early edits I had in the /etc/ninginx/conf.d/ directory reverted back to their default values.

Brent


#13

Hi,

If you no longer require Only Office, you should stop and disable nginx:

systemctl stop nginx
systemctl disable nginx
systemctl restart httpd

#14

Hello,

The sen2agri web page came back but I cannot logged-in, and the webpage says:

Screenshot at 2018-02-07 11-49-38

Regards.


#15

Hi,

it looks like it’s unable to connect to the Postgres database. Can you check its status?

systemctl status postgresql-9.4`

The connection parameters are set in /var/www/html/ConfigParams.php, you might also want to check that file.


#16

Hello.

Here’s the status of postgresql-9.4:

● postgresql-9.4.service - PostgreSQL 9.4 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2018-02-07 13:00:40 +08; 5 days ago
     Docs: https://www.postgresql.org/docs/9.4/static/
  Process: 13283 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)
  Process: 13276 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)

Feb 07 13:00:39 ESSCGeo-Sen2Agri pg_ctl[13283]: < 2018-02-07 13:00:39.237 +08 >LOG:  could not bind IPv4 socket: Address already in use
Feb 07 13:00:39 ESSCGeo-Sen2Agri pg_ctl[13283]: < 2018-02-07 13:00:39.237 +08 >HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
Feb 07 13:00:39 ESSCGeo-Sen2Agri pg_ctl[13283]: < 2018-02-07 13:00:39.273 +08 >FATAL:  lock file "/var/run/postgresql/.s.PGSQL.5432.lock" already exists
Feb 07 13:00:39 ESSCGeo-Sen2Agri pg_ctl[13283]: < 2018-02-07 13:00:39.273 +08 >HINT:  Is another postmaster (PID 1590) using socket file "/var/run/postgresql/.s.PGSQL.5432"?
Feb 07 13:00:40 ESSCGeo-Sen2Agri pg_ctl[13283]: pg_ctl: could not start server
Feb 07 13:00:40 ESSCGeo-Sen2Agri pg_ctl[13283]: Examine the log output.
Feb 07 13:00:40 ESSCGeo-Sen2Agri systemd[1]: postgresql-9.4.service: control process exited, code=exited status=1
Feb 07 13:00:40 ESSCGeo-Sen2Agri systemd[1]: Failed to start PostgreSQL 9.4 database server.
Feb 07 13:00:40 ESSCGeo-Sen2Agri systemd[1]: Unit postgresql-9.4.service entered failed state.
Feb 07 13:00:40 ESSCGeo-Sen2Agri systemd[1]: postgresql-9.4.service failed.

On the other hand, here are the contents of /var/www/html/ConfigParams.php:

<?php
    class ConfigParams {
        static $CONN_STRING  = 'host=localhost port=5432 dbname=sen2agri user=admin password=sen2agri';
        static $SERVICES_URL = 'http://localhost:8080/dashboard';
        static $SITE_ID;
        static $USER_NAME;

        static function init() {
            // set login information
            if (isset($_SESSION['siteId']) && isset($_SESSION['userId']) && isset($_SESSION['userName'])) {
                self::$SITE_ID   = $_SESSION['siteId'];
                self::$USER_NAME = $_SESSION['userName'];
            }
        }
    }

    ConfigParams::init();
    ?>

Regards.


#17

Hi,

Didn’t this happen to you before? I think you had two versions of Postgres installed on the server:

sudo ss -pantl | grep 5432

#18

Hello,

Here are the results:

LISTEN 0 128 127.0.0.1:5432 *:* users:(("postgres",pid=1590,fd=3))

Yeah you’re right, another version of postgres was installed.


Should I uninstall the other version of my postgres?

Brent


#19

9.4 is ours. You should check what the old one is used for.

$ sudo -u postgres psql
postgres=# \l

#20

Hello again,

I uninstalled all the packages of postgres 9.2 (it was updated automatically by the CentOS system) and successfully started the postgresql-9.4.service, but still can’t log in successfully in the web interface. Any suggestions?

Cheers.