summaryrefslogtreecommitdiffstats
path: root/server/setup/apache-suexec-fcgid-cgit-etc/0-basic.txt
blob: 85ee7c4d764108dc2cf1abf8599ab311c86379a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Apache2: Installing suexec + fcgid
===================================

/etc/php/7.0/apache2/php.ini /etc/php/7.0/cgi/php.ini
=====================================================
Temp Folder:

sys_temp_dir = "/var/tmp"
upload_tmp_dir = "/var/tmp"
upload_max_filesize = 256M
post_max_size = 256M

Enable opcache:

[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
..

See php.ini
Both php.ini (apache2 and cgi) shall be equal

suexec
========
apt-get install apache2-suexec-custom

groupadd webrunner
useradd -s /bin/false -d /srv/www -g webrunner webrunner

# adding webrunner group to apache2's www-data UID allows access 
# to chown -R webrunner:webrunner /srv/www/<bla>
usermod -a -G webrunner www-data

/etc/apache2/suexec/www-data
+++
/srv/www
public_html/cgi-bin
+++

cp -a /etc/apache2/suexec/www-data /etc/apache2/suexec/webrunner

php7.0-cgi + libapache2-mod-fcgid
======================================
apt-get install php7.0-cgi libapache2-mod-fcgid libfcgi-perl

a2dismod php7.0

a2enmod rewrite
a2enmod suexec
a2enmod include
a2enmod fcgid 

cd /etc/apache2/mods-enabled/
rm php7.0.*

dpkg -P libapache2-mod-php7.3

mkdir /srv/www/scripts

/srv/www/scripts/php7.0-wrapper
+++
#!/bin/sh
PHPRC=/etc/php/7.0/cgi
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/lib/cgi-bin/php7.0
+++

chmod 755 /srv/www/scripts/php7.0-wrapper
chown -R webrunner:webrunner /srv/www/scripts

/etc/apache2/sites-enabled/0xy-z.conf

<VirtualHost *:80>
    SuexecUserGroup webrunner webrunner

    <Directory /srv/www/jordan>
        Options +Indexes +ExecCGI -MultiViews +SymLinksIfOwnerMatch

        AddHandler fcgid-script .php
        FcgidWrapper /srv/www/scripts/php7.0-wrapper .php
    </Directory>


systemctl restart apache2
/etc/init.d/apache2 restart