"Proper" or "Best" way to point Apache & MariaDb to external drive?

Hi All,

I’m happy and confident enough to move forward with this fresh install of VirtualMin and WebMin. Everything is purring nicely except mail, which I’ll figure out eventually lol.

I’ve turned on MariaDb and created a dummy db to start, and I will be running the script to install PHPMyAdmin when the time is right.

I would like to tell Apache to use /media/raidlin/htdocs as the root directory for my main outward-pointing website and I’d like all of my imported .sql files to be housed on the same disk beside the htdocs folder, i.e., at /media/raidlin/mydbs. I’m running on both port 80 via http and port 443 via https.

I see several different places in the VirtualMin Dashboard where I could start pointing Apache and MariaDb to the above locations, but I’m sure there is a “best-practices” way.

So, how would YOU tell VirtualMin to point Apache’s DocumenRoot to /media/raidlin/htdocs , and how would YOU tell MariaDb to house your dbs at /media/raidlin/mydbs, please and thank you?

SYSTEM INFORMATION
OS type and version Ubuntu 23.04
Virtualmin version 7.7

Just wondering why you are using a non supported OS ? This may lead to trouble later you should , perhaps, be using ubuntu 22.04 for stability , i in the past have fallen foul when using a non A grade OS

Definitely a concern and I based my decision on the installation and post-install wizard; if I received ZERO errors with both, I continue, but if not, I keep searching for a 22.04 flavour which behaves/handles well with Remmina and dual displays (I’ve had bad luck with Remmina, probably because of my own ignorance). To my surprise, VirtualMin installed perfectly:

Running Virtualmin 7 pre-installation setup:
  Syncing system time ..
  .. done
  Updating CA certificates ..
  .. done

  Welcome to the Virtualmin GPL installer, version 7.0.3

  This script must be run on a freshly installed supported OS. It does not
  perform updates or upgrades (use your system package manager) or license
  changes (use the "virtualmin change-license" command).

  The systems currently supported by install script are:

    Red Hat Enterprise Linux and derivatives
      - RHEL 8 and 9 on x86_64
      - Alma and Rocky 8 and 9 on x86_64
      - CentOS 7 on x86_64
      
    Debian Linux and derivatives
      - Debian 10 and 11 on i386 and amd64
      - Ubuntu 20.04 LTS and 22.04 LTS on i386 and amd64

  If your OS/version/arch is not listed, installation will fail. More
  details about the systems supported by the script can be found here:

    https://www.virtualmin.com/os-support

  The selected package bundle is LAMP and the size of install is
  full. It will require up to 650 MB of disk space.

  Exit and re-run this script with --help flag to see available options.

 Continue? (y/n) y
[INFO] Started installation log in /root/virtualmin-install.log
◻◻ Phase 1 of 3: Setup
[ERROR] Your system hostname hpg is not fully qualified.
Please enter a fully qualified hostname (e.g.: host.example.com): hpg.(mydomain)
Downloading Virtualmin 7 key                                                
Installing Virtualmin 7 key                                                 
Downloading Webmin key                                                      
Installing Webmin key                                                       
Downloading repository metadata                                             
Enabling universe repositories, if not already available                    
Disabling cdrom: repositories                                               
Cleaning up software repo metadata                                          

 Phase 2 of 3: Installation
Checking and installing system package updates                              
Installing Virtualmin 7 and all related packages                            
Installing Virtualmin 7 and all related packages updates                    

▣▣ Phase 3 of 3: Configuration
[1/21] Configuring AWStats                                                  
[2/21] Configuring Apache                                                   
[3/21] Configuring Bind                                                     
[4/21] Configuring ClamAV                                                   
[5/21] Configuring Dovecot                                                  
[6/21] Configuring Etckeeper                                                
[7/21] Configuring Firewalld                                                
[8/21] Configuring MariaDB                                                  
[9/21] Configuring Postfix                                                  
[10/21] Configuring ProFTPd                                                 
[11/21] Configuring Procmail                                                
[12/21] Configuring Quotas                                                  
[13/21] Configuring SASL                                                    
[14/21] Configuring Shells                                                  
[15/21] Configuring SpamAssassin                                            
[16/21] Configuring Status                                                  
[17/21] Configuring Upgrade                                                 
[18/21] Configuring Usermin                                                 
[19/21] Configuring Webmin                                                  
[20/21] Configuring Fail2banFirewalld                                       
[21/21] Configuring Virtualmin                                              
▣▣▣ Cleaning up

[SUCCESS] Installation Complete!
[SUCCESS] If there were no errors above, Virtualmin should be ready
[SUCCESS] to configure at (mydomain).
[SUCCESS] You may receive a security warning in your browser on your first visit.
shawn@hpg:~$ 

Post-Installation Wizard Results

The status of your system is being checked to ensure that all enabled features are available and properly configured ..
 

Your system has 15.03 GiB of memory, which is at or above the Virtualmin recommended minimum of 256 MiB

BIND DNS server is installed

Mail server Postfix is installed and configured

Postfix is configured to support per-domain outgoing IP addresses

Apache is installed

CGI scripts can be executed using suEXEC or FCGIwrap

Apache supports HTTP/2 on your system

The following PHP execution modes are available : cgi fcgid fpm

The following PHP versions are available : 8.1.12 (/bin/php-cgi8.1)

The following PHP-FPM versions are available : 8.1.12 (php8.1-fpm)

PHP versions have changed to 8.1 since last check. Regenerating any missing php.ini files

Apache is configured to host SSL websites

MariaDB 10.11.2 is installed and running

Logrotate is installed

SpamAssassin and Procmail are installed and configured for use

Plugin AWStats reporting is installed

Plugin Protected web directories is installed

Using network interface (correct) for virtual IPs

IPv6 addresses are available, using interface (correct)

Default IPv4 address for virtual servers is 10.0.0.101

Default IPv6 address for virtual servers is (correct)

Both user and group quotas are enabled for home and email directories

All commands needed to create and restore backups are installed

The selected package management and update systems are installed

Chroot jails are available

.. your system is ready for use by Virtualmin

Updating all Webmin users with new settings..
.. done

Updating Virtualmin library pre-load settings ..
.. done

Updating status collection job ..
.. done

Re-loading Webmin ..
.. done

Hopefully my good luck continues:)

PS At the moment I’m on the Edit Directives page as I’m most experienced modifying this document. I’ve copied all of the subdirectories (awstats, cgi-bin, etc,) to a directory beside my new htdocs folder. After changing both 80 & 443 versions of this document, I’ll reboot Apache to see if it worked. If not, I’ll undo and wait for some help here lol:)

Agh. We should detect that situation better. We made the installer more forgiving of different OSes and less dependent on version specific code, but you are absolutely running on an unsupported OS.

You should use a supported OS, if you’re not a pretty experienced system administrator and Virtualmin/Webmin user. Your OS version is wholly untested by us, and if you run into issues (you probably will), we won’t be able to guide you (we aren’t going to install it and try to reproduce problems on an unsupported OS, we already have too many OS variants to support).

That’s a shame:( Well, for now, I still need to learn a few important things about WebMin/VirtualMin usage and configuration, so I’ll make my mistakes here getting my MariaDb files moved and Samba/firewall working properly, plus backup configuration. Once I’ve moved past the Total Newbie Stage and have all my notes showing what works, I’ll start over with a Grade A foundation.

On that note, I got my Apache reading from /media/raidlin/htdocs now, but I could still use some advice on how to properly configure MariaDb through VirtualMin to allow my databases to be rooted at /media/raidlin/mydbs. Any help here would be much appreciated:)

Merci:)
Shawn

shutdown mariadb

service mysql stop

then

rsync -av /var/lib/mysql /media/raidlin/mydbs

then

mv /var/lib/mysql /var/lib/mysql.bak

so you have a backup just in case it all goes wrong
then edit /etc/mysql/mariadb.conf.d/50-server.cnf and find the line

datadir = /var/lib/mysql

and change it to

datadir = /media/raidlin/mydbs

at this point restart mariadb

service mysql start

then log into mysql as root ( mysql -u root -p)
type the following command at the mysql prompt

select @@datadir;

this should return /media/raidlin/mydbs

now do some tests on the data for example creating a database & adding tables to it and reading from & writing to existing databases. If all goes well you can remove the backup you made earlier.
This guide assumes that you are logged into a terminal as root.
as a side note I found this ’ The Remmina PPA is looking for a maintainer , and it’s not actively updated. so what do you use Remmina for ? My thought are using a non supported OS and Remmina may equal disaster

1 Like

It’s a bug. Fixed here:

On that note, I got my Apache reading from /media/raidlin/htdocs now, but I could still use some advice on how to properly configure MariaDb through VirtualMin to allow my databases to be rooted at /media/raidlin/mydbs .

  1. You should use System ⇾ Users and Groups ⇾ Configuration: Home directory options page to configure the default home location for users. That will affect Apache as well.
  2. You should use Servers ⇾ MariaDB Database Server: MariaDB Server Configuration page to define different location (default is /var/lib/mysql) for databases files directory. Note that first you would need to stop MariaDB, move or copy (preserving permissions) the actual files from /var/lib/mysql to a new location and then restart MariaDB manually.

That doesn’t work
I did


saved and restarted maria
then did

as you can see the datadir is still the same

Did you also first stop MariaDB, move or copy (preserving permissions) the actual files from /var/lib/mysql to a new location and then restarted MariaDB?

no you did not say in your reply that was necessary

I’m sorry, you’re right, I will edit my answer.

so therefore my answer is correct or have I missed something ?

so therefore my answer is correct or have I missed something ?

Yes, it is.

JIMR1 - thanks so much for this help. I really appreciate it.

Ilia - Should I undo my changes to the Servers > Apache Webserver > Virtual Server Options > Edit Directives where I changed all the locations to /media/raidlin etc. and work via Configuration: Home directory options from there?

I will follow these directions to finally get my sql data onto /media/raidlin/mydbs. After this unpleasant month-long journey to salvage my old Windows Storage Spaces data and XAMPP setup, I will finally have everything on universally-readable external drives and therefore will be OS-disaster independent*. Phew:)

At that point I can re-install a Grade A Ubuntu 22.04 OS and VirtualMin again. When finally configured, I can hopefully move this box into the corner and use RDP/Remmina to access it.

*kinda lol

The rest of this is not related to the original question:


I still need to figure out the proper way to run Samba. Right now, I’ve added samba (139, 445) TCP to the FirewallD page, and I have no idea if that means it is accessible via the Internet? And I still have no idea how to add users from my other computers as users of the Samba shares via VirtualMin (I’m sharing /mnt/md0 and /media/).



Re: Remmina, my LAN setup follows a (terribly named) master/slave approach as a result of my music/MIDI studio, Windows-based.

One computer holds the DAW (the app[s] where my work is done to create my music) and the other computers hold my samples and their software. So most of the time I’m on the DAW with 3 monitors, but I have to RDP in to the slaves often to set up my samples for the DAW.

However, my computers also dual-boot Ubuntu in order to perform functions totally unrelated to the music studio, namely running my website, a web programming environment (VS Code), an IoT programming environment (lots of IDEs), storing all of my non-music data (RAID10 NAS), and a “general usage” box for email/Internet, watching videos etc.

I was all Windows until early April when my only Windows 11 computer (other boxes were all Windows 10) was storing my NAS drives via “Storage Spaces” and died. If you don’t know, Storage Spaces is proprietary and not backwards compatible; hence my move to Ubuntu and mdadm.

then edit /etc/mysql/mariadb.conf.d/50-server.cnf and find the line

datadir = /var/lib/mysql

and change it to

datadir = /media/raidlin/mydbs

There was no > datadir = /var/lib/mysql so I added i here:

[mysqld]






pid-file                = /run/mysqld/mysqld.pid
basedir                 = /usr

#SG
datadir                  = /media/raidlin/mydbs

And then:

root@hpg:~# sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
root@hpg:~# service mysql start
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.
root@hpg:~# systemctl status mariadb.service
× mariadb.service - MariaDB 10.11.2 database server
× mariadb.service - MariaDB 10.11.2 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enab>
     Active: failed (Result: exit-code) since Thu 2023-06-08 09:39:11 EDT; 1min>
   Duration: 20h 18min 11.743s
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 210882 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /v>
    Process: 210883 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_>
    Process: 210885 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] &>
    Process: 210978 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUST>
   Main PID: 210978 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 255ms

Jun 08 09:39:11 hpg.rgblr.art systemd[1]: Starting mariadb.service - MariaDB 10>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Warning]>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Warning]>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Note] St>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] m>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] D>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] A>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Main process exited,>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Failed with result '>
...skipping...
× mariadb.service - MariaDB 10.11.2 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enab>
     Active: failed (Result: exit-code) since Thu 2023-06-08 09:39:11 EDT; 1min>
   Duration: 20h 18min 11.743s
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 210882 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /v>
    Process: 210883 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_>
    Process: 210885 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] &>
    Process: 210978 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUST>
   Main PID: 210978 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 255ms

Jun 08 09:39:11 hpg.rgblr.art systemd[1]: Starting mariadb.service - MariaDB 10>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Warning]>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Warning]>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [Note] St>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] m>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] D>
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] A>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Main process exited,>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Failed with result '>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: Failed to start mariadb.service - Mar>

root@hpg:~# journalctl -xeu mariadb.service
Jun 08 09:39:11 hpg.rgblr.art mariadbd[210978]: 2023-06-08  9:39:11 0 [ERROR] A>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Main process exited,>
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit mariadb.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: mariadb.service: Failed with result '>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit mariadb.service has entered the 'failed' state with result 'exit-co>
Jun 08 09:39:11 hpg.rgblr.art systemd[1]: Failed to start mariadb.service - Mar>
░░ Subject: A start job for unit mariadb.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit mariadb.service has finished with a failure.
░░ 
░░ The job identifier is 18824 and the job result is failed.

So I’m not sure what to do next…

Wait, is everybody suggesting changing the paths of homes and all the services? Don’t do that!

Mount the new drive onto the paths where these things already live, so you don’t have to change any configuration files!

This is especially true for home! But stuff in var really shouldn’t move, either. There’s just so many expectations about where things live that it’s a pain in the ass to change it, and likely to bite you later when you find out you missed something.

There is no reason to ever change these config directives. Just mount the new partitions/volumes where you want them to appear in the hierarchy. If you already have files in those locations, you can copy them over before altering where it is mounted.

Changing paths for your services is (almost) never the right thing. In addition to all the additional maintenance headache, it’ll make restoring backups a lot more complicated later when you migrate to new hardware. You’re just asking for trouble doing this.

Joe - I can unfortunately verify that your concerns are valid (don’t ask lol).

So I formatted the drive and installed Ubuntu 22.04. Now, before I hit enter on this terminal to install VirtualMin one last time, can you please explain to me what exactly this means:

**

Mount the new drive onto the paths where these things already live, so you don’t have to change any configuration files!

**

  1. My website exists at /media/shawn/raidlin/htdocs.
  2. My sql files should be imported to /media/shawn/raidlin/mydbs (or /media/shawn/raidlin/mysql, either is fine).

Am I to somehow make VirtualMin think these 2 directories actually exist at the default VirtualMin location…like some sort of Windows “Shortcut”? Or are you telling me my only option is to house my website on the internal operating system drive at the location VirtualMin expects, as in dump my htdocs files into the public_html directory and import my sql data to the default location supplied by VirtualMin?

…or does Linux allow me to rename the actual location?

Merci:)
Shawn

Don’t do that.

Mount the partition or volume that is currently mounted on /media/blah/blah/bunchacrap on /home. Use a bind mount if it’s not a separate volume or partition (but you should make it a separate volume or partition for the benefit of future you).

Don’t do that either. Mount that volume or partition on /var/lib/mysql.

You’re not doing anything with Virtualmin. You are literally mounting those partitions or volumes in the place in the filesystem hierarchy (/home and /var or /var/lib/mysql or /var/lib/mariadb) where that kind of data belongs.

No, I’m not suggesting a symbolic (or hard) link.

It is not the only option, but it is the right option. And, it is so much more of a right option, that you’d be crazy to try to do it some other way. I’m sorry anybody suggested it changing all the paths, because that’s just a really bad practice and will bite you badly later.

We don’t supply that location, your OS does. These are conventions shared across the Linux world. User homes live in /home (though there is some debate about whether we ought to instead put those homes in /var/www, since these homes are intended to host websites, but I think the “home” aspect of it is more important than the “www” aspect of it, since mail and other stuff also goes there). Databases live in /var.

Look in /etc/fstab. Unless the extra disk is some sort of temporary disk (i.e. a USB disk) that was auto-mounted (in which case it probably has a filesystem entirely inappropriate for this purpose, like FAT32, which doesn’t even have permissions or quotas!), you will see a mount entry for this disk.

I recommend you read up on the following topics (this will save you a lot of time in the long run over doing something crazy like changing all the paths):

LVM, the Logical Volume Manager. Ideally, you will create two volumes on your big disk, one for /home and one for /var (or /var/lib/mysql, if you really only want databases stored there and everything else stored elsewhere). You could do this with raw partitions, but using LVM allows flexibility later, and also provides additional features, such as snapshots, disk mirroring and other RAID types, etc. Volumes are the right thing (but in a testing or development environment where you don’t care too much about the data or about backups or system upgrades or migrations later, filesystems on raw partitions is also fine).

And, fstab. This is the filesystem table, where mounted filesystems are defined. You will configure how the volumes I just mentioned get mounted. You decide where in the filesystem hierarchy a volume or partition will be mounted (e.g. /home or /var/ or / or whatever).

Your questions aren’t really Virtualmin questions. These are basic system administration topics, I’m just trying to steer you onto a reasonable path; changing all the locations of your databases and user homes is not a reasonable path.

Joe - I am EXTREMELY grateful for your post. It fills in many black holes for me as a new Linux user; before getting this current VirtualMin box up, my only experience with Linux was in VS Code with WSL in Windows. But I am unsure where to start because of your USB note.

fstab looks like this (ignore my addition for md127, which is an 8Tb mdadm RAID10 instruction and not part of this discussion):


  GNU nano 6.2                                                               /etc/fstab                                                                        
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda5 during installation
UUID=f5624f6b-5f0c-4135-a07b-xxxxxxxxxx       /       ext4    relatime,rw,errors=remount-ro,grpquota,usrquota,quota   0       1
# /boot/efi was on /dev/sda1 during installation
UUID=805E-xxxxxxx  /boot/efi       vfat    umask=0077      0       1

#SG from XPS (was md0):
/dev/md127 /mnt/md127 ext4 defaults,nofail,discard 0 0

Hopefully the following helps people understand why this entire post (and my other recent posts) might seem odd:

  • This computer is a laptop with a single SSD, with a partition for Linux, a partition for Windows (just in case), and the inherent boot/UEFI etc. bits required to run the 2 OSes.

  • My website (at htdocs) is on an external USB3 enclosure which has 2 hardware RAID drives and 3 non-RAID drives.

  • htdocs are on the RAID setup, which is SSDs top-level partitioned as RAIDLIN (where htdocs is) and OSBKUP (where TimeShift files go).

I guess my question is, can this above apply to “permanently” attached USB enclosures? If yes, I’ll do my due diligence here based on your post and figure out how to “rename” (so to speak) my drives so they mount as a Linux expert would mount them given their application/use…

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.