Advertising:

Instalación de Mediawiki en CentOS 7 + PHP56 + MariaDB

From Zabbix-ES
Jump to navigation Jump to search

Instalacion de paquetes necesarios

# yum -y install http://rpms.famillecollet.com/enterprise/7/remi/x86_64/remi-release-7.3-2.el7.remi.noarch.rpm
# yum -y install centos-release-scl
# yum -y install yum-utils
# yum -y install mariadb-server mariadb httpd
# yum -y install php56 php56-php php56-php-curl php56-php-mbstring php56-php-json php56-php-gd php56-php-mysql php56-php-mysqlnd php56-php-zlib php56-php-ftp php56-php-xml php56-php-intl php56-php-xcache
# yum -y install texlive ImageMagick

Configuracion de MariaDB

Preconfiguracion

# systemctl enable mariadb
# systemctl start mariadb
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <ENTER SIN PSW>
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: <PASSWORD>
Re-enter new password: <PASSWORD>
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Creacion de Base de datos y Usuario

# mysql -u root -p
Enter password: <PASSWORD>
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER 'wiki'@'localhost' IDENTIFIED BY '<WIKI_USER_PASSWORD>';
MariaDB [(none)]> CREATE DATABASE wikidatabase; 
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wikidatabase.* TO 'wiki'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wikidatabase       |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]>  SHOW GRANTS FOR 'wiki'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for wiki@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wiki'@'localhost' IDENTIFIED BY PASSWORD '*2E9DB5B9A590D4FBDBF4D2C87B66AB176A1ED306' |
| GRANT ALL PRIVILEGES ON `wikidatabase`.* TO 'wiki'@'localhost'                                              |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> exit

Instalacion de Mediawiki

# cd /var/www
# wget http://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.2.tar.gz
# tar zxvf mediawiki-*
# ln -s mediawiki-1.29.2/ mediawiki
# rm -f mediawiki-1.29.2.tar.gz
# systemctl restart mariadb
# systemctl enable httpd
# systemctl start httpd
# vi /var/www/mediawiki/images/.htaccess
# Serve HTML as plaintext, don't execute SHTML
AddType text/plain .html .htm .shtml .phtml .php .php3 .php4 .php5 .php7

# Old way of registering php with AddHandler
RemoveHandler .php

# Recent way of registering php with SetHandler
<FilesMatch "\.ph(p[3457]?s?|tml)$">
   SetHandler None
</FilesMatch>
# vi /etc/httpd/conf.d/mediawiki.conf
Alias /mediawiki "/var/www/mediawiki"
 
<Directory "/var/www/mediawiki">
   DirectoryIndex index.htm index.html index.php
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

# systemctl enable httpd
# systemctl restart httpd

Configuracion General

# cd /var/www/mediawiki/extensions
# wget https://extdist.wmflabs.org/dist/extensions/LdapAuthentication-REL1_29-4c9bdab.tar.gz
# tar ztvf LdapAuthentication-REL1_29-4c9bdab.tar.gz
# rm -f LdapAuthentication-REL1_29-4c9bdab.tar.gz
# vi ../LocalSettings.php 
# FileUpload
$wgEnableUploads = true;
$wgUploadPath = "$wgScriptPath/images";
$wgStrictFileExtensions = true;
$wgMaxUploadSize = 2147483647;
$wgUploadSizeWarning = 2147483647;
$wgUseInstantCommons = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgFileExtensions = array('png','gif','jpg','jpeg','svg','pdf','zip','doc','docx','xls','xlsx','odt','ods','txt','odp','tgz','gzip','gz','rar','tar','xml');

#AUTENTICACION LDAP
require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );
$wgAuth = new LdapAuthenticationPlugin();
$wgLDAPDomainNames = array("globalia.com");
$wgLDAPServerNames = array("globalia.com"=>"192.168.150.15");
$wgLDAPUseLocal = true;
$wgLDAPDebug = 6;
#$wgDebugLogGroups["ldap"] = "/tmp/ldapdebug.log" ;
$wgLDAPEncryptionType = array("globalia.com"=>"clear");
$wgLDAPBaseDNs = array("globalia.com"=>"dc=globalia,dc=com");
$wgLDAPSearchAttributes = array("globalia.com"=>"uid");
$wgLDAPSearchStrings = array("globalia.com" => "USER-NAME@globalia.com");
$wgLDAPGroupsPrevail = array("globalia.com"=>true);
$wgLDAPGroupNameAttribute = array("globalia.com"=>"cn");
$wgShowDBErrorBacktrace = true;

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['upload'] = true;
$wgGroupPermissions['*']['reupload'] = true;
# cd /var/www
# chown -R apache:apache mediawiki
# cd /var/www/mediawiki/maintenance
# php56 update.php

Crear los Virtual Hosts en Apache

# mkdir /etc/httpd/sites-available
# mkdir /etc/httpd/sites-enabled
# vi /etc/httpd/conf/httpd.conf
  IncludeOptional sites-enabled/*.conf
# vi /etc/httpd/sites-available/wiki.meetandcomm.org.conf
<VirtualHost wiki.meetandcomm.org:80>
    ServerName wiki.meetandcomm.org
    ServerAlias wiki.meetandcomm.org
    DocumentRoot /var/www/mediawiki
    ErrorLog /var/log/httpd/wiki.meetandcomm.error.log
    CustomLog /var/log/httpd/wiki.meetandcomm.requests.log combined
</VirtualHost>

Alias /mediawiki "/var/www/mediawiki"
 
<Directory "/var/www/mediawiki">
   DirectoryIndex index.htm index.html index.php
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
# ln -s  /etc/httpd/sites-available/wiki.meetandcomm.org.conf /etc/httpd/sites-enabled/wiki.meetandcomm.org.conf
# systemctl restart httpd && systemctl status httpd

Personalizacion

 http://10.151.0.73/mediawiki/index.php/MediaWiki:Vector.css
/* El CSS colocado en esta página afectará a los usuarios que usen la apariencia "Vector" */
/* Bring the text to 14px */
#bodyContent {
  font-size: 0.8em;
}


Para finalizar la instalacion nos conectamos via WEB http://IP_ADDRES/mediawiki y seguimos los pasos indicados.