Multiple version of PHP on different Virtual Hosts

Hi everyone, I’m a web developer.
I would like to be able to configure apache, php, mariadb and phpmyadmin.
I would like to create a virtual host for each project.

The structure should be this:

  • /home/user/www/site1/ (PHP 8.2)
  • /home/user/www/site2/ (PHP 8.1)
  • /home/user/www/site3/ (PHP 8.0)

I would like to be able to access the site via the addresses:

  • site1.test
  • site2.test
  • site3.test

On “site1” I would like the root document to be:

  • /home/user/www/site1/public (Laravel installation)

Can you tell me the procedure for doing this?

If possible, also enable HTTPS on virtual hosts…

Thanks in advance to everyone.

I don’t think hosting is really the focus of this forum…
I have not administered virtual hosts, but settings for apache are changed either in the virtual host config, or htaccess. Similar for php, there you have php.ini too.

On my sites, since i am on a shared hosting and cannot access the host config, i force different php versions per forder in the .htaccess

I’m from Ubuntu, I was looking for an approach like this:
https ://tecadmin.net/install-multiple-php-version-apache-ubuntu/

You can use php-legacy and current php - that’s all

Can you tell me the commands to use to accomplish what I asked?
I’m just starting out…

Hi @DomyIT, and welcome!

AFAIK PHP 8.0 is no longer supported. I might be wrong about this, though. But if ao, then it won’t be supported for long anymore.

Thus, keeping it is a bad idea :tm: so I recommend you rather look at a docker or other container if you can’t use the latest version.

More info:

https://www.php.net/supported-versions.php

It’s also not really possible in the same way as the article, for that I’d recommend Ubuntu LTS.

1 Like

I have some old projects still running on PHP 8.0…

Now it’s not the PHP version that matters, but how to accomplish what I asked.

Get it a earlier PHP version running with docker:

https://hub.docker.com/_/php

3 Likes

I would like to create virtual hosts by customizing the document root and the PHP version…

Is it possible?

Posssible? Yes, as with just about any- and everything Linux.

a Good idea? Not at all.

Will you find help accomplishing bad ideas on the forum? No, because we don’t promote bad ideas.

Have a look about doing this in thee Arch wiki, if you don’t want to follow our advice:

https://wiki.archlinux.org/title/PHP

It is not entirely different from that, just the names are slightly different.

Example:

Ubuntu:

  • Package: apache2
  • Service: apache

Manjaro:

  • Package: apache
  • Service: httpd

Package php is PHP v8.2 and package php-legacy is PHP v8.1. Anything lower is only in the AUR, so not like Ubuntu officially supported, but if needed available. If PHP 8.3 came out, then it becomes packages php and PHP 8.2 becomes php-legacy. PHP 8.1 will be dropped to the unsupported AUR.

For example PHP 8.0. You see here the basic package and all modules separately.

That said… it is the same software, but the main difference is just the package manager, naming convention and support cycle.

Can you guide me step by step? I think it’s a good idea to setup the system the way I would like to work.

Is it possible to achieve a similar result?
https ://tecadmin.net/install-multiple-php-version-apache-ubuntu/

Why is it a bad solution?

  1. Because you’d have to keep it working and updates manually. So if you don’t know how to get it running, no offense meant, but I doubt very much you’ll be able to keep it running.

  2. Because it’s old, and might soon not be supported at all anymore, it runs the risk of becoming vulnerable to exploits since it’s no longer updated.

  3. Since it’s kept behind, it won’t keep up with the rest of the software that does still get regular updates and thus might cause breakage.

Virtual host with php8.1 e php8.2 only?

No, sorry. If you have specific questions, yes, but not a whole how to.

All depends on your requirements.

As said: Beside the package manager it is pretty much the same, just Ubuntu is more conservative in that regard and ArchLinux/Manjaro follows more upstream. So yes, it is possible.

You should stick with Ubuntu - you will be better off.

Don’t take this the wrong way - if you cannot create the desired setup yourself - you won’t be able to maintain it and you are not ready for a rolling release like Manjaro.

You will run into far too many issues over time which - in turn - will create frustration when your system breaks on sync.

2 Likes

I agree here. If you @DomyIT are not able to see the similarities and the few Deviations between Manjaro and Ubuntu, then I guess you are not ready to switch to Manjaro for web development. Stick with Ubuntu and get familiar with Manjaro in the meanwhile, before completely switching.

I want to try.

Should I start by following this guide?

3 Likes

That will get you started …

1 Like

I completed the procedure, everything works.
Any help creating a virtual host in a different directory?