NextCloud: Difference between revisions
No edit summary |
No edit summary |
||
| Line 11: | Line 11: | ||
=== Download NextCloud on Ubuntu 20.04 === | === Download NextCloud on Ubuntu 20.04 === | ||
Log into your Ubuntu 20.04 server. Then download the NextCloud zip archive onto your server. The latest stable version is 21.0.1 at time of this writing. You may need to change the version number. Go to https://nextcloud.com/install and click the <code>download for server</code> button to see the latest version. | Log into your Ubuntu 20.04 server. Then download the NextCloud zip archive onto your server. The latest stable version is 21.0.1 at time of this writing. You may need to change the version number. Go to https://nextcloud.com/install and click the <code>download for server</code> button to see the latest version. | ||
You can run the following command to download it on your server.<syntaxhighlight lang="bash"> | You can run the following command to download it on your server. | ||
<syntaxhighlight lang="bash"> | |||
wget https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip | wget https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Once downloaded, extract the archive with <code>unzip</code>.<syntaxhighlight lang="bash"> | You can always use the above URL format to download NextCloud. If a new version comes out, simply replace <code>21.0.1</code> with the new version number. | ||
Once downloaded, extract the archive with <code>unzip</code>. | |||
<syntaxhighlight lang="bash"> | |||
sudo apt install unzip | sudo apt install unzip | ||
</syntaxhighlight><syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash"> | |||
sudo unzip nextcloud-21.0.1.zip -d /usr/share/nginx/ | sudo unzip nextcloud-21.0.1.zip -d /usr/share/nginx/ | ||
</syntaxhighlight>The <code>-d</code> option specifies the target directory. NextCloud web files will be extracted to <code>/usr/share/nginx/nextcloud/</code>. Then we need to change the owner of this directory to <code>www-data</code> so that the web server (Nginx) can write to this directory.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
The <code>-d</code> option specifies the target directory. NextCloud web files will be extracted to <code>/usr/share/nginx/nextcloud/</code>. Then we need to change the owner of this directory to <code>www-data</code> so that the web server (Nginx) can write to this directory. | |||
<syntaxhighlight lang="bash"> | |||
sudo chown www-data:www-data /usr/share/nginx/nextcloud/ -R | sudo chown www-data:www-data /usr/share/nginx/nextcloud/ -R | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Create a Database and User for Nextcloud in MariaDB Database Server === | === Create a Database and User for Nextcloud in MariaDB Database Server === | ||
Log into MariaDB database server with the following command. Since MariaDB is now using <code>unix_socket</code> plugin to authentication user login, there’s no need to enter MariaDB root password. We just need to prefix the <code>mysql</code> command with <code>sudo</code>.<syntaxhighlight lang="bash"> | Log into MariaDB database server with the following command. Since MariaDB is now using <code>unix_socket</code> plugin to authentication user login, there’s no need to enter MariaDB root password. We just need to prefix the <code>mysql</code> command with <code>sudo</code>. | ||
<syntaxhighlight lang="bash"> | |||
sudo mysql | sudo mysql | ||
</syntaxhighlight>Then create a database for Nextcloud. This tutorial name the database nextcloud. You can use whatever name you like.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
Then create a database for Nextcloud. This tutorial name the database nextcloud. You can use whatever name you like. | |||
<syntaxhighlight lang="bash"> | |||
create database nextcloud; | create database nextcloud; | ||
</syntaxhighlight>Create the database user. Again, you can use your preferred name for this user. Replace <code>your-password</code> with your preferred password.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
Create the database user. Again, you can use your preferred name for this user. Replace <code>your-password</code> with your preferred password. | |||
<syntaxhighlight lang="bash"> | |||
create user [/cdn-cgi/l/email-protection [email protected]] identified by 'your-password'; | create user [/cdn-cgi/l/email-protection [email protected]] identified by 'your-password'; | ||
</syntaxhighlight>Grant this user all privileges on the <code>nextcloud</code> database.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
Grant this user all privileges on the <code>nextcloud</code> database. | |||
<syntaxhighlight lang="bash"> | |||
grant all privileges on nextcloud.* to [/cdn-cgi/l/email-protection [email protected]] identified by 'your-password'; | grant all privileges on nextcloud.* to [/cdn-cgi/l/email-protection [email protected]] identified by 'your-password'; | ||
</syntaxhighlight>Flush privileges and exit.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
Flush privileges and exit. | |||
<syntaxhighlight lang="bash"> | |||
flush privileges; | flush privileges; | ||
</syntaxhighlight><syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash"> | |||
exit; | exit; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Create a Nginx Config File for Nextcloud === | === Create a Nginx Config File for Nextcloud === | ||
Create a <code>nextcloud.conf</code> file in <code>/etc/nginx/conf.d/</code> directory, with a command-line text editor like Nano.<syntaxhighlight lang="bash"> | Create a <code>nextcloud.conf</code> file in <code>/etc/nginx/conf.d/</code> directory, with a command-line text editor like Nano. | ||
<syntaxhighlight lang="bash"> | |||
sudo vim /etc/nginx/conf.d/nextcloud.conf | sudo vim /etc/nginx/conf.d/nextcloud.conf | ||
</syntaxhighlight>Copy and paste the following text into the file. Replace <code>nextcloud.example.com</code> with your own preferred sub-domain. Don’t forget to create DNS A record for this sub-domain in your DNS zone editor. If you don’t have a real domain name, I recommend going to NameCheap to buy one. The price is low and they give whois privacy protection free for life.<syntaxhighlight lang="nginx"> | </syntaxhighlight> | ||
Copy and paste the following text into the file. Replace <code>nextcloud.example.com</code> with your own preferred sub-domain. Don’t forget to create DNS A record for this sub-domain in your DNS zone editor. If you don’t have a real domain name, I recommend going to NameCheap to buy one. The price is low and they give whois privacy protection free for life. | |||
<syntaxhighlight lang="nginx"> | |||
server { | server { | ||
listen 80; | listen 80; | ||
| Line 154: | Line 192: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
Save and close the file. (To save a file in Nano text editor, press <code>Ctrl+O</code>, then press <code>Enter</code> to confirm. To exit, press <code>Ctrl+X</code>.) | |||
Then test Nginx configuration.<syntaxhighlight lang="bash"> | Then test Nginx configuration. | ||
<syntaxhighlight lang="bash"> | |||
sudo nginx -t | sudo nginx -t | ||
</syntaxhighlight>If the test is successful, reload Nginx for the changes to take effect.<syntaxhighlight lang="bash"> | </syntaxhighlight> | ||
If the test is successful, reload Nginx for the changes to take effect. | |||
<syntaxhighlight lang="bash"> | |||
sudo systemctl reload nginx | sudo systemctl reload nginx | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Install and Enable PHP Modules === | === Install and Enable PHP Modules === | ||
Run the following commands to install PHP modules required or recommended by NextCloud.<syntaxhighlight lang="bash"> | Run the following commands to install PHP modules required or recommended by NextCloud. | ||
<syntaxhighlight lang="bash"> | |||
sudo apt install imagemagick php-imagick php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp | sudo apt install imagemagick php-imagick php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Terkait == | == Terkait == | ||
* [[NextCloud:Disable server-side-encryption]] | * [[NextCloud:Disable server-side-encryption]] | ||
== Source == | == Source == | ||
* [https://www.linuxbabe.com/ubuntu/install-nextcloud-ubuntu-20-04-nginx-lemp-stack linuxbabe.com] | * [https://www.linuxbabe.com/ubuntu/install-nextcloud-ubuntu-20-04-nginx-lemp-stack linuxbabe.com] | ||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Linux]] | [[Category:Linux]] | ||