forked from gregkare/php-remote-storage-deployment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·112 lines (81 loc) · 4.39 KB
/
deploy.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# Script to deploy php-remote-storage on a Fedora >= 22 installation using DNF.
#
# Tested on Fedora 23
###############################################################################
# VARIABLES
###############################################################################
# VARIABLES
HOSTNAME=storage.example
###############################################################################
# SYSTEM
###############################################################################
sudo dnf -y update
# set hostname
sudo hostnamectl set-hostname ${HOSTNAME}
###############################################################################
# SOFTWARE
###############################################################################
# enable COPR repos
sudo dnf -y copr enable fkooman/php-base
sudo dnf -y copr enable fkooman/php-remote-storage
# install software
sudo dnf -y install mod_ssl php php-opcache php-fpm httpd openssl php-remote-storage php-webfinger
###############################################################################
# CERTIFICATE
###############################################################################
# Generate the private key
sudo openssl genrsa -out /etc/pki/tls/private/${HOSTNAME}.key 2048
sudo chmod 600 /etc/pki/tls/private/${HOSTNAME}.key
# Create the CSR (can be used to obtain real certificate!)
sudo openssl req -subj "/CN=${HOSTNAME}" -sha256 -new -key /etc/pki/tls/private/${HOSTNAME}.key -out ${HOSTNAME}.csr
# Create the (self signed) certificate and install it
sudo openssl req -subj "/CN=${HOSTNAME}" -sha256 -new -x509 -key /etc/pki/tls/private/${HOSTNAME}.key -out /etc/pki/tls/certs/${HOSTNAME}.crt
###############################################################################
# APACHE
###############################################################################
# empty the default Apache config file
sudo sh -c 'echo "" > /etc/httpd/conf.d/php-remote-storage.conf'
sudo sh -c 'echo "" > /etc/httpd/conf.d/php-webfinger.conf'
# use the global httpd config file
sudo cp storage.example-httpd.conf /etc/httpd/conf.d/${HOSTNAME}.conf
sudo sed -i "s/storage.example/${HOSTNAME}/" /etc/httpd/conf.d/${HOSTNAME}.conf
# Don't have Apache advertise all version details
# https://httpd.apache.org/docs/2.4/mod/core.html#ServerTokens
sudo sh -c 'echo "ServerTokens ProductOnly" > /etc/httpd/conf.d/servertokens.conf'
###############################################################################
# PHP
###############################################################################
# Set PHP timezone, to suppress errors in the log
sudo sed -i 's/;date.timezone =/date.timezone = UTC/' /etc/php.ini
#https://secure.php.net/manual/en/ini.core.php#ini.expose-php
sudo sed -i 's/expose_php = On/expose_php = Off/' /etc/php.ini
# recommendation from https://php.net/manual/en/opcache.installation.php
sudo sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=60/' /etc/php.d/10-opcache.ini
# PHP-FPM configuration
sudo sed -i "s|listen = /run/php-fpm/www.sock|listen = [::]:9000|" /etc/php-fpm.d/www.conf
sudo sed -i "s/listen.allowed_clients = 127.0.0.1/listen.allowed_clients = 127.0.0.1,::1/" /etc/php-fpm.d/www.conf
###############################################################################
# APP
###############################################################################
# enable Twig template cache
sudo sed -i 's/;templateCache/templateCache/' /etc/php-remote-storage/server.ini
# Initialize DB
sudo -u apache php-remote-storage-init
# Create storage directory (XXX can we do this from RPM?)
sudo -u apache mkdir -p /var/lib/php-remote-storage/storage
# Enable WebFinger php-remote-storage snippets
sudo cp /etc/php-webfinger/conf.d/php-remote-storage-05.conf.example /etc/php-webfinger/conf.d/php-remote-storage-05.conf
sudo sed -i 's|/php-remote-storage||' /etc/php-webfinger/conf.d/php-remote-storage-05.conf
sudo cp /etc/php-webfinger/conf.d/php-remote-storage-03.conf.example /etc/php-webfinger/conf.d/php-remote-storage-03.conf
sudo sed -i 's|/php-remote-storage||' /etc/php-webfinger/conf.d/php-remote-storage-03.conf
###############################################################################
# DAEMONS
###############################################################################
# enable HTTPD and PHP-FPM on boot
sudo systemctl enable httpd
sudo systemctl enable php-fpm
# start HTTPD and PHP-FPM
sudo systemctl start php-fpm
sudo systemctl start httpd
# ALL DONE!