New users looking for help installing the latest version of NextCloud Server (17) from Github using Composer with Apache2, MariaDB and PHP 7.2 support, the steps below should be a great place to start…

When you use Composer to install NextCloud packages, you can easily upgrade from the commmand line with Composer, which is much simpler…

To upgrade NextCloud, you must manually upgrade its core files and other packages when new versions are available…. and doing that using its starndard method can be challenging for some users…

This brief tutorial is going to show students and new users how to install / upgrade NextCloud from Github repository via Composer with Apache2, MariaDB and PHP 7.2 support on Ubuntu 16.04 | 18.04 LTS servers…

To get started with installing NextCloud, follow the steps below:

Step 1: Install Apache2 HTTP Server on Ubuntu.

Apache2 HTTP Server is the most popular web server in use… so install it since NextCloud needs it..

To install Apache2 HTTP on Ubuntu server, run the commands below…

sudo apt update
sudo apt install apache2

After installing Apache2, the commands below can be used to stop, start and enable Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

To test Apache2 setup, open your browser and browse to the server hostname or IP address and you should see Apache2 default test page as shown below.. When you see that, then Apache2 is working as expected..

http://localhost or use the ip addres of your ubuntu server.

apache2 ubuntu install

Step 2: Install MariaDB Database Server

MariaDB database server is a great place to start when looking at open source database servers to use with Magento… To install MariaDB run the commands below…

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots..

Run these on Ubuntu 16.04 LTS

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Run these on Ubuntu 18.04 and 18.10 LTS

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

To test if MariaDB is installed, type the commands below to logon to MariaDB server

sudo mysql -u root -p

Then type the password you created above to sign on… if successful, you should see MariaDB welcome message

mariadb welcome

Step 3: Install PHP 7.2 and Related Modules

PHP 7.2 may not be available in Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.

Run the commands below to add the below third party repository to upgrade to PHP 7.2

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.2

sudo apt update

Next, run the commands below to install PHP 7.2 and related modules.

sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

After installing PHP 7.2, run the commands below to open PHP default config file for Apache2…

sudo nano /etc/php/7.2/apache2/php.ini

Then make the changes on the following lines below in the file and save. The value below are great settings to apply in your environments. (not neccesary)

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360

After making the change above, save the file and close out.

Step 4: Restart Apache2

After installing PHP and related modules, all you have to do is restart Apache2 to reload PHP configurations…

To restart Apache2, run the commands below

sudo systemctl restart apache2.service

To test PHP 7.2 settings with Apache2, create a phpinfo.php file in Apache2 root directory by running the commands below

sudo nano /var/www/html/phpinfo.php

Then type the content below and save the file.

<?php phpinfo( ); ?>

Save the file.. then browse to your server hostname followed by /phpinfo.php

http://localhost/phpinfo.php

You should see PHP default test page…

PHP 7.2 ubuntu nginx

Step 5: Create NextCloud Database

Now that you’ve installed all the packages that are required for NextCloud to function, continue below to start configuring the servers. First run the commands below to create a blank NextClouddatabase.

To logon to MariaDB database server, run the commands below.

sudo mysql -u root -p

Then create a database called nextcloud

CREATE DATABASE nextcloud;

Create a database user called nextclouduser with new password

CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the database.

GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 6: Download NextCloud Latest Release

To get NextCloud latest release you may want to use Github repository… Install Composer, Curl and other dependencies to get started…

sudo apt install curl git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

After installing curl and Composer above, change into the Apache2 root directory and downaload NextCloud packages from Github… Always replace the branch number with the latest branch….

cd /var/www/html
sudo git clone --branch stable17 https://github.com/nextcloud/server.git nextcloud
cd /var/www/html/nextcloud
sudo composer install
sudo git submodule update --init

Then run the commands below to set the correct permissions for NextCloud to function.

sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

Step 7: Configure Apache2

Finally, configure Apahce2 site configuration file for NextCloud. This file will control how users access NextCloud content. Run the commands below to create a new configuration file called nextcloud.conf

sudo nano /etc/apache2/sites-available/nextcloud.conf

Then copy and paste the content below into the file and save it. Replace servername and server aliias with your own domain name and directory root location.

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud/
     ServerName example.com
     ServerAlias www.example.com
  
     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the file and exit.

Step 8: Enable the NextCloud and Rewrite Module

After configuring the VirtualHost above, enable it by running the commands below

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Step 9 : Restart Apache2

To load all the settings above, restart Apache2 by running the commands below.

sudo systemctl restart apache2.service

Then open your browser and browse to the server domain name. You should see NextCloud setup wizard to complete. Please follow the wizard carefully.

http://example.com/nextcloud or type use http://your-ip-adress/nextcloud

Then create an admin account for NextCloud and type in the database info created above and finish the installation….

NextCloud ubuntu composer install

Enjoy!

nextcloud ubuntu composer install

Congratulation! You have successfully installed NextCloud on Ubuntu 16.04 | 18.04 and may work on upcoming 18.10…

Upgrading NextCloud

In the future when you want to upgrade to a new released version, simply follow the steps below:

Backup your corrent NextCloud folder….

sudo mv /var/www/html/nextcloud /var/www/html/nextcloud_bak

Then download the latest… replace the stable number with the latest…

cd /var/www/html
sudo git clone --branch stable14 https://github.com/nextcloud/server.git nextcloud
cd /var/www/html/nextcloud
sudo composer install
sudo git submodule update --init

Next, copy the old data folder and the old config.php file from the backed-up folder to the new NextCloud directory….

sudo cp -rf /var/www/html/nextcloud_bak/data /var/www/html/nextcloud
sudo cp /var/www/html/nextcloud_bak/config/config.php /var/www/html/nextcloud/config/

After that, run the commands below to upgrade….

sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --on
sudo composer update /var/www/html/nextcloud --with-dependencies
sudo -u www-data php /var/www/html/nextcloud/occ upgrade
sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --off

That’s it!

You may also like the post below:

By Ryan123

47 thoughts on “Install NextCloud Server Using Composer On Ubuntu 16.04 | 18.04 With Apache2, MariaDB And PHP 7.2 Support”
  1. Good day! I simply would like to offer you a huge
    thumbs up for your excellent info you have right here on this post.
    I am coming back to your web site for more soon.

  2. Hi there to every one, the contents present at this website
    are actually amazing for people experience, well, keep up the good work fellows.

  3. Amazing blog! Do you have any suggestions for
    aspiring writers? I’m hoping to start my own site soon but
    I’m a little lost on everything. Would you advise starting with a free platform like WordPress or
    go for a paid option? There are so many options out there that I’m totally confused ..
    Any tips? Appreciate it!

    1. I would go for WordPress at least in the beginning and have it hosted by a hosting company. WordPress gives you the option to easily manage your post, the only downside is that you do get limited by some themes and you have to make sure your WordPress is up-to-date all the time because of security patches that happen frequently.
      I might create a separate blog post just for you. 🙂

  4. I like the helpful info you provide in your articles. I will
    bookmark your weblog and check again here frequently. I am
    quite sure I’ll learn lots of new stuff right here! Best of
    luck for the next!

  5. Greetings from California! I’m bored at work so I decided to check out your blog on my iphone during lunch break.
    I enjoy the info you provide here and can’t wait to take a look when I get home.
    I’m shocked at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyways, great site!

  6. Thank you for letting me know. I am sorry I can’t help you with these questions, I didn’t even know I was on their

  7. What I normally do is just write down some points that I need in my article, just remember you can always go back and change items.

  8. Wow that was odd. I just wrote an really long comment but after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over
    again. Anyway, just wanted to say excellent blog!

  9. First of all I want to say awesome blog! I had a quick question that I’d like to ask if you do not mind.
    I was interested to find out how you center yourself and clear your thoughts prior to writing.

    I have had a hard time clearing my thoughts in getting my thoughts out there.
    I truly do take pleasure in writing but it just seems like the first
    10 to 15 minutes tend to be wasted just trying to figure out how to begin.
    Any recommendations or tips? Appreciate it!

  10. Hi! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m absolutely enjoying your blog and look forward to new updates.

  11. Hi, this weekend is pleasant for me, for the reason that this point in time i am reading this great informative post here at my
    home.

  12. I like what you guys are up too. This kind of clever work and exposure!
    Keep up the fantastic works guys I’ve added you guys to
    our blogroll.

  13. My spouse and I stumbled over here different website and thought I may as well
    check things out. I like what I see so now i’m following you.

    Look forward to checking out your web page again.

  14. Currently it appears like WordPress is the top blogging platform available
    right now. (from what I’ve read) Is that what you’re using on your blog?

  15. These are really fantastic ideas in concerning
    blogging. You have touched some nice factors here. Any way keep up wrinting.

  16. I seriously love your website.. Excellent colors & theme.
    Did you make this site yourself? Please reply back as I’m attempting to
    create my own blog and would love to find out where you got
    this from or just what the theme is called. Cheers!

  17. It’s a shame you don’t have a donate button! I’d certainly donate to this
    brilliant blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my
    Google account. I look forward to fresh updates and will talk about this blog with
    my Facebook group. Talk soon!

  18. Good web site you have got here.. It’s difficult to find good quality writing like yours these days.
    I really appreciate individuals like you! Take care!!

  19. Thanks in support of sharing such a pleasant opinion,
    piece of writing is fastidious, thats why i have read it completely

  20. Greetings! Very helpful advice within this post! It is the little changes that make the
    largest changes. Many thanks for sharing!

  21. What’s up colleagues, how is everything, and
    what you desire to say about this piece of writing,
    in my view its actually remarkable for me.

  22. We are a group of volunteers and opening a new scheme in our
    community. Your web site offered us with valuable information to work on. You have
    done a formidable job and our whole community will be grateful to you.

  23. Hi my friend! I wish to say that this article is awesome, great written and include almost all vital infos.
    I’d like to see extra posts like this .

  24. It’s impressive that you are getting thoughts from this piece of
    writing as well as from our dialogue made at this time.

  25. Thanks , I have recently been looking for info approximately this subject for ages and
    yours is the greatest I’ve came upon till
    now. However, what in regards to the conclusion? Are you sure
    in regards to the source?

  26. You actually make it seem so easy with your presentation but I find this matter to be really
    something which I think I would never understand.
    It seems too complex and very broad for me. I’m looking
    forward for your next post, I’ll try to get the hang of it!

  27. Hello I am so grateful I found your blog, I really found you by
    error, while I was researching on Yahoo for something else, Nonetheless I am here now and would just
    like to say cheers for a tremendous post and a all round enjoyable blog (I also love the theme/design), I don’t have time to read through it all at the moment but
    I have bookmarked it and also included your RSS feeds,
    so when I have time I will be back to read more, Please do keep up the awesome jo.

  28. I used to be recommended this website by means of my cousin. I’m not positive whether this post is written by way of him as no one else
    understand such distinctive approximately my problem. You are amazing!
    Thanks!

  29. I just like the valuable info you provide in your articles.
    I will bookmark your blog and check again here regularly.
    I am quite sure I will be informed lots of new stuff right right here!

    Good luck for the following!

  30. Hi! This post could not be written any better! Reading this post reminds me of my old room mate!

    He always kept talking about this. I will forward this post to him.
    Fairly certain he will have a good read. Many thanks for sharing!

  31. I am really enjoying the theme/design of your weblog.
    Do you ever run into any internet browser compatibility problems?
    A handful of my blog audience have complained about my
    site not operating correctly in Explorer but looks
    great in Opera. Do you have any recommendations
    to help fix this problem?

  32. Greetings! Very useful advice in this particular post!
    It is the little changes which will make the greatest changes.
    Thanks for sharing!

  33. Great post. I used to be checking constantly this blog and I
    am inspired! Very helpful info specially the ultimate part 🙂
    I maintain such information much. I used to be looking for this certain information for a long time.
    Thanks and good luck.

  34. I every time spent my half an hour to read this weblog’s
    articles daily along with a cup of coffee.

Leave a Reply

Your email address will not be published. Required fields are marked *