Category Archives: ubuntu

Ubuntu 18.04 apache and Certbot

Attempting to install Certbot for LetsEncrpyt on Ubuntu 18.04 running apache and receive the following:

sudo add-apt-repository ppa:certbot/certbot Cannot add PPA: 'ppa:~certbot/ubuntu/certbot' The team named '~certbot' has no PPA named 'ubuntu/cerbot' Please choose from the following available PPAs: * 'cerbot': Certbot PPA * 'certbot-build':

A bit new to Ubuntu but am I missing something here. The PPA is there but it's not available?

Ubuntu 18.04 apache and Certbot

Attempting to install Certbot for LetsEncrpyt on Ubuntu 18.04 running apache and receive the following:

sudo add-apt-repository ppa:certbot/certbot Cannot add PPA: 'ppa:~certbot/ubuntu/certbot' The team named '~certbot' has no PPA named 'ubuntu/cerbot' Please choose from the following available PPAs: * 'cerbot': Certbot PPA * 'certbot-build':

A bit new to Ubuntu but am I missing something here. The PPA is there but it's not available?

Laravel 5.6 – permission denied on logs/laravel.log ubuntu xenial 16.04

Have visited topics on this before to no avail - struggling to get rid of a permissions error "Failed to open stream" on logs/laravel.log, the only thing that works at the moment is setting directory permissions to 777, that of course in a live server production environment is extremely bad practice.

I've followed practically every tutorial, like this one for example is the most recent I've come across:

https://vijayasankarn.wordpress.com/2017/02/04/securely-setting-file-permissions-for-laravel-framework/

and this

https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

Generally speaking, some checks I've carried out include checking ownership/groups by running

ps aux | egrep '(apache|httpd)'

which returns the following results

root      6723  0.0  0.4  77944  4880 ?        Ss   14:53   0:00 /usr/sbin/apache2 -k start
www-data  6726  0.0  0.6 432716  6708 ?        Sl   14:53   0:00 /usr/sbin/apache2 -k start
www-data  6727  0.0  0.6 432772  6696 ?        Sl   14:53   0:00 /usr/sbin/apache2 -k start
ubuntu    6874  0.0  0.0  12948   948 pts/0    S+   15:07   0:00 grep -E --color=auto (apache|httpd)

So I know my server is owned by www-data - even performing sudo chgrp changes such as ubuntu:www-data had no effect.

I had the same problem in local environment. On production, my blade template is practically rendered as raw text content as opposed to displaying the Laravel error page - assuming it's because the bootstrap/cache (which I've also modified permissions and ownership for) is being unable to be written to/partially written to.

I've also noted that a lot of tutorials mention bootstrap/cache being within the /storage folder but in newer Laravel versions this seems to have moved to /project-directory/bootstrap as opposed to /project-directory/storage/bootstrap etc.

I'm running Ubuntu Xenial 16.04 on an Amazon AWS instance.

Any help would be thoroughly appreciated.

Redirect Subdomain to specific port

I want to redirect the subdomain site1.example.com to :5 and the domain example.com to :80. I already have this apache configs:

site1.conf:

<VirtualHost *:5>
    ServerAlias www.site1.example.com
    ServerName example.com
    DocumentRoot /var/www/html/site1

    ErrorLog /var/log/apache2/site1-error.log
    CustomLog /var/log/apache2/site1-access.log combined
</VirtualHost>

000-default.conf:

<VirtualHost *:80>
    ServerName www.example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/html/www.example.com/

    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined    
</VirtualHost>

<VirtualHost *:80>
    ServerName site1.example.com
    ServerAlias www.site1.example.com

    ProxyPass / http://example.com:5
    ProxyPassReverse / http://example.com:5
</VirtualHost>

But there is always the error "ERR_NAME_NOT_RESOLVED". I also tried to create a SRV record in Cloudflare, but no success.

Docker container closes after starting Apache

OK, So I've set up my docker container as I need it.

This is my current Dockerfile:

FROM ubuntu:16.04

RUN apt-get update
RUN apt-get upgrade -y

RUN apt-get install -y \
    build-essential sudo software-properties-common \
    libboost-dev libboost-filesystem-dev libboost-program-options-dev \
    libboost-regex-dev libboost-system-dev libboost-thread-dev \
    libicu-dev libtiff5-dev libfreetype6-dev libpng12-dev \
    libxml2-dev libproj-dev libsqlite3-dev libgdal-dev \
    libcairo-dev libharfbuzz-dev

RUN apt-get install -y postgresql postgresql-contrib

RUN apt-get install -y nodejs 

RUN apt-get install -y python3-dev python-dev git python-pip \
    python-setuptools python-wheel python3-setuptools \
    python3-pip python3-wheel python-cairo-dev libboost-python-dev

RUN apt-get install -y ruby ruby-dev

RUN apt-get install -y wget curl 

RUN pip install --upgrade pip
RUN pip install mapnik

RUN sudo gem install awesome_print colorize twitter_cldr \
    nokogiri unidecoder

RUN apt-get -y install apache2 php-pear lynx-cur

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

EXPOSE 80

ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf

If I build it and run it with docker run -p 80:80 -it mycontainer, it runs fine. I can go via the terminal, do a /usr/bin/apache2ctl start, the server starts as usual and I can access it via localhost from my host's browser. Great!

Now, the idea is to simply put that /usr/bin/apache2ctl start command inside my Dockerfile, so that I don't have to write it every time the container starts.

However: if I put CMD ["/usr/sbin/apache2ctl", "start"] at the very end of my Dockerfile, build it and run it (with docker run -p 80:80 -it mycontainer), the container seems to start, outputs an Apache message and then it stops, no terminal, nothing. (nor does it run in the background).

What goes on? I just want to be able to start Apache automatically and keep the terminal live, so that I can do things there too.

running website with no http show different content

Im running 3 sites in one server the same IP in Ubuntu/Apache using vhost. I bought an SSL certificate and installed it in one of my sites successfully. The problem is when I run the site with no https it shows content from my other site.

Ex.

  • www.aaaaa.com
  • www.bbbbb.com (SSL)
  • www.ccccc.com

when I run https://bbbbb.com there is no problem but when I run http://bbbbb.com it shows the content of www.aaaaa.com

I know the ssl is working correctly coz I have tested it sslchecker.

This is the first time I installed SSL, I hope someone knows something about this problem.

How to configure the Apache Sever in ubuntu to run sites locally?

I am new to Apache and I want to configure example.com remotely. I do not own that domain. I tried this https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts but it didn't work. Can someone tell me what should be the contents of my example.conf file so that example.com and www.example.com both should point at my localhost. thanks

Ubuntu Apache2 cannot read subdomain .htaccess file on Port 443

I have a subdomain wordpress site (test.example.com) on a SSL apache2 server, the subdomain is located in /var/www/test

In the /etc/apache2/sites-available/test.example.conf I have:

<VirtualHost *:80>
    ServerName test.example.com
    DocumentRoot /var/www/test
    <Directory /var/www/test>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
    Redirect permanent "/" "https://test.example.com/"
</VirtualHost>

And in /etc/apache2/sites-available/default-ssl.conf

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin [email protected]
                ServerName test.example.com

                DocumentRoot /var/www/test

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
                SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                BrowserMatch "MSIE [2-6]" \
                               nokeepalive ssl-unclean-shutdown \
                               downgrade-1.0 force-response-1.0
        </VirtualHost>
</IfModule>

and in the .htaccess (/var/www/test)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

What I have don so far was;

I have changed the permalink setting to "plain" (https://test.example.com/?p=123), and they work fine, however when I changed to Post name (https://test.example.com/pageName), it throws 404 page.

Not Found
The requested URL /promotions was not found on this server.
Apache/2.4.18 (Ubuntu) Server at test.example.com Port 443

so I am pretty sure that the problem is with the .htaccess which is not being read by the virtualhost.

What am I missing here?