I wrote a script that compiles LaTeX code through pdftex. The trouble is that pdftex only runs on linux.
I am accomplishing this task with the use of shell_exec().
I don’t really have the ability to set up a linux box as a web server. I have my client computer, but it is behind a firewall that I do not control. I do have control of my work server which is running SBS 2003 with a Windows 2000 virtual machine running apache and php. To my knowledge, you can’t install pdftex in Windows, and if you could it wouldn’t work with shell_exec().
Is there way to work around this with cygwin? I could install pdftex in cygwin, and then configure php to run shell_exec() commands inside of cygwin. If this is possible, could somebody point me in the right direction?
Also, I wonder if there is another course of action. I wouldn’t mind buying hosting, but any shared hosting plan isn’t going to support the app. It would have to be a virtual or dedicated hosting plan; something I can’t afford.
For anyone who is wondering about running shell_exec() through Cygwin, check out this link to a comment in the PHP manual:
http://us.php.net/manual/en/function.shell-exec.php#68647
$result = shell_exec("C:\cygwin\bin\bash.exe --login -c '/cygdrive/c/cygwin/bin/convert.exe --version'");
The key is the "--login" option which appends all the required common
cygwin binary and library paths to $PATH. Without this option some of
the cygwin binaries that links to other libraries ( Like ImageMagick
binaries which links to X11 ) will not work and you may see errors
like "cygX11-6.dll not found, Could not start convert.exe"
pdfTeX runs just fine on Windows, without requiring Cygwin. Try MiKTeX.
Related
I've been looking on YouTube and other places, i'm not sure how, this place is filled with smart people so i thought i would ask you guys!
This blog post lists some options:
Termux lets you install a Linux environment and has a PHP distribution (but it is highly restricted and you will probably run into plenty of frustrating limits)
You can enable Developer Mode and then press Ctrl-Alt-T to open a crosh shell, from which you get type shell to get a regular shell and from there either:
Install Linux and dual-boot
Create a chroot environment to develop in
Meanwhile OS 69 introduces Linux for Chromebook which should be an easier way to get a Linux environment.
… but that said, Chromebooks are generally low-powered machines that aren't ideal hardware for doing development work. I'd look at setting up a remote server and doing my dev work over SSH.
You need to install MAMP or XAMPP on your Chromebook. MAMP or XAMPP will turn your Chromebook into a web server capable of reading PHP.
EDITED:
Since you can't run MAMP or XAMPP on your Chromebook, then you should look into using a Cloud solution such as AWS or Google Cloud.
The situation is simple: I have a PHP file and I want to serve it on my localhost. I already have MySQL set up and don't want to install XAMPP or other bulky packages which come with their own MySQL or any other thing such as that.
I tried many Node.js ways to serve a PHP file but none worked for me.
Please, I just have a file and want to "run" it. How can I do that?
Unfortunately, if you want to run a "server-side" code (in your case PHP) in your Windows computer, you have to use a web server that simulate for you it.
XAMPP (or WAMP) enables localhost port to receive connections from yourself and it is a smart way to try in "local" your code.
If you want to run PHP but you don't want to install XAMPP, then you can install a linux distribution and run "apache HTTP server" that is already installed in most distributions. But in every case you need a tool to simulate the "server-side" part.
First of all nodeJS means nodeJavaScript. So it will not support php with mystery magical things.
You could only install Apache server and mySQL. Then you don´t need any XAMPP and the tools it brings with it.
Try to install Apache standalone.
Not sure if this works but should be no problem.
But all in all i would recommend you to use XAMPP
I am figuring out how to use PHP OpenId
I have cloned the repo to the ~/www directory. There are some examples in the php-open-id/examples directory which I wanted to run.
Specifically, I wanted to render the page php-open-id/examples/consumer/index.php in order to better understand the API. I started a server in the php-open-id/examples directory using
python -m SimpleHTTPServer 8000
and I navigated to localhost://consumer/index.php
But it didn't work. It shows a dialog box to save the file. What is the correct way to render this PHP file?
I have found a solution :
Run the server using
php -S localhost:9000
Mac OS
Just Visit your project folder
open terminal on that folder
and Run php -S localhost:9000
then you can see
PHP 7.3.24-(to be removed in future macOS) Development Server started at Tue Mar 30 11:58:49 2021
Listening on http://localhost:9000
After that you are able to access your application on http://localhost:9000
if your port is not available try to change port
You need to have a php server for serving .php files. The simple python server is not a php server and therefore it is just simply listing the files in the directory for download.
If you are on OSX 10 or above, it comes with apache which has php module present and can be setup to serve php file.
Tutorials can be found here
http://php.net/manual/en/install.macosx.bundled.php and here https://discussions.apple.com/docs/DOC-3083
If you would like to setup a dedicated server instead of using apache, MAMP is a good solution. Google It and see tutorials on how to set it up.
Update November 2022:
Unfortunately, PHP has been removed from MacOS. This is a brief tutorial which explains how to get PHP working in Ventura.
I personally dislike the idea to compensate the lack of PHP with the activities outlined in the tutorial. My solution was to install Docker and to run a proper NGINX+PHP container. I consider it to be cleaner, more flexible and better to maintain rather than faffing about with half-baked on-board stuff. But that's a matter of taste, I guess.
Also, as suggested in one of the answers, using the Python approach is not hassle free in Ventura, since it requires xcode to be installed.
In MacOS 10.x I have also been working with the on-board Python and PHP. Having lost those tools as standard installations is annoying.
perlbrew is a tool to manage multiple installations of Perl on your system, making it easy to, say, quickly run a suite of test scripts against many different versions of Perl.
Is there anything like that for PHP? For now when I want to change the version of PHP that my system uses, I'll go into the build directory for my desired version and run make install.
Here's one: http://www.navicopa.com - it allows you to switch between different versions of php in one click (just install them into different directories)
And here's a free one: https://github.com/c9s/phpbrew
Also - you might like this solution as an alternative, if you don't want to use side software: https://stackoverflow.com/a/5299385/1337343
Also missed that you use linux environment, so you would really like this: https://github.com/tobiasgies/php-switch
Install all php versions you need and switch between them using this tiny bash script.
Maybe phpfarm could help you...
When you run ./configure, add --prefix=/usr/local/php-{version} (replacing {version} with the php version). Then to run a script with a certain version:
/usr/local/php-{version}/bin/php script.php
To run under a CGI environment
Make a symlink from /usr/local/bin/php-cgi to /usr/local/php-{version}/bin/php-cgi and then remake the symlink and restart the server when you want to switch php versions.
Maybe light offtopic, but for local development under windows some WAMP stacks provide excellent one-click switching of php versions. i had positive experiences with:
http://www.wampserver.com
http://www.uniformserver.com
Not sure whether this is all clear for you, but let me know if it's not :)
cli
For simple cli testing you can just install each version into their own folders, e.g. /usr/local/php-5.4/bin, /usr/local/php-5.3.10/bin, etc.
fastcgi
For some time you can run PHP in FastCGI mode. You can let a few versions run simultaneously and bind them to different ports, e.g. :9000, :9001, :9002, etc.
The next step is to set up multiple name based virtual hosts in either Apache, Nginx, Lighttpd or Node.js. Each virtual host binds to another FastCGI process and therefore uses a different version of PHP.
Maybe this is overkill for what you need, but if you don't mind using virtual machines Vagrant may be helpful.
Is there a tool or extension for a browser to working with PHP offline? I read about you need to install an Apache server.
Is there an easier way to view offline in browser to see how the PHP code executes?
XAMPP sets up a local install of MySQL, PHP, and Apache that you can develop on.
In Windows, install XAMPP or WAMP
Which are Windows Apache Mysql and Php bundles
In Linux install LAMP
Which is a Linux Apache Mysql and Php bundle
Both of which could help
Nope, simpler than xampp is not possible.
This won't be much use to you now, but there has been recent talk (and submission of code) of providing a built-in web server into PHP itself.
See the RFC at https://wiki.php.net/rfc/builtinwebserver
You could then write your script (e.g. app.php), execute php -S localhost:8000 to start the web server and then see the results in your browser at http://localhost:8000/app.php.
In the mean time, you can install Apache/PHP/MySQL/etc. on your local box, as the other answers have suggested, either manually or with a package like XAMPP.
No. PHP code must be processed by a PHP engine, and the easiest way to do so in a web environment is to use a web server. It does not need to be httpd, but it must be something.
if you are on a Mac, you have Apache installed already. the additional instructions you will need to add PHP and MySQL database server can be found here http://www.entropy.ch/software/macosx/
if you are using Windows, XAMPP is a self contained Apache/MySQL/PHP environment that runs as a stand alone application.
that should get you started. good luck