NEXTCLOUD - Install Script On Ubuntu 24.4: Difference between revisions
From IT-Arts.net
Created page with "Category:Wiki This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS = install_nextcloud.sh = <nowiki> #!/bin/bash # This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS # Update system and install essential utilities echo "Updating system and installing essential utilities..." sudo apt update && sudo apt upgrade -y sudo apt install -y curl wget gnupg2 lsb-release ca-certificates software-properties-common # Instal..." |
m Text replacement - "Category:Wiki" to "Category:Wiki '''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' " |
||
| Line 1: | Line 1: | ||
[[Category:Wiki]] | [[Category:Wiki]] | ||
'''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' | |||
This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS | This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS | ||
Latest revision as of 08:26, 17 January 2026
This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS
install_nextcloud.sh
#!/bin/bash
# This script installs Nextcloud with Nginx and PostgreSQL on Ubuntu 24.04 LTS
# Update system and install essential utilities
echo "Updating system and installing essential utilities..."
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget gnupg2 lsb-release ca-certificates software-properties-common
# Install Nginx, PostgreSQL, and PHP dependencies
echo "Installing Nginx, PostgreSQL, and PHP dependencies..."
sudo apt install -y nginx postgresql postgresql-contrib php-fpm php-pgsql php-cli php-gd php-mbstring php-xml php-curl php-zip php-intl php-bcmath git unzip
# Enable and start Nginx and PostgreSQL services
echo "Enabling and starting Nginx and PostgreSQL services..."
sudo systemctl enable nginx
sudo systemctl enable postgresql
sudo systemctl start nginx
sudo systemctl start postgresql
# Create a PostgreSQL database and user for Nextcloud
echo "Setting up PostgreSQL for Nextcloud..."
# Switch to the PostgreSQL user
sudo -u postgres psql -c "CREATE DATABASE nextcloud;"
sudo -u postgres psql -c "CREATE USER nextclouduser WITH PASSWORD 'nextcloudpassword';"
sudo -u postgres psql -c "ALTER ROLE nextclouduser SET client_encoding TO 'utf8';"
sudo -u postgres psql -c "ALTER ROLE nextclouduser SET default_transaction_isolation TO 'read committed';"
sudo -u postgres psql -c "ALTER ROLE nextclouduser SET timezone TO 'UTC';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextclouduser;"
# Download and configure Nextcloud
echo "Downloading and configuring Nextcloud..."
# Move to the /var/www directory and clone the Nextcloud repository
cd /var/www
sudo git clone https://github.com/nextcloud/server.git nextcloud
sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud
# Configure PHP-FPM for Nextcloud
echo "Configuring PHP-FPM for Nextcloud..."
sudo nano /etc/php/$(php -r 'echo PHP_VERSION_ID;')/fpm/php.ini
# Set the following values in php.ini (update these values as per your needs):
# max_execution_time = 360
# memory_limit = 512M
# post_max_size = 512M
# upload_max_filesize = 512M
# date.timezone = 'UTC'
# Restart PHP-FPM to apply changes
sudo systemctl restart php$(php -r 'echo PHP_VERSION_ID;')-fpm
# Set up Nginx configuration for Nextcloud
echo "Setting up Nginx configuration for Nextcloud..."
# Create a new Nginx configuration file for Nextcloud
sudo bash -c 'cat <<EOF > /etc/nginx/sites-available/nextcloud
server {
listen 80;
server_name your-domain.com; # Replace with your domain or IP
root /var/www/nextcloud;
index index.php index.html index.htm;
location / {
try_files \$uri \$uri/ =404;
}
location ~ ^/\.well-known/acme-challenge/ {
allow all;
root /var/www/nextcloud;
}
location ~ ^/index.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php$(php -r 'echo PHP_VERSION_ID;')-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nextcloud\$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
client_max_body_size 512M;
fastcgi_max_temp_file_size 1G;
}
EOF'
# Create a symbolic link to enable the site
sudo ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
# Test Nginx configuration
echo "Testing Nginx configuration..."
sudo nginx -t
# Restart Nginx to apply changes
echo "Restarting Nginx..."
sudo systemctl restart nginx
# Set up Nextcloud database configuration
echo "Configuring Nextcloud database..."
# Open Nextcloud's config.php file to modify database settings
# This step will be done during the web interface setup, but let's make sure the directory is correct
sudo cp /var/www/nextcloud/config/config.sample.php /var/www/nextcloud/config/config.php
# Set permissions for Nextcloud directory
echo "Setting permissions for Nextcloud directory..."
sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud
# Final setup through the web interface
echo "Nextcloud installation should now be accessible at http://your-domain.com or http://<your-server-ip>"
echo "Visit this URL to complete the installation via the web interface."
exit 0
