Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Build your own self-hosted cloud storage with Nextcloud, with enhanced privacy and security for file management

License

NotificationsYou must be signed in to change notification settings

stowyh/nextcloud-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Benefits

  • Enhanced privacy and security
  • Cost-effective
  • Scalable
  • Greater control and customization

Prerequisites

  • A computer running Ubuntu or any Debian-based distribution.
  • Verify if your ISP allows port forwarding [Optional]
  • Own a domain [Optional]

Initial Server Setup

Update Your Linux Distribution

sudo apt updatesudo apt full-upgradesudo apt autoremove

Install Necessary Packages

sudo apt install neovim wget mariadb-server php php-apcu php-bcmath php-cli php-common php-curl php-gd php-gmp php-imagick php-intl php-mbstring php-mysql php-zip php-xml unzip nmap

Update Your Hostname (Optional)

  • Modify the file to assign an appropriate hostname or domain name to your server.
sudo nvim /etc/hostname

hostname.png

sudo nvim /etc/hosts

hosts.png

  • Restart your server to apply the changes.
sudo reboot

Downloading Nextcloud

  • Download the Nextcloud ZIP file.
wget https://download.nextcloud.com/server/releases/latest.zip

MariaDB Setup

  • Check the status of themariadb service.
systemctl status mariadb
  • Run the secure installation script.
sudo mysql_secure_installation
  • Follow the prompts with the provided inputs:
Password prompt --> Press EnterSwitch to unix_socket_auth [Y/n] --> nChange the root password [Y/n] --> YEnter your secure password:Remove anonymous users [Y/n] --> YDisallow root login remotely [Y/n] --> YRemove test database and access to it [Y/n] --> YReload privilege tables now [Y/n] --> Y

Setting Up the Nextcloud Database

  • Access MariaDB.
sudo mariadb
  • Create the database.
CREATEDATABASEnextcloud;
  • Set up permissions.
GRANT ALL PRIVILEGESON nextcloud.* TO'nextcloud'@'localhost' IDENTIFIED BY'mypassword';FLUSH PRIVILEGES;
  • Exit by pressingCTRL+D.

Apache Web Server

  • Enable the necessary PHP extensions.
sudo phpenmod bcmath gmp imagick intl
  • Unzip the Nextcloud file.
unzip latest.zip
  • Move the files to the serving location and set the appropriate permissions.
mv nextcloud your.domain.namesudo chown -R www-data:www-data your.domain.namesudo mv your.domain.name /var/www
  • Disable the default Apache site.
sudo a2dissite 000-default.conf

Configure Nextcloud Host

  • Create an Apache config file for serving Nextcloud.
sudo nvim /etc/apache2/sites-available/your.domain.name.conf
  • Insert the following content into the file, modifyingyour.domain.name as needed:
<VirtualHost*:80>    DocumentRoot"/var/www/your.domain.name"    ServerName your.domain.name<Directory"/var/www/your.domain.name/">        Options MultiViews FollowSymlinks        AllowOverride All        Order allow,deny        Allow from all</Directory>    TransferLog /var/log/apache2/your.domain.name_access.log    ErrorLog /var/log/apache2/your.domain.name_error.log</VirtualHost>
  • Enable the site.
sudo a2ensite your.domain.name.conf

PHP Configuration

  • Edit the PHP configuration file.
sudo nano /etc/php/8.1/apache2/php.ini
  • Locate and modify the following parameters:
memory_limit =3G# Increase if you have more RAMupload_max_filesize =50G# Adjust based on your needsmax_execution_time =3600post_max_size =50G# Adjust based on your needsdate.timezone = Europe/London# Adjust your timezoneopcache.enable=1opcache.interned_strings_buffer=128opcache.max_accelerated_files=10000opcache.memory_consumption=128opcache.save_comments=1opcache.revalidate_freq=1

Timezones

  • Enable PHP modules for Apache.
sudo a2enmod dir env headers mime rewrite ssl
  • Restart Apache.
sudo systemctl restart apache2

Set Up Nextcloud Web Server

  • Upon first access, you will see a setup page.

admin.png

  • Enter the following information:
Username --> Your desired usernamePassword --> Set a secure passwordData Folder --> Leave as defaultDatabase user --> nextcloudDatabase password --> Your database passwordDatabase name --> nextcloud
  • Install the recommended apps.

Optional: External Access

  • To access Nextcloud from outside your private network, enable port forwarding on your router.
  • Example configuration for a Movistar router:
  1. Find your private IP using:
ifconfig -a

ifconfig.png

  1. Configure port forwarding in your router settings, enabling port 80 for your IP.
  2. Verify port 80 is open:
sudo nmap -n -PN -sT -sU -p80 {IP}
  1. Check if the Nextcloud page is accessible by entering your public IP in a web browser.

untrusted.png

Extra Configuration

  • To access Nextcloud via your public IP, edit theconfig.php file:
sudo nvim /var/www/your.domain.name/config/config.php
  • Add your public IP to thetrusted_domains array.

trusted.png

Configure Your Domain

Set Up Namecheap

  1. In Advanced DNS settings, create a host record with your public IP.
  2. Edit theconfig.php file to add your domain to thetrusted_domains array.

namecheap_host.pngdomain_trusted.png

TLS Certificate

  • Installsnapd andcertbot:
sudo apt install snapdsudo snap install core&& sudo snap refresh coresudo snap install --classic certbotsudo ln -s /snap/bin/certbot /usr/bin/certbot
  • Obtain and install your certificates:
sudo certbot --apache

Troubleshooting

  • Search online forums for solutions.
  • For further assistance, contact me viaemail.

Resources

Please submit a pull request for any errors or suggestions.

About

Build your own self-hosted cloud storage with Nextcloud, with enhanced privacy and security for file management

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp