-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathss-perms-php-packages.txt
138 lines (107 loc) · 6.96 KB
/
ss-perms-php-packages.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
####################################################################################################
#### author: SlickStack ############################################################################
#### link: https://slickstack.io ###################################################################
#### mirror: littlebizzy/slickstack/blob/master/bash/ss-perms-php-packages.txt #####################
#### path: /var/www/ss-perms-php-packages ##########################################################
#### destination: n/a (not a boilerplate) ##########################################################
#### purpose: Resets file and user permissions for PHP-FPM module core files and folders ###########
#### module version: PHP-FPM 8.3.x #################################################################
#### sourced by: ss-install-php-packages, ss-perms #################################################
#### bash aliases: ss perms php packages ###########################################################
####################################################################################################
####################################################################################################
#### TABLE OF CONTENTS (SS-Perms-PHP-Packages) #####################################################
####################################################################################################
## this is a brief summary of the different code snippets you will find in this script ##
## each section should be commented so you understand what is being accomplished ##
## A. Source SS-Config + SS-Functions
## B. Touch Timestamp File
## C. Message (Begin Script)
## D. Reset Permissions (PHP Runtime Directory)
## E. Reset Permissions (PHP Config)
## F. Reset Permissions (PHP Logs)
####################################################################################################
#### A. SS-Perms-PHP-Packages: Source SS-Config + SS-Functions #####################################
####################################################################################################
## before anything else we must source the critical variables that power this script ##
## ss-config is setup during ss-install wizard but ss-functions is hardcoded ##
## source ss-config ##
source /var/www/ss-config
## source ss-functions ##
source /var/www/ss-functions
## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS
####################################################################################################
#### B. SS-Perms-PHP-Packages: Touch Timestamp File ################################################
####################################################################################################
## this is a dummy timestamp file that will remember the last time this script was run ##
## it can be useful for developer reference and is sometimes used by SlickStack ##
ss_touch "${TIMESTAMP_SS_PERMS_PHP_PACKAGES}"
####################################################################################################
#### C. SS-Perms-PHP-Packages: Message (Begin Script) ##############################################
####################################################################################################
## this is a simple message that announces to the shell the purpose of this bash script ##
## it will only be seen by sudo users who manually run this script in the shell ##
ss_echo "${COLOR_INFO}Running ss-perms-php-packages... ${COLOR_RESET}"
####################################################################################################
#### D. SS-Perms-PHP-Packages: Reset Permissions (PHP Runtime Directory) ###########################
####################################################################################################
ss_mkdir /var/run/php
chown www-data:www-data /var/run/php
chmod 750 /var/run/php
####################################################################################################
#### E. SS-Perms-PHP-Packages: Reset Permissions (PHP Config) ######################################
####################################################################################################
## ubuntu 24.04 ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "24.04" ]]; then
chown root:root /etc/php/8.3/fpm/php-fpm.conf
chown root:root /etc/php/8.3/fpm/php.ini
chown root:root /etc/php/8.3/cli/php.ini
chown root:root /etc/php/8.3/fpm/pool.d/www.conf
fi
## ubuntu 22.04 ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "22.04" ]]; then
chown root:root /etc/php/8.1/fpm/php-fpm.conf
chown root:root /etc/php/8.1/fpm/php.ini
chown root:root /etc/php/8.1/cli/php.ini
chown root:root /etc/php/8.1/fpm/pool.d/www.conf
fi
## ubuntu 20.04 ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "20.04" ]]; then
chown root:root /etc/php/7.4/fpm/php-fpm.conf
chown root:root /etc/php/7.4/fpm/php.ini
chown root:root /etc/php/7.4/cli/php.ini
chown root:root /etc/php/7.4/fpm/pool.d/www.conf
fi
## ubuntu 18.04 ##
if [[ "${SYSTEM_UBUNTU_VERSION}" == "18.04" ]]; then
chown root:root /etc/php/7.2/fpm/php.ini
chown root:root /etc/php/7.2/fpm/php-fpm.conf
chown root:root /etc/php/7.2/cli/php.ini
chown root:root /etc/php/7.2/fpm/pool.d/www.conf
fi
####################################################################################################
#### F. SS-Perms-PHP-Packages: Reset Permissions (PHP Logs) ########################################
####################################################################################################
if [ ! -f "/var/www/logs/php-error.log" ]; then ss_touch "/var/www/logs/php-error.log"; fi
chown www-data:www-data /var/www/logs/php-error.log
chmod 0644 /var/www/logs/php-error.log ## must be 0644
####################################################################################################
#### SlickStack: Reset Permissions (SlickStack Scripts) ############################################
####################################################################################################
## we include this permissions reset in all cron jobs and bash scripts for redundancy ##
## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ##
## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS
## SNIPPET: ss bash scripts, ss cron jobs
## UPDATED: 02JUL2022
chown root:root /var/www/ss* ## must be root:root
chown root:root /var/www/crons/*cron* ## must be root:root
chown root:root /var/www/crons/custom/*cron* ## must be root:root
chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute
chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute
####################################################################################################
#### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ###############
####################################################################################################
## Ref: ChatGPT
## SS_EOF