@bobotron said in Zero to Mux (with wiki):
And now to figure out how to make mediawiki on it. And then how to gulp import a mediawiki backup....
ETA: So, me knowing enough stuff to get installs going as a baseline, is it possible to drop a couple of different mediawiki instances in there on different directories or things that point? IE: I have hotbmush.com which I want to be a core wiki. But I may have some other site, othersite.com, as a wiki too. Is this feasible?
Yeah, it's simple. My directory examples may not be 100% accurate unless you're using debian/ubuntu.
/etc/apache2/sites-available contains definitions for sites. Just look inside 000-default.conf there with a text editor to see how it should look. The important bit here is the directory specifier. For example, NEVER RUN YOUR WEBSITE OUT OF /var/www/html - ALWAYS SET UP A NON-ROOT AND NON-SUDO USER FOR SITES AND ESPECIALLY WIKIS. Those bits should be bold, italic, neon green on a black background.
The way it works is that the Apache service runs under the passwordless/loginless user named www-data with a group by the same name. So you create a new basic user with a home directory, typically named the same as the domain you're hosting there, then create a www directory inside that. Don't screw around with enabling public_html directories. That's chickenshit designed for multi-user/multi-tenant hosting scenarios.
So say your site is mydomain.com - log into the server as root or as a sudo-enabled user (preferably).
sudo adduser mydomain
This generates a user and a group at the same time, both named mydomain, and it generates a new /home/mydomain directory after you fill out the user's password and general info. You can just leave the general info blank, or put in other details if you like. You should really be using RSA keypairs instead of passwords to log in with any user at all, but you can set that up in /home/mydomain/.ssh/authorized_keys after your first login as that user.
sudo mkdir /home/mydomain/www
sudo chown www-data:www-data /home/mydomain/www
sudo chmod 775 /home/mydomain/www
What the last line does is set Read Write eXecute for Owner and RWX for Group and RX only for everyone else (this is imperative if you want the webpages to be publically available).
sudo mkdir /home/mydomain/www-logs
sudo chown www-data:www-data /home/mydomain/www-logs
sudo chmod 770 /home/mydomain/www
This time the last line sets RWX for owner, RWX for group, and no read/no-write for anyone else. This allows Apache to write into there and it allows mydomain to read/clear logs.
sudo usermod -a -G www-data mydomain
This adds the user 'mydomain' to the 'www-data' group, giving them RWX access to the new /home/mydomain/www directory. If you're logged in as mydomain at the time then you have to log out and back in for the change to take effect.
You must not forget the -a or you'll dump all existing groups not in the list instead of adding one for that user.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mydomain.conf
Now modify /etc/apache2/sites-available/mydomain.conf - set the data directory to /home/mydomain/www and set the logs directory (or the individual log files to point into) /home/mydomain/www-logs - assign whatever domain name you want to use in the host definition line.
sudo a2ensite mydomain
sudo /etc/init.d/apache2 restart
Or use systemctl if you're more comfortable with that.
At this point every distro has its little quirks so you may have to tweak stuff to get the filesystem permissions just right. /var/logs/apache2/error.log will tell you if this is the case. You can google error codes if any pop up. Apache is insanely well documented both in the online manual and literally every forum. Even StackOverflow.com manages not to fuck up advice on Apache configs and troubleshooting, which is a bit of a miracle if you've ever used StackOverflow for anything more complex than making toast.
Now all you have to do is download your wiki and unzip into /home/mydomain/www or else /home/mydomain/www/wiki (if you want to have a regular website at mydomain.com and the wiki at mydomain.com/wiki)
You'll want/need to create a separate MySQL schema for every wiki, but you can pretty safely use the same username/password as long as it's only accessible from localhost or 127.0.0.1 and only has privileges to those wiki schemas, and as long as nobody else ever logs into the linux shell. You should be able to tell each individual MediaWiki what schema and user credentials to use when you run the initial setup through a webbrowser.
Be advised that literally every single time you upload new files or create new files in /home/mydomain/www you'll need to be root or a sudo user and run:
sudo chown -R www-data:www-data /home/mydomain/www
AND/OR (either works)
sudo chmod -R 775 /home/mydomain/www
Otherwise the newly created files will be owned by the user mydomain and the group www-data so Apache may have issues serving the pages without the chmod or mydomain may have issues editing/overwriting data. I like for everything to be wholly owned by www-data:www-data (user and group) for uniformity. When you do the chown then you're doing chmod for the user mydomain's benefit (the first 7). When you don't do the chown then you're doing the chmod for the group www-data's benefit (the second 7). In both cases you're doing the chmod for everyone else (the 5 at the end).
Short of installing SAMBA and running all your uploads through that for new files (which I don't recommend for a public server - SSH is vastly preferable to SMB) I don't know of a good way to make the chown/chmod stuff happen automatically. Setting every single file in there to READ and EXECUTE may not be the best idea ever either, but is a quick and dirty way of doing it. If you value security over laziness, then you would run the recursive chown but then individually chmod every single new file by itself appropriately.
ie: HTML should never be set eXecute but PHP/PY files should.
sudo chmod 664 /home/mydomain/www/newHTMLFile.htm
sudo chmod 775 /home/mydomain/www/newScriptFile.php
sudo chmod 775 /home/mydomain/www/newScriptFile.py
Unix file permissions are bitflag values so the number 4 is Read and 2 is Write and 1 is eXecute. 664 makes htm files R+W for owner (the first 6) and R+W for group (the second 6) and Read-Only for everyone else (the 4 at the end).
775 then is RWX (owner) RWX (group) and Read+eXecute for everyone else.
It really is easier than it looks, once you get the hang of dicking around with linux systems.