Installing OwnCloud 7 with Nginx and PHP-FPM on an Ubuntu VPS is an easy task if you follow this tutorial. OwnCloud is a web based application that provides services such as file storage, management and sharing. Using OwnCloud you can sync and share your files, calendar, contacts and much more. Everything will be accessible from all your devices from anywhere.
In this tutorial we will install the latest version of OwnCloud with Nginx and PHP-FPM on an Ubuntu VPS.
First of all, log in to your server as root and make sure that your Ubuntu Linux VPS is fully up to date
apt-get update apt-get upgrade
Install MariaDB on your server
apt-get install mariadb-server
Run the following script to secure your MariaDB server and set a root password
mysql_secure_installation - Set root password? [Y/n] y - 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
Now, log in to your MariaDB server as user root and create a new user and database for OwnCloud.
mysql -u root -p Enter password: MariaDB [(none)]> CREATE DATABASE owncloud; MariaDB [(none)]> GRANT ALL ON owncloud.* to ownclouduser@localhost identified by 'YOURPASSWORD'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
Do not forget to change YOURPASSWORD with an actual strong password.
Install Nginx web server, PHP5-FPM and few additional PHP packages
apt-get install nginx php5-fpm php5-common php5-cli php5-json php5-mysql php5-curl php5-intl php5-mcrypt php5-memcache php5-gd
Now, download the latest stable OwnCloud release from their official website. At the moment of writing this article it is version 7.0.3
cd /opt/ wget https://download.owncloud.org/community/owncloud-7.0.3.tar.bz2
Unpack the downloaded file
tar -jxvf owncloud-7.0.3.tar.bz2
OwnCloud’s files will be unpacked in a new ‘owncloud’ directory under ‘/opt’. Change the owner of the directory
chown -R www-data:www-data /opt/owncloud
Create a new virtual block for your domain with the following content
nano /etc/nginx/sites-available/yourdomain.tld server { listen 80; server_name yourdomain.tld www.yourdomain.tld; root /opt/owncloud; index index.php; rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; error_page 403 /core/templates/403.php; error_page 404 /core/templates/404.php; location = /robots.txt { allow all; log_not_found off; access_log off; } location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){ deny all; } location / { rewrite ^/.well-known/host-meta /public.php?service=host-meta last; rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
Enable the server block executing the following command
ln -s /etc/nginx/sites-available/yourdomain.tld /etc/nginx/sites-enabled/
Open the /etc/php5/fpm/pool.d/www.conf file and change the ‘listen’ variable as you see below:
listen = 127.0.0.1:9000;
Restart Nginx and PHP-FPM for the changes to take effect
service nginx restart service php5-fpm restart
Finally, head your browser to http:yourdomain.tld where you will need to create an admin account and the information of the MariaDB we’ve created in this tutorial. With this step the installation of OwnCloud 7 is completed.
Of course you don’t have to Install OwnCloud 7 with Nginx and PHP-FPM on Ubuntu, if you use one of our OwnCloud Optimized Linux Hosting services, in which case you can simply ask our expert Linux admins to install OwnCloud 7 with Nginx for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.