APACHE HTTP szerver


Írta: Bora Norbert
november 03, 2018

Telepítés

apt-get install apache2

Indítás/Leállítás és újraindítás


service
service apache2 start
service apache2 stop
service apache2 restart

/etc/init.d/
/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart

systemctl
systemctl start apache2.service
systemctl stop apache2.service
systemctl restart apache2.service

Elérési útvonalak

/
|
- /etc
|   |
|   - /apache2
|         |
|         - /sites-available
|         |        |
|         |        - 000-default.conf
|         |
|         - apache2.conf
|
- /var
    |
    - /www
        |
        - /html
        |     |
        |     - /blog
        |     |     |
        |     |     - /web
        |     |
        |     - /forum
        |     |     |
        |     |     - /web
        |     |
        |     - /webshop
        |           |
        |           - /web
        |
        - index.html

Virtuális állomások

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
    ServerName blog.localhost
    DocumentRoot /var/www/html/blog/web
</VirtualHost>

<VirtualHost *:80>
    ServerName forum.localhost
    DocumentRoot /var/www/html/forum/web
</VirtualHost>

<VirtualHost *:80>
    ServerName webshop.localhost
    DocumentRoot /var/www/html/webshop/web
</VirtualHost>

Az Apache dokumentum gyökérmappájának a módosítása másodlagos merevlemezre

sudo usermod -aG www-data username

sudo chown -R www-data:www-data /path/to/my/project

nano /etc/apache2/sites-available/000-default.conf

DocumentRoot /path/to/my/project

sudo service apache2 restart

Ha azt a tiltott üzenetet kapjuk, hogy nincs engedélyünk a / elérésére ezen a szerveren az apache gyökércseréje után, akkor kövessük az alábbi lépéseket
nano /etc/apache2/apache2.conf

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

a2enmod, a2dismod


A motor átírásának (RewriteEngine) az engedélyezése
a2enmod rewrite

service apache2 restart

.htaccess

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

SQLite


Telepítés
apt-get install php7.4-sqlite3

Engedélyezés (/etc/php/7.4/apache2/php.ini)
extension=pdo_sqlite

Logolás

sudo cat /var/log/apache2/error.log

sudo cat /var/log/apache2/access.log

sudo cat /var/log/apache2/other_vhosts_access.log

Felhasznált irodalom


Rich Bowen - Ken Coan - Apache receptek - moly.hu
Julie C. Meloni - A ​PHP, a MySQL és az Apache használata - moly.hu

Hivatkozások


Magyar

Angol

Start / Stop and Restart Apache 2 Web Server Command
User and Group permissions, with chmod, and Apache
Change Apache document root folder to secondary hard drive
How To Configure the Apache Web Server on an Ubuntu or Debian VPS?
How to give apache permission to write to home directory?
How do I find Apache http server log files?