Discussion Setting up a web server (port 80 in use?)

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
I'm trying to set up a small and easy web server on the same server I'm running Plexguide on, but got the following error thrown at me during the installation of apache:

Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Sun 2019-04-14 17:11:33 CEST; 7ms ago
Process: 1271 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

Apr 14 17:11:33 freeloader apachectl[1271]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2a01:4f8:161:11ac::2. Set the 'ServerName' directive globally to suppress this message
Apr 14 17:11:33 freeloader apachectl[1271]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Apr 14 17:11:33 freeloader apachectl[1271]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Apr 14 17:11:33 freeloader apachectl[1271]: no listening sockets available, shutting down
Apr 14 17:11:33 freeloader apachectl[1271]: AH00015: Unable to open logs
Apr 14 17:11:33 freeloader apachectl[1271]: Action 'start' failed.
Apr 14 17:11:33 freeloader apachectl[1271]: The Apache error log may have more information.
Apr 14 17:11:33 freeloader systemd[1]: apache2.service: Control process exited, code=exited status=1
Apr 14 17:11:33 freeloader systemd[1]: apache2.service: Failed with result 'exit-code'.
Apr 14 17:11:33 freeloader systemd[1]: Failed to start The Apache HTTP Server.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.19) ...
I'm assuming it's because Plexguide is already (generally) listening to port 80?

Essentially I want to run the webserver on www.[MYDOMAIN].com or on a subdomain.

Does anybody have suggestions for settings or configurations? Preferably to run it as a docker container even?
 
M

MrDoob

Guest
service apache2 stop 2>&1 >> /dev/null
service nginx stop 2>&1 >> /dev/null
apt-get purge apache nginx -yqq 2>&1 >> /dev/null
apt-get autoremove -yqq 2>&1 >> /dev/null
apt-get autoclean -yqq 2>&1 >> /dev/null
 

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
I figured as much, yeah.

service apache2 stop 2>&1 >> /dev/null
service nginx stop 2>&1 >> /dev/null
apt-get purge apache nginx -yqq 2>&1 >> /dev/null
apt-get autoremove -yqq 2>&1 >> /dev/null
apt-get autoclean -yqq 2>&1 >> /dev/null
What do these commands do?

Can I use Traefik to re-route traffic on the www subdomain to an apache container by any chance?
 

Admin9705

Administrator
Project Manager
Local time
12:35 PM
Jan 17, 2018
4,759
1,805
I figured as much, yeah.



What do these commands do?

Can I use Traefik to re-route traffic on the www subdomain to an apache container by any chance?
you can build your own apache docker container app. traefik needs port 443 and port 80.
 

plex_noob

Senior Member
Staff
Donor
Local time
7:35 PM
Oct 1, 2018
223
105
Brussels
If the web server is a docker container then there is no problem. If it is on another server, the traefik configuration is a bit more complex.
 
  • Like
Reactions: Admin9705

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
Thanks for the feedback guys.

[email protected] /opt/mycontainers # cp /opt/mycontainers/_template.yml app.yml
cp: cannot stat '/opt/mycontainers/_template.yml': No such file or directory
Looks like there's a little bug there. Any idea where I can find the _template.yml file?
 

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
I got it to work, based on the docker compose file from one of the core apps.

The core tech is really interesting, basically Traefik is doing all the work for me.

For reference, if anyone else wants to have a go:

Code:
#!/bin/bash
#
# Title:      Httpd WebServer
# Author(s):  Freeloader (based on PGBlitz framework)
# URL:        https://pgblitz.com - http://github.pgblitz.com
# GNU:        General Public License v3.0
################################################################################
---
- hosts: localhost
  gather_facts: false
  tasks:
    # FACTS #######################################################################
    - name: 'Set Known Facts'
      set_fact:
        pgrole: 'www'
        intport: '80'
        extport: '7979'
        image: 'httpd:2.4'

    # CORE (MANDATORY) ############################################################
    - name: 'Including cron job'
      include_tasks: '/opt/communityapps/apps/_core.yml'

    # LABELS ######################################################################
    - name: 'Adding Traefik'
      set_fact:
        pg_labels:
          traefik.frontend.auth.forward.address: '{{gauth}}'
          traefik.enable: 'true'
          traefik.port: '{{intport}}'
          traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'

    - name: 'Setting PG Volumes'
      set_fact:
        pg_volumes:
          - '/opt/appdata/{{pgrole}}:/var/www/html'
          - '/etc/localtime:/etc/localtime:ro'

    - name: 'Setting PG ENV'
      set_fact:
        pg_env:
          PUID: '1000'
          PGID: '1000'

    # MAIN DEPLOYMENT #############################################################
    - name: 'Deploying {{pgrole}}'
      docker_container:
        name: '{{pgrole}}'
        image: '{{image}}'
        pull: yes
        published_ports:
          - '{{ports.stdout}}{{extport}}:{{intport}}'
        volumes: '{{pg_volumes}}'
        env: '{{pg_env}}'
        restart_policy: unless-stopped
        networks:
          - name: plexguide
            aliases:
              - '{{pgrole}}'
        state: started
        labels: '{{pg_labels}}'

##PG-Community

##PG-Community
The only stuff I wasn't able to figure out:
  • My web files (index.html etc) are stored at "/var/lib/docker/overlay2/[*container hash*]/diff/usr/local/apache2/htdocs". Not sure how to get it to a more central location.
  • How I can install php and/or mysql along with it. I would expect something along these lines (https://stackoverflow.com/questions/41423349/docker-how-to-set-up-apache-php-in-docker-compose-yml ) with two or three services installed, and one linking to the other, but this docker compose script is a bit more complicated than that, so not sure how to amend.
 
  • Love
Reactions: Admin9705

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
Thanks!

I went with the following:
Code:
#!/bin/bash
#
# Title:      WebServer
# Author(s):  Freeloader
# URL:        https://pgblitz.com - http://github.pgblitz.com
# GNU:        General Public License v3.0
################################################################################
---
- hosts: localhost
  gather_facts: false
  tasks:
    # FACTS #######################################################################
    - name: 'Set Known Facts'
      set_fact:
        pgrole: 'www'
        intport: '80'
        extport: '7979'
        image: 'plehr/docker-php-sqlsrv-curl'

    # CORE (MANDATORY) ############################################################
    - name: 'Including cron job'
      include_tasks: '/opt/communityapps/apps/_core.yml'

    # LABELS ######################################################################
    - name: 'Adding Traefik'
      set_fact:
        pg_labels:
          traefik.frontend.auth.forward.address: '{{gauth}}'
          traefik.enable: 'true'
          traefik.port: '{{intport}}'
          traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'

    - name: 'Setting PG Volumes'
      set_fact:
        pg_volumes:
          - '/opt/appdata/{{pgrole}}:/var/www/html'
          - '/etc/localtime:/etc/localtime:ro'

    - name: 'Setting PG ENV'
      set_fact:
        pg_env:
          PUID: '1000'
          PGID: '1000'

    # MAIN DEPLOYMENT #############################################################
    - name: 'Deploying {{pgrole}}'
      docker_container:
        name: '{{pgrole}}'
        image: '{{image}}'
        pull: yes
        published_ports:
          - '{{ports.stdout}}{{extport}}:{{intport}}'
        volumes: '{{pg_volumes}}'
        env: '{{pg_env}}'
        restart_policy: unless-stopped
        networks:
          - name: plexguide
            aliases:
              - '{{pgrole}}'
        state: started
        labels: '{{pg_labels}}'

##PG-Community

##PG-Community
The weird thing is that I get the following error when trying to access the page: "You don't have permission to access /index.html on this server."

It's only when I manually chmod index.html to 775 that I can access the page.

I uploaded the index.html file using the same ftp user as the one that installed Plexguide and that I used to install the www container inside Plexguide.
 
Last edited:
M

MrDoob

Guest
# CORE (MANDATORY) ############################################################
- name: 'Including cron job'
include_tasks: '/opt/coreapps/apps/_core.yml'

-----
force: yes
owner: '1000'
group: '1000'

---
 

freeloader

Full Member
Original poster
Local time
6:35 PM
Mar 29, 2019
47
10
Thanks!

So I change it as follows?
Code:
# CORE (MANDATORY) ############################################################
    - name: 'Including cron job'
      include_tasks: '/opt/communityapps/apps/_core.yml'
      -----
      force: yes
      owner: '1000'
      group: '1000'
      ---
Edit: that doesn't work.

ERROR! Syntax Error while loading YAML.
could not find expected ':'

The error appears to have been in '/opt/communityapps/apps/www.yml': line 24, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

-----
force: yes
^ here
 
Last edited:
M

MrDoob

Guest
Check this and you see what is wrong

 

timekills

Legendary Member
Staff
Donor
Local time
8:35 PM
Sep 12, 2018
351
168
Thanks!

So I change it as follows?
Code:
# CORE (MANDATORY) ############################################################
    - name: 'Including cron job'
      include_tasks: '/opt/communityapps/apps/_core.yml'
      -----
      force: yes
      owner: '1000'
      group: '1000'
      ---
Edit: that doesn't work.
YAML:
    - name: 'Setting default ENV'
      set_fact:
        pg_env:
          USER_ID: 1000
          GROUP_ID: 1000
 
Assists Greatly with Development Costs

timekills

Legendary Member
Staff
Donor
Local time
8:35 PM
Sep 12, 2018
351
168
Working/tested file example attached.
If you want to specify a certain folder to be available through the web server change line 41 so the portion before the colon is the location of the folder you want available.

Change "ww" below to "www". For some reason I can't use www in the code section. (?)

YAML:
-'/folder/you/want/available:/var/ww/html'
 

Attachments

Last edited:
  • Like
Reactions: Admin9705

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads


Maintenance Donations

Recommend NewsGroups

      Up To a 58% Discount!

Trending