I wanted to know if it is possible to open a local PHP server from a VB.NET application, it can be a very basic server, such as VertrigoServ, because it is really just to run some basic codes even through the application.
I wanted to know if it is possible to open a local PHP server from a VB.NET application, it can be a very basic server, such as VertrigoServ, because it is really just to run some basic codes even through the application.
If I understand, you have a WAMP server installed on your machine (I suppose it's Apache, Mysql and PHP)
I will assume that your Apache is using ApacheHandler instead of FastCGI in the "Server API"
In any Windows call method (for example CMD), you should call the program and pass the arguments if necessary.
To call any program in .NET you can use the ProcessStartInfo
Steps to follow:
Locate the program httpd.exe
(it should be in a folder as C:\Apache\Apache2.4\bin\httpd.exe
)
If you are using Mysql, find mysqld.exe
, it should be something like C:\mysql\mysql5.2\bin\mysqld.exe
And find the my.ini
of Mysql (if you really want to use mysql in your scripts), the path should be something like C:\mysql\mysql5.2\my.ini
Now that we have the paths, we must create a method for each process (you can even reuse the same method, but this is another story):
Assuming that the apache path is something like C:\Apache\Apache2.4\bin\httpd.exe
, we should run a command like this (to run it as a service, it is not necessarily mandatory):
"C:\Apache\Apache2.4\bin\httpd.exe" -k runservice
To use with ProcessStartInfo
:
Dim startInfo As New ProcessStartInfo
startInfo.FileName = "C:\Apache\Apache2.4\bin\httpd.exe"
startInfo.Arguments = "-k runservice"
' Para ocultar a janela do processo
p.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(startInfo)
To call Mysql (if necessary for your scripts) you should use something like:
C:\mysql\bin\mysqld.exe --defaults-file=C:\mysql\my.ini --console
The method must be something like:
Dim startInfo As New ProcessStartInfo
startInfo.FileName = "C:\mysql\bin\mysqld.exe"
startInfo.Arguments = "--defaults-file=C:\mysql\my.ini --console"
' Para ocultar a janela do processo
p.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(startInfo)