{"id":17219967,"url":"https://github.com/silvae86/semanticmediawiki-install","last_synced_at":"2025-03-25T15:25:33.161Z","repository":{"id":150043000,"uuid":"69887451","full_name":"silvae86/semanticmediawiki-install","owner":"silvae86","description":"Step by step Semantic Mediawiki Installation guide using Ubuntu 18.04, PHP 7.2 and all that stuff","archived":false,"fork":false,"pushed_at":"2018-11-06T22:59:51.000Z","size":7430,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T13:43:06.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silvae86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-03T16:07:07.000Z","updated_at":"2018-11-06T22:59:53.000Z","dependencies_parsed_at":"2023-04-12T14:31:18.253Z","dependency_job_id":null,"html_url":"https://github.com/silvae86/semanticmediawiki-install","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvae86%2Fsemanticmediawiki-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvae86%2Fsemanticmediawiki-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvae86%2Fsemanticmediawiki-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvae86%2Fsemanticmediawiki-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silvae86","download_url":"https://codeload.github.com/silvae86/semanticmediawiki-install/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245487497,"owners_count":20623436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T03:51:14.432Z","updated_at":"2025-03-25T15:25:33.115Z","avatar_url":"https://github.com/silvae86.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## How to install Semantic MediaWiki on Ubuntu 18.04 LTS\n\nOriginal repository with scripts for installation: https://github.com/silvae86/semanticmediawiki-install\n\nThis is intended as a record of my installations of [Semantic MediaWiki](https://en.wikipedia.org/wiki/Semantic_MediaWiki) for the course of Information Management and Collaboration that I teach at the [Master in Information Science](https://sigarra.up.pt/feup/en/cur_geral.cur_view?pv_curso_id=737) at [FEUP](https://sigarra.up.pt/feup/en/web_page.Inicial).\n\nIt can also be used by anyone who needs to install a Semantic MediaWiki instance from scratch.\n\n## Pre-requisites\n\nA fresh Ubuntu machine (I am using 18.04 LTS on a Virtual Machine at the moment).\n\n## Dependencies\n\nSemantic MediaWiki needs MySQL, Apache2, PHP, Inkscape and others. We will install these as part of the process, as well as SendMail to be able to notify people when they register and to be able to recover passwords.\n\n## Installation of MediaWiki\n\nBefore we can install the Semantic extension we need to install the base MediaWiki software.\n\n### Set up some variables for the installation\n\nFirst is necessary to set up some preliminary values that will be used later in the script. Remember, if you close the current terminal session you will have to set them up again.\n\n```bash\nMYSQL_PASSWORD=\"FIXME__PASSWORD\"\nHOST=\"gcc-mci.fe.up.pt\"\necho $HOST\nADDRESS=\"http://${HOST}\"\necho $ADDRESS\n```\n\n1. The default root password for MySQL (keep it safe!)\n2. The host name of the machine you are configuring\n3. The internet address of the machine.\n\n**Replace these with what you need before typing Enter in the terminal!**\n\n### Some cleanup\n\n```bash\nsudo dpkg --configure -a\nsudo apt-get -y -qq update\nsudo apt-get -y -qq upgrade\n```\n\n### Install SendMail\n\n```bash\n#install sendmail\nsudo apt-get update\nsudo apt-get install -y -qq sendmail\n```\n\n### Install Apache2, PHP and MySQL Client and other dependencies\n\n```bash\nsudo apt-get -y -f -qq install wget apache2 php php-mysql libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli mysql-client-5.7\n```\n\n### Install MySQL Server and set password automatically\n\n```bash\nsudo apt-get -y -f -qq install debconf-utils\ndebconf-set-selections \u003c\u003c\u003c \"mysql-server mysql-server/root_password password ${MYSQL_PASSWORD}\"\ndebconf-set-selections \u003c\u003c\u003c \"mysql-server mysql-server/root_password_again password ${MYSQL_PASSWORD}\"\napt-get update\nsudo apt-get -y install mysql-server\n#will try to login using the root password\nmysql -u root -p${MYSQL_PASSWORD}\n# you should see the mysql prompt\n```\n\n### Download MediaWiki and move it to installation directory\n\n```bash\nmkdir -p Downloads\ncd Downloads\nsudo wget --progress=bar:force https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.1.tar.gz\ntar -xvzf ./mediawiki-1.31.1.tar.gz\nsudo rm -rf /var/lib/mediawiki\nsudo mkdir -p /var/lib/mediawiki\nsudo mv mediawiki-1.31.1/* /var/lib/mediawiki\ncd /var/www/html\nsudo ln -s /var/lib/mediawiki mediawiki\ncd -\nls /var/www/html/mediawiki # You should see a file listing after these commands are run. It is the contents of mediawiki correctly installed in the Apache HTML folder.\n```\n\n### Increase maximum upload size on Apache to allow uploads larger than 2M to the wiki\n\n**You may need to modify the PHP version** in the following commands as it changes. 7.2 needs to become 7.4, or whatever is installed on your system. Run `ls /etc/php`,  see which version of PHP you have installed and **modify the paths accordingly:**\n\n```bash\nsudo sed -i '/upload_max_filesize = 2M/c\\\\upload_max_filesize = 50M' /etc/php/7.2/apache2/php.ini\nsudo sed -i '/memory_limit = 8M/c\\\\memory_limit = 128M' /etc/php/7.2/apache2/php.ini\nsudo service apache2 restart # restart apache with new settings\n\n```\n\n### Configure your new mediawiki\n\nGo to your website address in the browser (for my case http://gcc-mci.fe.up.pt/mediawiki, in your case you will adjust accordingly) and configure MediaWiki using the wizard.\n\n![Mediawiki Setup Welcome Screen](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/mediawiki_welcome.png)\n\n#### Setup process\n\n![Mediawiki Setup Language](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/1_language.png)\n\n![Mediawiki Setup Database](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/2_db_setup.png)\n\n![Mediawiki Setup Wiki Details](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/3_type_of_db.png)\n\n![Mediawiki Setup Language](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/4_wiki_details.png)\n\n![Mediawiki Setup Admin Details](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/5_add_admin_details.png)\n\n![Mediawiki Setup Install Now](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/6_install_it.png)\n\n![Mediawiki Setup Ready to Install](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/7_before_install.png)\n\n![Mediawiki Setup Install Finished](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/8_finished.png)\n\n![Mediawiki Setup Download LocalSettings](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/9_download_localsettings.png)\n\n### Download LocalSettings.php to the MediaWiki installation\n\nAfter the setup is complete, your browser will automatically download a file called `LocalSettings.php`. This will have to be placed in a specific directory and customised to suit our particular needs.\n\nUpload the `LocalSettings.php` file to your home directory using an FTP client and then copy it to the MediaWiki installation directory\n\n```bash\ncd ~\nsudo mv ~/LocalSettings.php /var/www/html/mediawiki\nsudo chown -R www-data /var/www/html\n```\n\n### Set right permissions to enable file uploads\n\nsudo chmod -R 0755 /var/www/html/mediawiki/images\n\n### Mediawiki is Ready\n\nYou should now see the MediaWiki home page ready to work\n\n![Mediawiki Ready](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/10_mediawiki_installed.png)\n\n## Installation of Semantic MediaWiki extension\n\nSemantic Mediawiki relies on PHP Composer. Let's install it first.\n\n### Install PHP Composer\n\n```bash\ncd ~\nphp -r \"copy('https://getcomposer.org/installer', 'composer-setup.php');\"\nphp -r \"if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"\nphp composer-setup.php\nphp -r \"unlink('composer-setup.php');\"\n\nsudo apt-get -y -qq install composer\n\n```\n\n### Run PHP Composer on HTML Folder and update MediaWiki dependencies\n\n```bash\ncd /var/www/html\nsudo chmod ugo+w composer.json\nsudo mkdir -p /var/www/html/vendor\nsudo chmod ugo+rw /var/www/html/vendor\n\ncd /var/www/html/mediawiki\ncomposer update\n```\n\n### Install Semantic Mediawiki extension in MediaWiki\n\n```bash\ncd /var/www/html/mediawiki\nsudo mkdir -p ./extensions/SemanticMediaWiki\nsudo chmod ugo+rw ./extensions/SemanticMediaWiki\nsudo composer require mediawiki/semantic-media-wiki \"3.0.0\" --update-no-dev\nsudo composer require mediawiki/semantic-result-formats \"3.0.0\"\ncomposer update --no-dev\nphp maintenance/update.php\n```\n\n### Finishing Touches\n\nThe LocalSettings.php file needs to be customised with some tuning add-ons.\n\nAdd at the end:\n\n```php\n// Set custom logo if you want\n$wgLogo = $wgScriptPath . '/images/feup_logo.png';\n\n// Enable semantics for the wiki. Replace with the root URL of your wiki\nenableSemantics( 'http://gcc-mci.fe.up.pt/mediawiki' ); //FIXME\n//\n//Prevent new user registrations except by sysops\n$wgGroupPermissions['*']['createaccount'] = false;\n\n//enable uploads\n$wgEnableUploads = true; # Enable uploads\n\n$wgTrustedMediaFormats[] = 'application/zip';\n\n$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',\n    'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',\n    'pptx', 'ps', 'odt', 'ods', 'odp', 'odg', 'zip'\n);\n\n//enable captchas to present spam\nwfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ) );\n\n// Add your questions in LocalSettings.php using this format:\n// A question may have many answers\n$wgCaptchaQuestions = array(\n    'Qual é o nome ou sigla desta Unidade Curricular?' =\u003e array( 'GCC', 'gestt\não de conhecimento e colaboração', 'Gestão de Conhecimento', 'Gestão de C\nonhecimento e Colaboração', 'gestao de conhecimento e colaboracao' )\n);\n\n$wgGroupPermissions['*']['edit'] = false;\n```\n\n## Extra 1: Promote users to admins if you need it\n\nAccess these pages and select your users; attribute them to the administration groups\n\nhttp://your-wiki-address/mediawiki/index.php/Special:Privileges (in English)\nhttp://your-wiki-address/mediawiki/index.php/Especial:Privil%C3%A9gios (in Portuguese)\n\n### Your SemanticMediaWiki should be ready\n\nGo to your wiki address, in my case http://gcc-mci.fe.up.pt/mediawiki/wiki/Special:Version or http://gcc-mci.fe.up.pt/mediawiki/index.php/Especial:Versão (in Portuguese wikis). You should see that your list includes Semantic Mediawiki:\n\n![Semantic Mediawiki Installed](https://github.com/silvae86/semanticmediawiki-install/raw/master/images/setup/11-smw_installed.png)\n\nHappy Wiki'ing!\n\n## Extra 2: how to clone a semantic mediawiki installation\n\nSometimes you need to create different installations for separate permissions management. In my case I had to create several SMW instances where my students had administrative permissions to be able to parametrize controlled vocabularies. However, if they would be administrator of their wiki, they would see everyone's work (which is obviously not good for evaluation!)\n\nThe solution is to completely clone the wiki and make it into separate workspaces, so that they can be admins of their own wikis but not see their colleagues' work in their own wikis.\n\n### Copy the folder to a new one\n\n```bash\ncp -R /var/www/html/mediawiki /var/www/html/grupo1\ncp -R /var/www/html/mediawiki /var/www/html/grupo2\ncp -R /var/www/html/mediawiki /var/www/html/grupo3\n# ...\n```\n\nNow for all the new subfolders, you need to run the following operations.\n\n### Enter the cloned folders\n\n```bash\ncd /var/www/html/grupo1\n```\n\n### Create an empty MySQL Database for every new cloned wiki\n\n```bash\nmysql -u root -pMYSQL_ROOT_PASSWORD # replace MYSQL_ROOT_PASSWORD with your mysql admin password\n\nmysql\u003e create database grupo1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql\u003e create database grupo2;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql\u003e create database grupo3;\nQuery OK, 1 row affected (0.00 sec)\n```\n\n### Edit LocalSettings.php inside each cloned folder\n\nIf you do not edit this, all three wikis will be editing the same MySQL database! We need to change the database being used by each wiki, among other stuff.\n\n```PHP\n# Site name\n$wgSitename = \"Semantic MediaWiki Grupo 1 GCC\"; # (Before) $wgSitename = \"Semantic MediaWiki Sandbox GCC\";\n\n# Namespace, must be unique\n$wgMetaNamespace = \"Semantic_MediaWiki_Grupo1_GCC\"; # (Before) $wgMetaNamespace = \"Semantic_MediaWiki_Sandbox_GCC\";\n\n# Wiki subfolder\n$wgScriptPath = \"/grupo1\";  # (Before) $wgScriptPath = \"/mediawiki\";  \n\n## Database settings\n$wgDBname = \"grupo1\"; # (Before) $wgDBname = \"demo\";\n\n# Site secret\n$wgSecretKey = \"a_very_long_key\"; # (Before) $wgSecretKey = \"another_very_long_key\";\n```\n\n### Recreate MediaWiki database tables\n\n```bash\nmysql -u root -pMYSQL_ROOT_PASSWORD \u003c maintenance/tables.sql\n```\n\n### Recreate Semantic MediaWiki database tables\n\n```bash\nphp maintenance/update.php\n```\n\n### Create admin user in each wiki\n\n```bash\ncd /var/www/html/grupo1\nphp maintenance/createAndPromote.php --sysop --bureaucrat new_user_username my_secret_password # create 'new_user_username' with password 'my_secret_password'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvae86%2Fsemanticmediawiki-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilvae86%2Fsemanticmediawiki-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvae86%2Fsemanticmediawiki-install/lists"}