mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 07:46:35 +01:00
fix static file permissions
This commit is contained in:
4
.idea/workspace.xml
generated
4
.idea/workspace.xml
generated
@@ -4,7 +4,9 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="5251c5c9-f2a1-41f2-bc76-10b517091df1" name="Changes" comment="" />
|
||||
<list default="true" id="5251c5c9-f2a1-41f2-bc76-10b517091df1" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/install/install.py" beforeDir="false" afterPath="$PROJECT_DIR$/install/install.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
||||
@@ -140,6 +140,42 @@ detect_os() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to fix static file permissions (critical for LiteSpeed)
|
||||
fix_static_file_permissions() {
|
||||
echo " 🔧 Fixing static file permissions for web server access..."
|
||||
|
||||
# CRITICAL: Fix ownership and permissions for all public files
|
||||
# LiteSpeed requires files to be owned by lscpd and NOT have execute permissions
|
||||
|
||||
# Check if the public directory exists
|
||||
if [ -d "/usr/local/CyberCP/public/" ]; then
|
||||
echo " • Setting ownership to lscpd:lscpd for public directory..."
|
||||
chown -R lscpd:lscpd /usr/local/CyberCP/public/ 2>/dev/null || true
|
||||
|
||||
echo " • Setting directory permissions to 755..."
|
||||
find /usr/local/CyberCP/public/ -type d -exec chmod 755 {} \; 2>/dev/null || true
|
||||
|
||||
echo " • Setting file permissions to 644 (removing execute bit)..."
|
||||
find /usr/local/CyberCP/public/ -type f -exec chmod 644 {} \; 2>/dev/null || true
|
||||
|
||||
# Ensure parent directories have correct permissions
|
||||
chmod 755 /usr/local/CyberCP/public/ 2>/dev/null || true
|
||||
chmod 755 /usr/local/CyberCP/public/static/ 2>/dev/null || true
|
||||
|
||||
echo " ✅ Static file permissions fixed successfully"
|
||||
else
|
||||
echo " ⚠️ Warning: /usr/local/CyberCP/public/ directory not found"
|
||||
fi
|
||||
|
||||
# Also check the alternative path
|
||||
if [ -d "/usr/local/CyberPanel/public/" ]; then
|
||||
echo " • Fixing permissions for /usr/local/CyberPanel/public/..."
|
||||
chown -R lscpd:lscpd /usr/local/CyberPanel/public/ 2>/dev/null || true
|
||||
find /usr/local/CyberPanel/public/ -type d -exec chmod 755 {} \; 2>/dev/null || true
|
||||
find /usr/local/CyberPanel/public/ -type f -exec chmod 644 {} \; 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to fix post-installation issues
|
||||
fix_post_install_issues() {
|
||||
echo " 🔧 Fixing database connection issues..."
|
||||
@@ -683,12 +719,11 @@ install_cyberpanel_direct() {
|
||||
# Check if installation was successful
|
||||
if [ $install_exit_code -eq 0 ]; then
|
||||
print_status "SUCCESS: CyberPanel installed successfully"
|
||||
|
||||
# Run post-installation fixes
|
||||
# echo ""
|
||||
# echo " 🔧 Running post-installation fixes..."
|
||||
# fix_post_install_issues
|
||||
|
||||
|
||||
# Run static file permission fixes (critical for LiteSpeed)
|
||||
echo ""
|
||||
fix_static_file_permissions
|
||||
|
||||
return 0
|
||||
else
|
||||
print_status "ERROR: CyberPanel installation failed (exit code: $install_exit_code)"
|
||||
|
||||
@@ -2229,16 +2229,6 @@ password="%s"
|
||||
command = 'mv static /usr/local/CyberCP/public/'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
## Set proper permissions for static files
|
||||
command = 'chown -R lscpd:lscpd /usr/local/CyberCP/public/static'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = r'find /usr/local/CyberCP/public/static -type d -exec chmod 755 {} \;'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = r'find /usr/local/CyberCP/public/static -type f -exec chmod 644 {} \;'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
try:
|
||||
path = "/usr/local/CyberCP/version.txt"
|
||||
writeToFile = open(path, 'w')
|
||||
@@ -2400,12 +2390,12 @@ class Migration(migrations.Migration):
|
||||
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
## Fix ownership and permissions for all public files (must be owned by lscpd for web server access)
|
||||
## Static files (CSS, JS, images) must NOT have execute permissions - LiteSpeed blocks files with unnecessary execute bits
|
||||
## CRITICAL FIX: Restore public directory ownership after root:root override
|
||||
## The public directory MUST be owned by lscpd for web server to serve files
|
||||
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
## Set proper permissions: directories get 755, files get 644 (no execute bit for static files!)
|
||||
## Ensure correct permissions: directories 755, files 644 (NO execute bit on static files!)
|
||||
command = r'find /usr/local/CyberCP/public/ -type d -exec chmod 755 {} \;'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
|
||||
@@ -3343,18 +3343,6 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
||||
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp"
|
||||
Upgrade.executioner(command, 'chown core code', 0)
|
||||
|
||||
## Fix ownership and permissions for all public files (must be owned by lscpd for web server access)
|
||||
## Static files (CSS, JS, images) must NOT have execute permissions - LiteSpeed blocks files with unnecessary execute bits
|
||||
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/"
|
||||
Upgrade.executioner(command, 'Fix public directory ownership', 0)
|
||||
|
||||
## Set proper permissions: directories get 755, files get 644 (no execute bit for static files!)
|
||||
command = "find /usr/local/CyberCP/public/ -type d -exec chmod 755 {} \;"
|
||||
Upgrade.executioner(command, 'Fix public directory permissions', 0)
|
||||
|
||||
command = "find /usr/local/CyberCP/public/ -type f -exec chmod 644 {} \;"
|
||||
Upgrade.executioner(command, 'Fix public file permissions', 0)
|
||||
|
||||
## change owner
|
||||
|
||||
command = "chown -R root:root /usr/local/lscp"
|
||||
|
||||
Reference in New Issue
Block a user