Friday, December 19, 2014

Installing Pydio 6 on CentOS 7

I am going to start this blog with this article, which describes the needed steps to install Pydio on a CentOS 7.

Right now there is no howto in http://pyd.io regarding this OS version, so I think it may be interesting. It is based on this existing howto. However you need to change some small things in order for it to work with CentOS 7.

I have used the minimal install from the iso named CentOS-7.0-1406-x86_64-DVD.iso .

First things first,

 yum install wget  

Next step is providing the installation dependencies for Pydio,

 wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm  
 wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm  
 rpm -Uvh remi-release-7.rpm epel-release-7*.rpm  
 yum update  


The following command will install PHP and its dependencies:

 yum install php php-apc php-mbstring php-pecl-apc php-mysql php-cli php-devel php-gd php-ldap php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml php-imap php-mcrypt*  


Now you have to edit /etc/php.ini to change some parameters for Pydio to work properly. With vi or your preferred editor,

  • Change output_buffering = 4096 to output_buffering = Off
  • Change post_max_size = 8M to post_max_size = 1024M
  • Change upload_max_filesize = 2M to upload_max_filesize = 1024M

Next is installing and configuring MariaDB. It will start on boot.

 yum install mariadb-server  
 systemctl start mariadb.service  
 systemctl enable mariadb.service  
 /usr/bin/mysql_secure_installation  

The last command is a wizard in which you can set the MySQL root password and some security settings more, like removing the anonymous user. The first question is the current root password, which is none so just press Enter.

Then you have to create the Pydio database, with the mysql command tool.

 mysql -u root -p  


It will ask you for the password you have just set, hopefully.

Then enter the following SQL commands at the prompt to create the database and the Pydio user for the database.

 create database pydio;  
 create user pydio@localhost identified by 'mysqlpassword';  
 grant all privileges on pydio.* to pydio@localhost identified by 'mysqlpassword' with grant option;  


... where mysqlpassword is the Pydio database user password. CTRL-d to exit.

Next step is installing Apache and mod_ssl. In my CentOS minimal installation Apache was already installed. And enabling the service to start on boot.

 yum install httpd  
 yum install openssl mod_ssl  
 systemctl start httpd.service  
 systemctl enable httpd.service  

The following command will create a self-signed certificate for Pydio. As it is self-signed, browsers will issue a warning but whatever. It will last for 3650 days.

 openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/pki/tls/private/pydio.key -out /etc/pki/tls/certs/pydio.crt  

You will be prompted with some questions about location, organization name and so on.

Next commands are to tell Apache about the paths to the certificate files we have just created.

 sed -i "s/localhost.crt/pydio.crt/g" /etc/httpd/conf.d/ssl.conf  
 sed -i "s/localhost.key/pydio.key/g" /etc/httpd/conf.d/ssl.conf  

Next commands are for installing Pydio.

 rpm -Uvh http://dl.ajaxplorer.info/repos/pydio-release-1-1.noarch.rpm  
 yum update  
 yum --disablerepo=pydio-testing install pydio  

Now we have to edit the Pydio .conf file for Apache because CentOS 7 installs Apache 2.4, and the default .conf has two directives which are no longed valid. If you don't to this, you will get a 403 Forbidden error if you try to access Pydio.

Edit /etc/httpd/conf.d/pydio.conf and delete the following lines:

 Order allow,deny  
 Allow from all  

... and put this one instead of them:

 Require all granted  

Restart Apache:

 systemctl restart httpd.service  

And some commands to harden the file security. /usr/share/pydio is the default Pydio installation path.

 chown -R root:apache /usr/share/pydio  
 cd /usr/share/pydio  
 find ./ -type d -exec chmod u=rwx,g=rx,o= '{}' \;  
 find ./ -type f -exec chmod u=rw,g=r,o= '{}' \;  
 chown -R apache:apache /var/lib/pydio  
 cd /var/lib/pydio  
 find ./ -type d -exec chmod u=rwx,g=rx,o= '{}' \;  
 find ./ -type f -exec chmod u=rw,g=r,o= '{}' \;  


Last find commands are not going to be very useful as Apache will write files with 644 mask. Have a look at this to configure SELinux.

And that's all! Browse to http://yourserver/pydio or better https://yourserver/pydio . If you are browsing from another computer you will need to open the web server ports in the firewall, or if you are in a hurry to test just disable the firewall service,

 systemctl stop firewalld.service \;  



Voy a comenzar mi blog con este artículo, que describe los pasos necesarios para instalar Pydio en una CentOS 7.

En el momento de escribir esto no hay un howto en la web oficial http://pyd.io para esta versión de CentOS, así que creo que puede ser interesante. Me baso en este howto ya existente, cambiando ciertas cosas para que funcione en CentOS 7.

He usado la "minimal install" del iso CentOS-7.0-1406-x86_64-DVD.iso .

Lo primero es lo primero,

 yum install wget  


En el paso siguiente proporcionamos las dependencias de instalación de Pydio,

 wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm  
 wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm  
 rpm -Uvh remi-release-7.rpm epel-release-7*.rpm  
 yum update  


El comando siguiente instala PHP y sus dependencias:

 yum install php php-apc php-mbstring php-pecl-apc php-mysql php-cli php-devel php-gd php-ldap php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml php-imap php-mcrypt*  


Ahora hay que editar el /etc/php.ini para cambiar algunos parámetros que Pydio necesita para funcionar correctamente. Con vi o tu editor preferido,

  • Cambia output_buffering = 4096 a output_buffering = Off
  • Cambia post_max_size = 8M a post_max_size = 1024M
  • Cambia upload_max_filesize = 2M a upload_max_filesize = 1024M
Ahora se instala y configura MariaDB. Arrancará en el botado.

 yum install mariadb-server  
 systemctl start mariadb.service  
 systemctl enable mariadb.service  
 /usr/bin/mysql_secure_installation  

El último comando es un wizard en el que se establece la contraseña de root de MySQL y algunos settings más, como quitar el usuario anónimo. La primera pregunta es la contraseña de root actual, que es nula, así que pulsa Enter.

Ahora se crea la base de datos de Pydio, con la utilidad de línea de comandos mysql.

 mysql -u root -p  


Te preguntará por la contraseña de root que acabas de poner.

A continuación introduce los siguientes comandos en el prompt SQL para crear la base de datos y el usuario de Pydio de base de datos.

 create database pydio;  
 create user pydio@localhost identified by 'mysqlpassword';  
 grant all privileges on pydio.* to pydio@localhost identified by 'mysqlpassword' with grant option;  


... donde mysqlpassword es la contraseña del usuario de base de datos de Pydio. CTRL-d para salir.

El siguiente paso es instalar Apache y el mod_ssl. En mi instalación mínima de CentOS el Apache ya estaba instalado. Y habilitamos el servicio para que arranque en el botado.
 yum install httpd  
 yum install openssl mod_ssl  
 systemctl start httpd.service  
 systemctl enable httpd.service  

El siguiente comando creará un certificado auto-firmado para Pydio. Como está auto-firmado, los navegadores mostrarán una advertencia, pero da igual. Durará 3650 días.

 openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/pki/tls/private/pydio.key -out /etc/pki/tls/certs/pydio.crt  

Te preguntará ubicación, nombre de la organización, y algunas cosas más.

Los siguientes comandos son para decirle a Apache sobre las rutas a los archivos de certificado que acabamos de crear.
 sed -i "s/localhost.crt/pydio.crt/g" /etc/httpd/conf.d/ssl.conf  
 sed -i "s/localhost.key/pydio.key/g" /etc/httpd/conf.d/ssl.conf  

Los siguientes comandos instalan Pydio.

 rpm -Uvh http://dl.ajaxplorer.info/repos/pydio-release-1-1.noarch.rpm  
 yum update  
 yum --disablerepo=pydio-testing install pydio  

Ahora tenemos que edir el fichero .conf de Pydio para Apache porque CentOS 7 instala Apache 2.4, y el fichero .conf de por defecto tiene dos directivas que ya no son válidas para esta versión. Si no se hace esto, en vez de la web de Pydio aparecerán errores 403 Forbidden.

Edita
 Order allow,deny  
 Allow from all  

... y pon esta en su lugar:

 Require all granted  

Reiniciar Apache:

 systemctl restart httpd.service  

Y ahora, unos comandos para fortalecer la seguridad a nivel de fichero. /usr/share/pydio es la ruta por defecto de instalación de Pydio

 chown -R root:apache /usr/share/pydio  
 cd /usr/share/pydio  
 find ./ -type d -exec chmod u=rwx,g=rx,o= '{}' \;  
 find ./ -type f -exec chmod u=rw,g=r,o= '{}' \;  
 chown -R apache:apache /var/lib/pydio  
 cd /var/lib/pydio  
 find ./ -type d -exec chmod u=rwx,g=rx,o= '{}' \;  
 find ./ -type f -exec chmod u=rw,g=r,o= '{}' \;  


Los últimos comandos find no van a ser muy útiles ya que Apache escribirá ficheros con la máscara 644. Échale un vistazo a esto para configurar SELinux.

¡Y eso es todo! Navega a http://tuservidor/pydio o mejor a https://tuservidor/pydio . Si estás accediendo desde otro ordenador necesitarás abrir los puertos para servicio web en el firewall, o si tienes prisa por probarlo sólo deshabilita el firewall,

 systemctl stop firewalld.service \;  

No comments:

Post a Comment