OwnCloud is suite of application client-server for creating hosting services, it is allow you to create your own cloud storage and allow you to share your data, contacts, calendar with other users and devices. OwnCloud is open source project that provides an easy way for you to sync and share your data that is hosted in your data center. it Has a beautiful and user-friendly front-end design, so that make a user easy for browse and access the data, then share to others users. OwnCloud an online secure enterprise file sync and file sharing.
In this tutorial, I will guide you a step by step to install owncloud 8, and we use Nginx(engine-X) as web server, php-fpm and mariaDB as the database system on FreeBSD 10.2.
Step 1 ) Installing Nginx php-fpm and MariaDB
In the previous tutorial, we had discussed about the installation FEMP (Nginx, MariaDB and PHP-FPM), but in this tutorial we will discuss briefly. We will install FEMP using pkg command.
Install Nginx :
pkg install nginx
Install MariaDB :
pkg install mariadb100-server-10.0.21 mariadb100-client-10.0.21
Install php-fpm and all the packages that needed by owncloud :
pkg install php56-extensions php56-mysql php56-pdo_mysql php56-zlib php56-openssl php56-bcmath php56-gmp php56-gd php56-curl php56-ldap php56-exif php56-fileinfo php56-mbstring php56-gmp php56-bz2 php56-zip php56-mcrypt pecl-APCu pecl-intl
Step 2 ) Configure Nginx php-fpm and MariaDB
Configure Nginx.
Leave nginx with default configuration. In this step you just need to add nginx to the startup with sysrc command, then start nginx :
sysrc nginx_enable=yes
service nginx start
And try access it with your browser.
Configure MariaDB
Copy mariadb configuration and add it to the startup.
cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
sysrc mysql_enable=yes
Start mariadb :
service mysql-server start
Next, Configure a password for mariadb :
mysql_secure_installation
Enter current password for root (enter for none):
#Just press Enter here
Change the root password? [Y/n] Y
#Type your password for mariadb here
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
and try log in to the mariadb/mysql server with command :
mysql -u root -p
YOUR PASSWORD
Configure PHP-FPM
Change the default listen to the unix socket and set the permission for it, and then configure php-fpm to running under user "www".
nano /usr/local/etc/php-fpm.conf
change the line like below :
listen = /var/run/php-fpm.sock
...
...
listen.owner = www
listen.group = www
listen.mode = 0660
And now configure and edit php.ini file :
cd /usr/local/etc/
cp php.ini-production php.ini
nano php.ini
change the cgi.fix_pathinfo line value to 0.
cgi.fix_pathinfo=0
and the last add php-fpm to the boot time and start it :
sysrc php_fpm_enable=yes
service php-fpm start
Step 3 ) Generate SSL Certificate for OwnCloud
Create new directory "cert" in the /usr/local/etc/nginx/ and please generate SSL certificate :
mkdir -p /usr/local/etc/nginx/cert/
cd /usr/local/etc/nginx/cert/
openssl req -new -x509 -days 365 -nodes -out /usr/local/etc/nginx/cert/owncloud.crt -keyout /usr/local/etc/nginx/cert/owncloud.key
Next, change the certificate permission to 600 :
chmod 600 *
Step 4 ) Create Database for OwnCloud
To create the database for owncloud, you must log in to the mysql/mariadb server use the password that had been set.
mysql -u root -p
YOUR PASSWORD
Create new database called "my_ownclouddb" :
create database my_ownclouddb;
And Create new user "myownclouduser" for the "my_ownclouddb" database :
create user myownclouduser@localhost identified by 'myownclouduser';
Next, Grant that user has been created to the "my_ownclouddb" database :
grant all privileges on my_ownclouddb.* to myownclouduser@localhost identified by 'myownclouduser';
flush privileges;
Step 5 ) Install and Configure OwnCloud
Go to the tmp directory and download owncloud from the official site with fetch command. I'm here use OwnCloud 8.1.3 - latest stable version.
cd /tmp/
fetch https://download.owncloud.org/community/owncloud-8.1.3.tar.bz2
Extract the owncloud and move owncloud directory to "/usr/local/www/".
tar -xzvf owncloud-8.1.3.tar.bz2
mv owncloud/ /usr/local/www/
Now create new directory "data" in the owncloud directory, and change the ownership of the file and directory to the "www" user that running nginx.
cd /usr/local/www/
mkdir -p /usr/local/www/owncloud/data
chown -R www:www owncloud/
Next, Configure the virtualhost for owncloud.
Move to the nginx configuration directory, and rename default nginx configuration file nginx.conf to nginx.conf.original.
cd /usr/local/etc/nginx/
mv nginx.cong nginx.conf.original
And create new configuration file for owncloud :
nano nginx.conf
Paste the following code :
worker_processes 2;
events {
worker_connections 1024;
}http {
include mime.types;
default_type application/octet-stream;
sendfile off;
keepalive_timeout 65;
gzip off;server {
listen 80;
server_name 192.168.1.114;#Force to the https
return 301 https://$server_name$request_uri;
}server {
listen 443 ssl;
server_name 192.168.1.114; #YourIP or domain#SSL Certificate you created
ssl_certificate /usr/local/etc/nginx/cert/owncloud.crt;
ssl_certificate_key /usr/local/etc/nginx/cert/owncloud.key;# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;root /usr/local/www/owncloud;
location = /robots.txt { allow all; access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ^~ / {
index index.php;
try_files $uri $uri/ /index.php$is_args$args;
fastcgi_intercept_errors on;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
client_max_body_size 512M;
fastcgi_buffers 64 4K;
location ~ ^/(?:\.|data|config|db_structure\.xml|README) {
deny all;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
include fastcgi_params;
fastcgi_param modHeadersAvailable true;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
}
location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
expires 30d;
add_header Cache-Control public;
access_log off;
}
location ^~ /data {
internal;
alias /mnt/files;
}
}
}
}
Save and Exit.
Next, test nginx configuration with command "nginx -t", if there is no error, please restart nginx and php-fpm :
nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successfulservice php-fpm restart
service nginx restart
Visit the server IP or the domain name with your browser :
http://owncloud.local - will force to the https, so please confirm the ssl certificate.
And create admin user for owncloud, fill with your username and password. Then fill the database configuration, and fill it with a database that has been configured in the previous step.
And click "Finish Setup".
Step 6 ) Testing
Visit the http://192.168.1.114/, then login with username and password that have been configured.
So we have successfully install and configure owncloud 8.1.3 on FreeBSD 10.2 with SSL and Nginx webserver.
Conclusion
OwnCloud an open-source project that makes it easy for users to store and exchange data on cloud computing. We can install ownCloud on our servers, so that we ourselves can organize the data that has been stored on our server easily and safely. This is a good solution for the convenience and security of data (Because the data is in our own) for its users. OwnCloud easily installed and configured on the server.
The post How to Install OwnCloud 8 with Nginx and SSL on FreeBSD 10.2 appeared first on LinOxide.