Suggestion to include PHP

 
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
usalabs
-


Joined: 14 Nov 2005
Posts: 18

PostPosted: Fri May 05, 2023 1:22 am    Post subject: Suggestion to include PHP Reply with quote

After seeing a lot of other 3rd party web server software such as WAMP, XAMPP, I noticed they both include PHP in their installation, but only runs from within the installation folder of the web server software, not as a separate installation, so I got thinking, why can't Aprelium do this with both X1 and X2 server software? Being that just about all websites nowadays use PHP over HTM, PHP could be bundled with both versions of the server, saving time in installing a completely separate program, why not just have different versions of PHP installed along with the server software and the PHP versions can be changed using the web interface.

The most common versions I came across are:-

5.3
5.6
8.0
8.2

The reason I suggested different versions is that the user can still use PHP scripts that are only developed on PHP v5.3 or 5.6, and also has a choice of the current 8.2 if developing PHP scripts vor that version and can be run on Abyss.
Back to top View user's profile Send private message
Horizon
-


Joined: 18 Feb 2022
Posts: 54

PostPosted: Fri May 05, 2023 3:35 am    Post subject: Reply with quote

Hello,

actually Aprelium has dedicated PHP packages on this page:
https://aprelium.com/downloads/php.html#win

But the problem with including PHP is always which version is the best one...
So far PHP isn't a monolithic software, that means that one might want many diferent major versions of it.

However the Aprelium PHP packages work fully offline, so they don't need Internet access after download.
If you were to download them all, you would need 5GB or more of disk space.

You also suggested including commonly known versions, that could work.
Even PHP 5.6 & PHP 7.4 could do the trick.

But then the next problem is that Abyss Web Server will want you to register it as an available interpreter in the console web interface.
But Abyss Web Server has a separate interpreter storage for each host, and it can't know in advance which ones need php on them.

-

So, in short considering the above and what you want:

- we could instead revamp the PHP packages of Aprelium to include an interpreter autoconfig URL.
- in the download page of Abyss Web Server, we could post direct quick links to PHP 5.3, 5.6, 8.0 & 8.2 packages by Aprelium.
- these packages would also save the autoconfig URL as a start menu URL shortcut (on Windows) or equivalent for Linux & Mac OS.

(While PHP 5.6.40 is likely fine anyway, the PHP 5.3 one might still need a safety disclaimer due to known vulnerabilities in the PHP-core itself.)

An interpreter autoconfig URL would be generated by the Aprelium PHP installer, by reading the registry (if on Windows) to know where Abyss is installed.

Then it could read abyss.conf (or registry) to get the console URL & the port number.

If that generated link is opened, the admin logs normally into the console and is then presented with the list of hosts with checkboxes.

The checked hosts then directly get configured for PHP as interpreter.

Aprelium also announced in another topic here that the next version will feature an easier way to use multiple versions of PHP on a single host.
For example, one PHP version per directory with many different directories.

-

Also, the reason for the generic approach for interpreters in Abyss is because one could also use Python, Perl or even a custom program as interpreter.

It could be CGI, ISAPI or FastCGI too.

So it would seem strange for Abyss to have a direct integration for one particular interpreter, since such integration would need to blend with the current interpreter configuration UI.

(A custom CGI interpreter for example is rather simple since it's actually reading STDIN & CGI environment variables, then outputting a raw HTTP response to STDOUT before closing its process with exit-code 0.)

-

Another thing to note is that XAMPP & WAMP aren't actually server softwares.

They're a package containing a pre-compiled Apache with a pre-configured PHP interpreter, and MySQL.

The actual XAMPP & WAMP programs are the configuration panels used to customize Apache, PHP & MySQL.

So it's not really possible to compare Abyss with WAMP or XAMPP, but it could be compared to Apache or Lighttpd instead for example.

We could even make a WAMP edition that uses Abyss instead of Apache :). It would be 'Windows Abyss MySQL PHP'.

-

So the reason for WAMP & XAMPP being able to do it but not Abyss is that they're a package/bundle of different softwares while Abyss is one software.

If Abyss does it then it will have to be in a different way such as what I described above.

I hope this answers your question, and that the alternative idea is still correct for what you want.
Back to top View user's profile Send private message
usalabs
-


Joined: 14 Nov 2005
Posts: 18

PostPosted: Fri May 05, 2023 5:18 pm    Post subject: Reply with quote

In one aspect it does answer some questions, but in another there are still some unanswered.

Abyss (no matter if X1 or X2) can only serve different combinations of interpreters per host (PHP, Perl), but not multiple versions simultaneously, so, by changing the 'Script Parameters' page to include PHP version in a dropdown list, and the form would know where each PHP version's (if bundled with Abyss), CGI or EXE file is located, and change the configuration file accordingly.

As I mentioned the most common versions of PHP are: 5.6, 7.0, 7.2, 8.0 and 8.2.

I haven't yet seen any situation where different versions of PHP can be used on one host even if using aliases, usually, different PHP versions are on a host by host basis, X1 can only serve 1 host with one version of PHP, but many aliases, but X2 can serve multiple hosts, and therefore can have the ability to utilize a different PHP version per host, it's just a matter of changing the configuration file on a host.

EG
On X2, 1 host running on port 80, and another on port 8080 and a 3rd on port 8100, then the 'Script Parameters' page on each host can have the option to choose what version of PHP for that host, whereas X1 will only be able to choose which PHP version is used for the one host.

Even in Apache, I haven't found out yet how to use multiple PHP versions when using aliases. To use multiple PHP versions I would have to create separate virtual hosts for each version I want to use, just the same for Abyss X2.
Back to top View user's profile Send private message
Horizon
-


Joined: 18 Feb 2022
Posts: 54

PostPosted: Fri May 05, 2023 9:41 pm    Post subject: Reply with quote

I actually detailed how to do exactly this (multiple PHP versions) with Abyss Web Server, and it will also work on the X1 edition.

See my post here (search for 'Revision #2' in the topic):
https://aprelium.com/forum/viewtopic.php?t=622995

All you need to do is to use different file extensions (e.g. .php74) then URLRewrite to mask them as .php in all URLs.

And finally you need to make a batch symlink script for your php files.

Thanks to symbolic links & URLRewrite, you don't even need to modify any php file to change the php file extensions in the includes of the scripts.

Considering that Apache doesn't have this feature either, this cans be an acceptable workaround while waiting for a new update of Abyss Web Server to implement it in a more user-friendly manner.

I hope that you will be able to understand the way this workaround works.

Otherwise just read afterwards the example flow at the bottom of that multiple-PHP topic's post to really grasp the practical steps involved in the redirects.
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Sat May 06, 2023 4:08 pm    Post subject: Re: Suggestion to include PHP Reply with quote

WAMPS and XAMMP and other ****MP variants are bundles made for people who want PHP+MySQL+A Web server.

Abyss Web Server is totally different. First it is only a Web server. And not all people looking for a Web server want PHP +MySQL with it.

Abyss Web Server is about choice and building your "Web" stack on your own. Many people want PHP+PostgreSQL, some others ASP.NET, others may look for Ruby or Python based Web applications.

Abyss Web Server makes all these combinations possible and doesn't drive its value from being a bundle for other people's software.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Mon May 08, 2023 1:11 am    Post subject: Reply with quote

Another workaround for OP:

First of all, you’ll need X2 for this.

Let’s say you are running PHP 7 on your site by default.
Now make a host setup with PHP 8.
Make a reverse proxy on your main site to point to the PHP 8 host.

I assume you’d only run two versions for compatibility for an application. This should do the trick and doesn’t require renaming file extensions.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Wed May 17, 2023 5:47 pm    Post subject: Reply with quote

pkSML wrote:

Let’s say you are running PHP 7 on your site by default.
Now make a host setup with PHP 8.
Make a reverse proxy on your main site to point to the PHP 8 host.

I assume you’d only run two versions for compatibility for an application. This should do the trick and doesn’t require renaming file extensions.


Could you elaborate on this?

I have X2 and lets say I have a domain setup with PHP7 so if I access mydomain.com it loads the pages using PHP7.

Lets say I have a specific folder that requires PHP8 so if I access mydomain.com/newstuff it needs to use PHP8 to load but only that folder requires PHP8.

Is this possible?
Back to top View user's profile Send private message
Horizon
-


Joined: 18 Feb 2022
Posts: 54

PostPosted: Fri May 19, 2023 11:03 am    Post subject: Reply with quote

Quote:
Lets say I have a specific folder that requires PHP8 so if I access mydomain.com/newstuff it needs to use PHP8 to load but only that folder requires PHP8.


It's possible using reverse-proxy if you create a dedicated host entry in Abyss Web Server for e.g. specific-app.mydomain.com then doing reverse proxy with:

mydomain.com (main PHP 7 host):

Path: /specific-app
* create a new empty folder named e.g. 'specific-app' in that host's directory.

Remote Host: specific-app.mydomain.com
Remote Port: 443
Remote Path: /

SSL: yes

Advanced\Fix URL in cookies: yes
Advanced\Fix URLs in redirects: yes

* then modify your hosts file on the server machine to point specific-app.mydomain.com to 127.0.0.1.
* you can use self-signed ssl for the hidden specific-app.mydomain.com host.

Then you can configure PHP 8 on the new dedicated specific-app host separately.
Its root directory will be as if it was a website for only this app, the php app directory in the server root directory.

Make sure to enable backend operation support in Abyss Web Server console settings to get correct visitor IP addresses in your logs.
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Tue May 30, 2023 12:55 am    Post subject: Reply with quote

Thanks for the info but unfortunately the reverse proxy in Abyss does not seem up to the task.

If I set things up as you describe, yes I can have PHP7 on one domain and PHP8 on the other but if I run actual scripts on the proxy domain, the scripts seem to know the domain is not correct and various scripts fail, database access fails, just lots of fails.

Only the most simple things seem to actually work, which is too bad. :(
Back to top View user's profile Send private message
Horizon
-


Joined: 18 Feb 2022
Posts: 54

PostPosted: Tue May 30, 2023 8:32 am    Post subject: Reply with quote

Hello,
It turns out I didn't mention the 'Preserve Host header' option in Reverse-Proxy settings:



It was added starting with the 2.16.4 version.
You will need to update Abyss to atleast 2.16.4 or higher if this option isn't shown in Reverse-Proxy settings.

For a proper reverse-proxy you'll also need to enable back-end operation support in the server settings:



This way Abyss Web Server will automatically swap the hostname to the correct one, because 127.0.0.1 is trusted for defining the correct one and backend-proxy support is enabled.
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Tue May 30, 2023 8:14 pm    Post subject: Reply with quote

I am obviously missing something since it still does not work and as far as I can tell I have setup everything just as you described.

I have the main domain with PHP8 set up and in the Main folder I have index.php that contains..
Code:
<?php
   print ("MAIN");
   phpinfo();
?>


This folder is setup in Abyss as protocol http+https/port 80,443
Host name is mydomain.com and the document path is D:\Main

If I visit "https://mydomain.com" it returns MAIN:PHP version 8.1.19

I then create a subfolder under Main called Sub. In this folder I place this index.php file...
Code:
<?php
   print ("SUB");
   phpinfo();
?>

This subdomain is setup to use PHP7
This folder is setup in Abyss as protocol http+https/port 80,443
Host name is sub.mydomain.com and the document path is D:\Main\Sub

Under host mydomain.com I set up the reverse-proxy as:
/sub
sub.mydomain.com
443
/
chk - HTTPS

and under advanced I have
chk - Fix URLs in Cookies
chk - Fix URLs in Location Response Headers
chk - Preserve the "Host" Header

Back end has been set up exactly as you have shown and HOSTS file has been modified to: 127.0.0.1 sub.mydomain.com

If I visit "https://sub.mydomain.com" directly (to bypass reverse-proxy) it returns SUB:PHP version 7.4.26 so I assume the subdomain is set up correctly.

Now if I visit "https://mydomain.com/sub" (which should use the reverse-proxy), instead of returning SUB:PHP version 7.4.26 it returns MAIN:PHP version 8.1.19
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Thu Jun 01, 2023 3:07 am    Post subject: Reply with quote

Reverse proxy is working perfectly fine for me.

One suggestion I have is to NOT have the root folder of sub.mydomain.com inside the root folder of mydomain.com.

In other words, move the D:\Main\sub folder somewhere else, like D:\sub. Then update the root folder in the Abyss console for sub.mydomain.com. That's how I have mine set up.

Tip: Don't make the reverse proxy use HTTPS unless necessary. It will only add latency.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Thu Jun 01, 2023 3:35 pm    Post subject: Reply with quote

Thanks for the tips but my problem still persists.

If I visit "https://sub.mydomain.com" directly (to bypass reverse-proxy) it returns SUB:PHP version 7.4.26

If I visit "https://mydomain.com/sub" (which should use the reverse-proxy), instead of returning SUB:PHP version 7.4.26 it returns MAIN:PHP version 8.1.19

It seems to simply be showing me "mydomain.com", it is not proxying to "/sub"
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Thu Jun 01, 2023 3:43 pm    Post subject: Reply with quote

Are you saying you have the exact same setup but yours works?
Back to top View user's profile Send private message
Horizon
-


Joined: 18 Feb 2022
Posts: 54

PostPosted: Thu Jun 01, 2023 7:07 pm    Post subject: Reply with quote

Hello,
perhaps I think I know why it didn't work:

Let's imagine that your root server folder is D:\Websites.

Then instead of D:\Websites\Main\Sub as pkSML suggested it needs to be:

D:\Websites\Main
D:\Websites\Sub

So they need to have their own exclusive root directories.

But that's not all, because you still need a Sub folder in the Main hostname, and it needs to be empty.

So it will be:

D:\Websites\Main (main website)
D:\Websites\Main\Sub (empty folder)
D:\Websites\Sub (actual folder for the specific PHP app)

-- To explain from scratch the process: -

Create for example a mainsite.com host.
Its root directory could be D:\Websites\mainsite.com

Put your main website files inside and setup the PHP interpereter for it.

Now create a new folder named 'specific-app' that needs to stay empty as D:\Websites\mainsite.com\specific-app

-- Now create a subdomain named specific-app.mainsite.com and its root directory is D:\Websites\specific-app.mainsite.com

Setup a different PHP interpreter version for it.
Next copy your real specific PHP app files directory in this new subdomain's root directory.

-- Back to the mainsite.com host (the main one), create a reverse-proxy rule as:

Local path: /specific-app

Remote port: 4430
Remote host: specific-app.mainsite.com
Remote path: /

HTTPS: (unchecked)

Advanced: Fix URLs in cookies (and redirects)
Advanced: Preserve Host header

-- Now go again to the specific-app.mainsite.com host and this time add mainsite.com as one of the accepted hostnames in the General settings.

Then in the Abyss hosts list make sure specific-app.mainsite.com is lower (below) mainsite.com.

It will be:

Host #1: mainsite.com - D:\Websites\mainsite.com
Host #2: specific-app.mainsite.com, mainsite.com - D:\Websites\specific-app.mainsite.com

This will tell Abyss to accept the preserved Host header when connecting to the subdomain.

But you noticed that I wrote port 4430 in the Reverse-proxy rule, so your subdomain host needs to indeed listen on port 4430.

Otherwise, Abyss wouldn't know how to differenciate the HTTP requests with the same Host header to a website listening on the same port number.

-- And if you really have to enable HTTPS in the Reverse-proxy due to a PHP app refusing to work with HTTP only, then make sure to generate a self-signed certificate trusted for your local server PC only.

And set it deliberately to 1024-bit RSA since it's only for a localhost reverse-proxy.
This way your PHP app will consider that your host is secure (which it is, on the external Internet side).

Then you will be able to use the HTTPS checkbox in Reverse-proxy.

-- Now in the server PC's hosts file, write '127.0.0.1 specific-app.mainsite.com'.

-----

The list is long but it's pretty detailed so is there was anything in your setup that you notice as missing it could be why it didn't work.
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Thu Jun 08, 2023 11:55 pm    Post subject: Reply with quote

Thank you for all your help!
With the final bit of info you posted things now work.... about 90% of the time ;)

Occasionally I will receive a 502 server error or a message saying the database could not be accessed or connection lost but pressing Refresh in the browser to reload the page will fix the problem. This of course only happens when going through the reverse-proxy so not sure how to fix that.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group