Apache running MongoDB and PHP - apache

I'm using XAMPP in my Mac OSX. I've installed mongodb and copied the .so file into xampp plugins folder. My phpinfo() of the page shows that MongoDB section which is installed.
After i start Apache of XAMPP server, when i code
m = new MongoClient();
$db = $m->mydatabase;
$collection = $db->myCollection;
Its saying some Fatal Error.
If i run mongod command in Terminal window, its working. Then what is the use of installing mongodb in XAMPP server. My Questions are
Why its working like that..?
Is there any way to start mongod when we start Apache server.

Why its working like that..?
Installing the PHP driver and the MongoDB server are two completely different things.
This is very basic driver stuff; you require a library or communication layer that can route your PHP programming to the MongoDB server (basically).
Is there any way to start mongod when we start Apache server.
You could make an sh script that looks like:
/etc/init.d/xammp_service_dunno_what_it_is_called start
/etc/init.d/mongodb start
Then you could just attach to the startup, or even better you can just attach both services (XAMPP and MongoDB) to the startup of your computer.
However, as far as I know, there is no way to create a sort of trigger mechanism that will load up MongoDB when the OS detects that you have started running Apache.

Related

Laravel: how to specify the php version?

I have a Laravel (5.7.19) app running with apache2 on a redhat7 machine. There are php5.6, php7.1 and php7.4 installed on the machine and somehow apache uses php5.6 as the default and the app doesn't work with php5.6. Is there a way to specify a php version for a Laravel app, such as setting the php version in .env or some other config file of the app? I've googled around and couldn't find an answer. Right now the only way I could make the app to work is to disable php5.6 and then apache would use php7.1 as the default.
"Is there a way to specify a php version for a Laravel app, such as setting the php version in .env or some other config file of the app?"
No. The PHP interpetor isn't aware of itself. The application's dotenv file is read by the application itself, which means there's already an interpretor doing the job so if it's picked up by php5, there's no way for the interpretor to pass it along to a php7 interpreter.
If you're using Apache (and assuming a single Apache running), you can setup multiple PHP versions under the same Apache server by using the fastcgi module as described here: https://medium.com/#sivaschenko/apache-running-multiple-php-versions-simultaneously-570fc1541580 and then depending on application you can setup virtual hosts using different php versions
THe better way is with nginx + fpm, where you can have different php versions with different fpm instances running on different ports and you can setup server blocks where php requests are routed appropriately.

Does file copy deployments work with CakePHP?

I have a legacy CakePHP(1.3.13) app, running on Ubuntu server 16.04, on apache. It is using php 5.6. I'm trying to migrate the app to a development server, also Ubuntu 16.04, but running php 7.2.
On the production machine, php file(s) are being executed even before line 1 of index.php in the app I'm trying to migrate. On the dev box, this isn't happening.
I've sudo tar'ed the entire web server tree, and sudo untar'ed it on the dev box. I've copied the apache site configs, and only edited them for hostnames.
I don't understand why apache is running one or many php files PRIOR to running index.php on the production box. It is apparently loading a custom configuration php file, that sets up some global variable, but for the life of me I can't figure out why this is happening. I'm sure I'm just missing something dumb.
Greg Schmidt nailed it. There was a second auto_prepend_file=MagicallyExecutingScript.php in the php.ini.

Howto run mod-mono and php on same apache webserver

I've successfully implemented mod-mono and apache webserver on a Centos 8 distro.
I've also installed PHP 7.2 on the server and the configuration looks ok on eye inspection.
However, the webserver is not executing the PHP files, but serving them for download.
If i go to http://example.com - it runs the website in MONO space
If I go to http://example.com/info.php - it gives me the PHP file for downloading. It makes me think that it tries to run the php file through mono and fails, so gives it to me for download instead forwarding it to PHP for execution.
Is it possible to run both PHP and MONO code on same apache webserver?
If yes, what could be the tricks to have it working ?
Many thanks.
Actually having a separate PHP website and also MONO websites in same apache server was working. However I though things were not working since I tried to run the PHP file from within the MONO-handled virtualhost ... so no need for clarifications.

How do you install an apache server (httpd) on codenvy?

I would like to have a simple httpd server on my codenvy machine in order to run a front-end web app. How do I install it?
Create a workspace with the template "php-default", then a php project. Try run, access the url the "start apache" gave you, and it should work ! I got a running app in less than 3 minutes.

localhost configuration in offline mode

I'm in a very stupid situation and if I didn't get to resolve it my project will be rejected.
I doing a project for a company that they have hard network security and I can't publish the project online or in a local server.
I'm using on my project PHP and MySQL using usbwebserver program "it's offline Apache server".
now the problem is:
my project should to be on a network as a folder example: \server1\project
and to open the project on my computer I have to access the path and run usbwebserver.exe , so it is open perfect for 1 user but if I try to access the same project in other computer when the first user using the program the Apache not running and I think because the port of apache already in use."maybe I'm wrong"
my question is if there any solution that when other users on the network click on usbwebserver.exe
the apache become running on it .. because I have to use the same DB.
If there is other program that can solve my situation to everyone can work on same apache and same DB offline also I will appreciate!!
I thinking in this way if it possible:
Install Apache on your machine and call mysql from server folder that doesn't run Apache!!!
it is possible ? and if yes how can done it ?