apache

Error: Undefined constant PDO::MYSQL_ATTR_USE_BUFFERED_QUERY

sudo apt-get install php8.2-mysql
sudo apachectl restart

GOOD tutorial about running apache and php both from homebrew

variables

httpd -V
#output:
#...
# -D SERVER_CONFIG_FILE="/usr/local/etc/httpd/httpd.conf"
#...

accesslog file analyze

goaccess combined.access.log -o report.html --log-format=COMBINED

restart php-fpm

sudo /etc/init.d/php7.3-fpm restart

create subdomain (bash script)

#!/bin/bash

if [[ $# -eq 0 ]] ; then
    echo 'Usage: sudo ./createSubdomain.sh subdomain.mysite.nl'
    exit 1
fi

if [ `id -u` -ne 0 ]; then
    echo "Error: Please run this script with 'sudo'"
    exit 1
fi

if [[ $1 != *.hualab.nl ]] ; then
    echo 'Error: not a valid subdomain: $1 on hualab.nl'
    exit 1
fi

if [ -d /var/www/$1 ]; then
    echo "Error: already exists: $1"
    exit 1
fi

mkdir -p "/var/www/$1/public_html/"
mkdir "/var/log/apache2/$1"

chown rick:www-data "/var/www/$1/public_html/"

conf=/etc/apache2/sites-available/$1.conf

touch $conf

echo "" > $conf
echo "<VirtualHost *:80>" >> $conf
echo "    ServerAdmin me@mysite.nl" >> $conf
echo "    ServerName $1" >> $conf
echo "    DocumentRoot /var/www/$1/public_html/" >> $conf
echo "    ErrorLog /var/log/apache2/$1/error.log" >> $conf
echo "    CustomLog /var/log/apache2/$1/access.log combined" >> $conf
echo "</VirtualHost>" >> $conf

echo "<Directory /var/www/$1/public_html/>" >> $conf
echo "    Options Indexes FollowSymLinks" >> $conf
echo "    AllowOverride All" >> $conf
echo "    Require all granted" >> $conf
echo "</Directory>" >> $conf

a2ensite $1.conf

apachectl configtest

systemctl reload apache2

rm ~/$1 #remove symbolic link

ln -s /var/www/$1/public_html/  ~/$1

echo $1 > ~/$1/index.html

sudo certbot -d $1

SSLCertificateFile: file '/etc/letsencrypt/live/.....' does not exist or is empty

Solution:

sudo chmod 755 /etc/letsencrypt/archive
sudo chmod 755 /etc/letsencrypt/live/
apachectl configtest

Syntax OK

let's encrypt

sudo certbot --apache

'Error: mysite.com does not exist' when using a2ensite

cause: sudo a2ensite mysite.com

solution: add .conf to the filename!

a2ensite is simply a perl script that only works with filenames ending .conf

/etc/apache2/sites-enabled

in this folder (/etc/apache2/sites-enabled) small .conf files per site are placed.

find apache2.conf

/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE

create Virtual Hosts on Ubuntu

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

sudo a2ensite gerard.companje.nl.conf

good tutorial to get Apache & PHP (& mySQL) working on OSX

Invalid command 'LockFile'

El Capitan Apache error message AH00526: Syntax error on line 20 of /private/etc/apache2/extra/httpd-mpm.conf: Invalid command 'LockFile'.... http://apple.stackexchange.com/questions/211015/el-capitan-apache-error-message-ah00526

cd /etc/apache2/extra
sudo mv httpd-mpm.conf httpd-mpm.conf.elcapitan
sudo mv httpd-mpm.conf~orig httpd-mpm.conf
sudo apachectl restart
apachectl configtest

tips

http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/#apacheuser

fix permissions on OSX

cd ~/Sites/yoursite
sudo chown -R _www .
sudo chmod -R g+w .

# group settings sudo dseditgroup -o edit -a rick -t user _www # become a member of the _www group sudo chgrp -R _www . # set group of current folder and subfolders to _www

Apache guide on OSX

debug your virtual host configuration

/usr/sbin/httpd -S

follow apache log

tail -f /private/var/log/apache2/error_log

Symbolic link not allowed or link target not accessible

Solution: https://romaimperator.com/?p=9 Rights need to be set for every folder (also parent folders):

chmod a+x /Users/rick/Documents/Doodle3D/3dprintserver
chmod a+x /Users/rick/Documents/Doodle3D 
chmod a+x /Users/rick/Documents 

http status info

httpd -S

on ubuntu:

apachectl -S

create virtual host on mac

  • add hostname to /etc/hosts (pointing to 127.0.0.1)

  • check location of httpd config:

    /usr/sbin/httpd -V | grep SERVER_CONFIG
  • edit httpd.conf (probably at: ''/private/etc/apache2/httpd.conf''): uncomment the include for Virtual Host

  • edit httpd-vhosts.conf (probably at: ''/private/etc/apache2/extra/httpd-vhosts.conf'': add a virtual host like:

<VirtualHost *:80>
    DocumentRoot "/Users/rick/Sites/lepetitgarage"
    ServerName lepetitgarage.nl
</VirtualHost>

restart apache

sudo apachectl stop && sudo apachectl restart

autostart apache on mac

httpd per virtual host

/usr/local/directadmin/data/users/

meerdere logfiles monitoren

httpd info

/usr/sbin/httpd -V

find which httpd.conf

/usr/sbin/httpd -V |grep SERVER_CONFIG

autostart wamp server on windows

Run services.msc Set wampapache and wampmysqld to Startup type 'Automatic'

htaccess

zie ook [[htaccess]]

htaccess ignored on osx

make sure that 'AllowOverride All' is set in /private/etc/apache2/httpd.conf and/or /etc/apache2/users/USERNAME.conf

apache opnieuw opstarten

sudo /etc/init.d/httpd restart

op mac

sudo apachectl stop
sudo apachectl start

default site op onze server

/var/www/html

Allow access to the webserver through the network

allow access from other computers than localhost turn off 'deny from all' in httpd.conf

Virtual hosts

Virtual hosts kun je toevoegen in:

apache/conf/extra/httpd-vhosts.conf

but be sure to turn on the include in httpd.conf

Include conf/extra/httpd-vhosts.conf

Virtualhost: Forbidden, You don't have permission to access / on this server

The problem is that the extra/httpd-vhosts.conf is missing the directive to allow access to the directory. Allow access by adding a section inside the section.

<directory /vhost_document_root>
allow from all
</directory>

Virtualhost: Forbidden, You don't have permission to access / on this server

This can also be caused by a wrong DocumentRoot and directory settings for the DocumentRoot. Check the ''/private/etc/apache2/httpd.conf'' file and search for DocumentRoot. Make sure the paths are set to the right location. DocumentRoot "/Users/rick/Sites/" <Directory "/Users/rick/Sites/">

error_log

location of the error_log file:

tail -f /var/log/httpd/error_log
#/var/log/apache2/error.log