Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Friday, September 10, 2021

Apache on Ubuntu

Dockerfile for installing Apache on Ubuntu:

FROM ubuntu:20.04

ENV TZ=Europe/Berlin

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get -y install apache2

EXPOSE 80

CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]

Build and run

docker build -t ubu-apache .
docker run --name=ubu-apache -d -p 80:80 -v $(pwd)/html/:/var/www/html/ ubu-apache

Enter in container. Tail logs and list files in html folder

docker exec -it ubu-apache /bin/bash

root@8c138884f9a3:/# tail -f /var/log/apache2/error.log

root@8c138884f9a3:/# tail -f /var/log/apache2/access.log

root@8c138884f9a3:/# ls -l /var/www/html

Friday, March 16, 2018

Set Apache Alias

If you want to put WordPress to sub folder you need to create file wp03.conf with following content:

Alias /wp03 "/var/www/wp03"
<Directory "/var/www/wp03">
 AllowOverride All
 Options FollowSymlinks
 Order deny,allow
 Deny from all
 Allow from all
 Require all granted
</Directory>

Now you can access your blog on http://localhost/wp03

Monday, March 24, 2014

Post installation tasks on CentOS regarding Apache web server

This is a short troubleshooting guide for system administrators. Almost all tasks described in this post should be done as root. You need to be familiar with basic Linux commands / editors such as cat, vi, chmod and chown.

Wednesday, June 26, 2013

Top 3 Apache Rewrite Tips

Maintenance

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance.html
RewriteRule (.*) /maintenance.html [R]

Serve page without 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [L] 

Serve page with 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [R,L]

Friday, June 21, 2013

Serve Pages from Subfolder on Apache

Multiple site hosting on one hosting account in subfolders

Directory structure for domains example.com and otherexample.com

[Folder] public_html
[File  ]    .htaccess
[Folder]    example.com
[File  ]         index.php
[Folder]    otherexample.com
[File  ]         index.php

Content of .htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} example.com
RewriteCond %{REQUEST_URI} !example.com/
RewriteRule ^(.*)$ example.com/$1 [L]


RewriteCond %{HTTP_HOST} otherexample.com
RewriteCond %{REQUEST_URI} !otherexample.com/
RewriteRule ^(.*)$ otherexample.com/$1 [L]

index.php file could be a WordPress index.php that resides in web root folder.

Saturday, June 1, 2013

Serve Multiple Sites from Singe IP Address on Apache

If you want to run multiple sites on one Apache web server say several PHP frameworks - this is how you need to set up the XAMPP server. For WAMP server you need to keep in mind that there are two httpd.conf files and two httpd-vhosts.conf files so you need to modify the right ones.
Don't forget to include DirectoryIndex index.php line in your virtual hosts 'cause some frameworks will not work without it.

Friday, May 31, 2013