running tex from php script - php

I've installed mactex on my macbook and configured apache + php + mysql.
So when I'm running texi2pdf from bash it works fine. But when I'm trying to run it from php script the next error occurs
Font T2A/cmr/m/n/10=larm1000 at 10.0pt not loadable: Metric (TFM) file not found.
The function is called as
exec("texi2pdf .... ")
$PATH var is OK.
I guess the problem with access to some files but I've set permission to all necessary files (including ~/Library/texlive) and all of them are successfully read with
exec("ls ... ")
or
exec("cat ...")
The problem is not with cyrillic fonts, all necessary packages are installed and as I've already said texi2pdf works fine from bash.
MacOSX 10.7
Apache/2.2.19 (Unix) DAV/2 PHP/5.3.6
TeX 3.1415926 (TeX Live 2011)

Problem solved.
As PHP script uses current directory (or DocumentRoot) to load and generate necessary tex fonts the home directory should be change to user home
putenv('HOME=/Users/username');

Are you tried to allow exec? It may be blocked as default.

Related

Problem to download binary file using phpseclib SCP

I have a a small PHP script that uses phpseclib to download files from remote server.
The script is like below:
include('Net/SCP.php');
echo var_dump($ssh->exec('whoami')); // debug to test the ssh connection. returns "myuser"
$scp = new Net_SCP($ssh);
try{
$remotePath = '/home/user/test.txt';
$localPath = '/tmp/myfile';
if (!$scp->get($remotePath, $localPath)) {
throw new Exception("Problems to get file");
}
} catch (Exception $e) {
echo "\n\n" . var_dump($e->getMessage()) . "\n\n";die;
}
There are some other questions here in SO that uses very similar snippets.
It works like a charm for many files, but it fails for some binary files ($remotePath = '/home/user/test.p12';, for instance).
Are there any know limitation to download binary files using phpseclib (I didn't find anything in their issues on github)? If not, what I'm doing wrong? Am I forgetting some options or anything?
As a side note scp myuser#serverip:/home/user/test.p12 /tmp/teste.p12 works fine in command line.
Following the comments, I must indicate that my script just fails. The statment $scp->get($remotePath, $localPath returns false for all binary files that I tried. Thats all i have for now.
As far as I know, phpseclib does not have any detailed log on these fails.
My application log (nginx) does not show anything special. Access log on my remote server (centOS. for these tests I have the control over it, but its not the real scenario) I got something like below:
Jul 27 15:22:58 localhost sshd[14101]: Accepted password for myuser from myip port 51740 ssh2
Jul 27 15:22:58 localhost sshd[14101]: pam_unix(sshd:session): session opened for user myuser by (uid=0)
Jul 27 15:22:58 localhost sshd[14103]: Received disconnect from myip port 51740:11:
Jul 27 15:22:58 localhost sshd[14103]: Disconnected from user myuser myip port 51740
PHP version: 7.3 (the script is also used in servers with older versions)
Local server: Debian 10
Remote server: CentOs 8
The problematic file that fires the problem is a certificate p12 file.
I found the problem and it was much more simple than I tought. It was just a permission problem (for any good reason, I put all my test files in a directory without read permition).
I decided to leave this answer here, because I think that this is not clear on phpseclib documentation, but the 'Net/SCP.php' only works with files with read permission, so, before download make sure that the file are readable or execute something like chmod o+r filename.
The snippet in the question works fine with binary files.

require of a file with return value fails silently.

I have two simple files (+those generated and downloaded by composer)
I have a simple php file:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require __DIR__ . '/vendor/composer/autoload_classmap.php';
echo 'OK';
where autoload_classmap.php is generated based on this composer.json:
{
"require-dev": {
"symplify/easy-coding-standard": "5.3.*"
},
"config": {
"optimize-autoloader": true
}
}
But php script fails on the line with require. There's no error, no data are returned. Browser shows only ERR_CONNECTION_RESET.
(specific package in composer is probably irrelevant, I picked it because it has quite a lot of dependencies)
The problem is in the size of the required file (maybe not in the absolute size of the file but number of rows in array that's being returned definitively plays a role), if I delete number of rows down to around 1600 (I wasn't able to determine exact number - length of individual rows probably factors in).
I think this problem isn't really connected to composer itself though when I tried to replace array of classes with much larger array of random long text it worked fine.
The problem is (most probably) platform dependent: I tried it on my server and it worked fine but when I run it locally on a machine using Windows + WAMPServer (tested on two different machines) through web browser it fails with aforementioned disconnect error. It fails both in Chrome and Edge.
I run Windows 10, PHP 7.2.12 (but tested with 7.3 as well), Apache 2.4.37
On the other hand, when running through CLI it again works fine - so I don't think there's problem with some specific setting in php. But again - probably, what do I know? :)
I tried to find reasons why require may silently fail but I wasn't able to find anything. And I'm out of ideas hot to get it working. Framework I use in my real app relies on requiring this file and for that reason I need to keep optimize-autoloader on false (simply because that way it'll generate much smaller file and require works)
Any ideas?
Thanks
Turns out apache logged this notice:
[mpm_winnt:notice] [pid 6696:tid 672] AH00428: Parent: child process 14924 exited with status 3221225725 -- Restarting.
which directed me to this solution: https://www.codexpedia.com/apache-server/parent-child-process-exited-with-status-3221225725-restarting-on-xamp-apache/
All I needed to do was to add this:
<IfModule mpm_winnt_module>
ThreadStackSize 8888888
</IfModule>
in the httpd.conf file.

MAMP PRO will not start MySQL

I have MAMP & MAMP PRO. MAMP is working okay, this can successfully start Apache and MySQL and performs normally. MAMP PRO will refuse to start MySQL. I have tried the following setting:
innodb_recovery_force = 1
This was not effective, even when set to level 6. I've tried deleting the two log files contained within the MySQL DB folder. This was also not successful.
I do not care about the databases, I want a fresh clean start. However MAMP PRO refuses to work.
Below is the error log out put:
2017-11-24 20:52:31 10804 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace macs2014_internal/btcontentlocal uses space ID: 358 at filepath: .\macs2014_internal\btcontentlocal.ibd. Cannot open tablespace tripeasi_whitelabel_mobile/authtypeconcretecookiemap which uses space ID: 358 at filepath: .\tripeasi_whitelabel_mobile\authtypeconcretecookiemap.ibd
InnoDB: Error: could not open single-table tablespace file .\tripeasi_whitelabel_mobile\authtypeconcretecookiemap.ibd
I have tried completely reinstalling MAMP multiple times however it still appears to be looking for these databases which no longer exist. As I said before, I do not care about saving data.
Do you have other MySQL processes or Server running at the same time that you are trying to start the MySQL server on MAMP? (this can be checked using te "top" command in terminal)
When I first installed MAMP Pro, MySQL Server (MAMP) could not start, that because a MySQL server was already running. (configured to start automatically with the OS)
If so, you can kill all MySQL processes (don't forget to stop the MAMP servers before) using following command in the terminal: sudo killall -9 mysqld.
An other thing you can try, is:
Quit MAMP
In the finder go to Library/Application Support/appsolute/MAMP PRO/db/mysql56/
Delete the log files
Restart MAMP
I hope that your problem is solved after trying one of those things.
Kind regards,
Dakta
So, the folder on windows located in your public documents for MAMP PRO. This is why none of my settings were working correctly and why these phantom databases were appearing.
I went to:
C:\Users\Public\Documents\Appsolute\MAMPPRO\db
and deleted the databases from there, restarted my server and voila - it works. This is a very confusing place to put the settings for MAMP PRO and I don't really understand why they are there and not where you'd expect them to be in your program files.

How to install eclipse for php on windows7

I want to install Eclipse for PHP.
I download Eclipse "PDT 3.0.2 w/Eclipse indigo" to my folder "c:\eclipse" and extract the zip file.
I am also download "jre-6u37-windows-94.exe" and install it successfully.
The problem is when I try to run the file eclipse.exe I get error.
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations:
c:\eclipse\jre\bin\javaw.exe
javaw.exe in your current PATH
The jre installed in directory.
c:\Program Files (x86)\java\jre7\bin
What should I do for running successfully the eclipse.
this is my confog.ini
#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Mon Jun 11 14:17:27 IDT 2012
org.eclipse.update.reconcile=false
eclipse.p2.profile=pdtProfile
osgi.framework=file\:plugins/org.eclipse.osgi_3.7.2.v20120110-1415.jar
equinox.use.ds=true
osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.0.200.v20110815-1438.jar#1\:start
org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info
eclipse.product=org.zend.php.product
osgi.splashPath=vplatform\:/base/plugins/org.zend.php
osgi.framework.extensions=
osgi.bundles.defaultStartLevel=4
eclipse.p2.data.area=#config.dir/../p2
eclipse.application=org.eclipse.ui.ide.workbench
org.zend.php.customization.site.url=http\://downloads.zend.com/studio-eclipse/updates-extra/9_0,http\://downloads.zend.com/studio-eclipse/updates/9_0
should I add the line -vm Path=c:\Program Files(86)\Java\jre7\bin to top file ?
Because it is not working
As "PDT 3.0.2 w/Eclipse indigo" for Windows is only available for 32bit platform, you need to download a 32bit JRE as well to make it run on 64bit Windows platform. Don't forget to make JRE visible for Eclipse by either editing eclipse-php.ini or adding "-vm " as argument to a shortcut pointing to eclipse-php.exe.
More details here:
http://blog.lopau.com/eclipse-pdt-32-bit-on-windows-7/
I bet you that this conflict is due to installation of conflicted java setupYou just need to confirm that you are using 32-bit or 64-bit Windows and then install java according to your OS requirement.32-bit java for 32-bit OS and 64-bit java for 64-bit OS.You will surely get rid from this problem :)Another alternative is to re-run the JRE setup. It typically installs a default JRE by placing java.exe, javaw.exe, etc. in your system folder. That would place the executables in your path, which should be sufficient, based on the note in the error message that it searched your path for javaw.exeif you are still sure that you have installed the right setup then try to set the path by using this commandset PATH=C:\Program Files\Java\jre1.6.0_03\bin ;%PATH%
Eclipse can't find your java installation.
Follow this steps:
control panel -> view advanced system settings
On tab advanced -> environment variables -> system variables -> click new button
in the dialog that appears -> variable name -> enter JAVA_HOME
in the same dialog -> variable value -> enter c:\Program Files (x86)\java\jre7
and click ok to close dialog.
In system variables search for variable named Path. If it doesn't
exist create it with new button.
If there was a Path variable append ;%JAVA_HOME%\bin at the end of
the content in the variable value field.
If you have to create the Path variable enter %JAVA_HOME%\bin
Click OK to close edit system variable dialog
Click OK to close enviroment variables
Open windows command prompt and type echo %JAVA_HOME%. The answer
should be c:\Program Files (x86)\java\jre7 If this is not the case
check previous steps.
Start eclipse.

wamp php CLI has stopped working

I installed wamp server 2.2 with php 5.3.10 and apache 2.2.21. But when I want to execute some symfony command the response from my Windows 7 Home Premium is:
php -> CLI has stopped working
I had this error for a long time. It turned out I was on a slightly older version of Xdebug (php_xdebug-2.2.0-5.4-vc9.dll).
I replaced that file with "php_xdebug-2.2.2-5.4-vc9.dll" and it magically started working immediately.
I'm on wamp, and I updated both php.ini files (one is for cli, one for normal use) with the latest filename.
"zend_extension = c:\wamp\bin\php\php5.4.3\ext\php_xdebug-2.2.2-5.4-vc9.dll"
Then dropped the new file into the php ext folder and instant success. Hope this helps.

Categories