Protect a php configuration file on a linux server / apache.
18 posts
• Page 1 of 2 • 1, 2
Protect a php configuration file on a linux server / apache.
Hello,
I would like to compile a php configuration file so that users who I will provide my source code can not be changed.
I installed mono on my linux server. I tried to compile a php file on windows with the following command "phpc.exe test.php / target: web / out: test.dll."
I then copied the "WebPages.dll" in the same directory as the index.php file from my web server. I then tried to do a stupid "<? Php include (" WebPages.dll ");?>" But of course it does not work.
Could you please help me, I can not find documentation on it and I do not know how ...
I would like to compile a php configuration file so that users who I will provide my source code can not be changed.
I installed mono on my linux server. I tried to compile a php file on windows with the following command "phpc.exe test.php / target: web / out: test.dll."
I then copied the "WebPages.dll" in the same directory as the index.php file from my web server. I then tried to do a stupid "<? Php include (" WebPages.dll ");?>" But of course it does not work.
Could you please help me, I can not find documentation on it and I do not know how ...
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
you cannot include DLL file in PHP ...
Copy WebPages.dll into /bin folder ... scripts compiled into this DLL will be automatically available, and you can include them.
Also to compile whole folder into webpages.dll, you can use following:
phpc.exe /target:web /root:. /recurse:.
(This is just a shortcut for:
pgpc.exe /target:dll /root:. /recurse:. /out:bin/webpages.dll)
Copy WebPages.dll into /bin folder ... scripts compiled into this DLL will be automatically available, and you can include them.
- Code: Select all
include 'test.php';
Also to compile whole folder into webpages.dll, you can use following:
phpc.exe /target:web /root:. /recurse:.
(This is just a shortcut for:
pgpc.exe /target:dll /root:. /recurse:. /out:bin/webpages.dll)
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: Protect a php configuration file on a linux server / apa
hello,
Thank you for your reply, I have a small problem that does not work, I think I have not installed the program very well. I use this: http://wiki.php-compiler.net/Web_Server ... nux%29/2.0
below the list of steps that I made for the installation:
Here is the message log of apache I get when I restart apache:
Directory www
test.php
index.php
Thank you for your reply, I have a small problem that does not work, I think I have not installed the program very well. I use this: http://wiki.php-compiler.net/Web_Server ... nux%29/2.0
below the list of steps that I made for the installation:
- apt-get install apache2 libapache2-mod-php5 php5 php5-gd php5-cgi php5-cli php5-mysql mysql-client-5.5 mysql-server-5.5 phpmyadmin libapache2-mod-mono mono-apache-server2
- a2enmod mod_mono
- restart computer
- mkdir phalanger (with root user)
- copy 3.0 directory only (http://phalanger.codeplex.com/SourceCon ... iew/100149) to /usr/lib/mono/phalanger
- chmod -R 777 /usr/lib/mono/phalanger
- nano /etc/mono/2.0/machine.config<phpNet>
<compiler>
<!-- <set name="Debug" value="true" /> -->
</compiler>
<paths>
<set name="DynamicWrappers" value="/usr/lib/mono/phalanger/Deployment/Dynamic"/>
<set name="Libraries" value="/usr/lib/mono/phalanger/Deployment/Bin"/>
</paths>
<classLibrary>
<add assembly="PhpNetClassLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4af37afe3cde05fb" section="bcl" />
<add assembly="PhpNetMySql, Version=2.0.0.0,Culture=Neutral,PublicKeyToken=2771987119c16a03" section="mysql" />
</classLibrary>
</phpNet>
<configSections>
<section name="phpNet" type="PHP.Core.ConfigurationSectionHandler, PhpNetCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" />
.....
- nano /etc/mono/2.0/web.config<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<monoSettings>
<compilersCompatibility>
<compiler language="c#;cs;csharp" extension=".cs" compilerOptions="/nowarn:0169"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</compilersCompatibility>
</monoSettings>
<authorization>
<allow users="*" />
</authorization>
<httpHandlers>
<add path="*.php" verb="*" type="PHP.Core.RequestHandler, PhpNetCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" />
...
- gacutil -i PhpNetClasslibrary.dll -> ERREUR -> Failure adding assembly PhpNetClasslibrary.dll to the cache: The system cannot find the file specified.
- same message for PhpNetCore.dll, PhpNetCore.IL.dll, Data.Mysql.dll, PhpNetMysql.dll
- nano /etc/apache2/mods-enabled/mod_mono.confAddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd .php
DirectoryIndex index.aspx
Include /etc/mono-server2/mono-server2-hosts.conf
Alias /phalanger "/usr/lib/mono/projects/phalanger"
AddMonoApplications default "/phalanger:/usr/lib/mono/projects/phalanger"
<Location /phalanger>
SetHandler mono
</Location>
- restart apache
Here is the message log of apache I get when I restart apache:
[Sat Dec 15 18:54:26 2012] [notice] Apache/2.2.22 (Debian) mod_mono/2.10 PHP/5.4.4-10 configured -- resuming normal operations
Exception caught during reading the configuration file:
System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <phpNet> (/etc/mono/2.0/machine.config line 4)
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Load () [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0
at Mono.WebServer.Apache.Server.get_AppSettings () [0x00000] in <filename unknown>:0
at Mono.WebServer.Apache.Server+ApplicationSettings..ctor () [0x00000] in <filename unknown>:0
Exception during TraceManager initialization:
System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <phpNet> (/etc/mono/2.0/machine.config line 4)
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Load () [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
Handling exception type ConfigurationErrorsException
Message is Unrecognized configuration section <phpNet> (/etc/mono/2.0/machine.config line 4)
IsTerminating is set to True
System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <phpNet> (/etc/mono/2.0/machine.config line 4)
Server stack trace:
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Load () [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
Exception rethrown at [0]:
at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00000] in <filename unknown>:0
at Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource webSource) [0x00000] in <filename unknown>:0
at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool)
at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Configuration.ConfigurationErrorsException: Unrecognized configuration section <phpNet> (/etc/mono/2.0/machine.config line 4)
Server stack trace:
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Load () [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
Exception rethrown at [0]:
at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00000] in <filename unknown>:0
at Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource webSource) [0x00000] in <filename unknown>:0
at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool)
at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in <filename unknown>:0
Directory www
/var/www/bin/WebPages.dll
/var/www/index.php
test.php
- Code: Select all
<?php
echo "hello world!";
?>
index.php
- Code: Select all
<?php
include 'test.php';
?>
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
Try to use http://wiki.php-compiler.net/Installation/3.0/Linux if you want to use Phalanger 3.0.
- marosik
- Posts: 2
- Joined: December 16th, 2012, 4:38 pm
Re: Protect a php configuration file on a linux server / apa
Hello,
Thank you for your reply, I used the debian wheezy package that is easier for me. The mono version I have installed is: "JIT compiler Version 2.10.8.1," I guess that is compatible with Phalanger 3.0.
After installing mono by the command "apt-get install libapache2-mod-mono mono-apache-server2 apache2".
I went to the directory "/usr/lib/mono" and I created a directory "phalanger".
I created a file "phalanger_install_3.0.sh", but when I execute the script nothing happens, I don't know why? Could you guide me if you like it?
best regards
Thank you for your reply, I used the debian wheezy package that is easier for me. The mono version I have installed is: "JIT compiler Version 2.10.8.1," I guess that is compatible with Phalanger 3.0.
After installing mono by the command "apt-get install libapache2-mod-mono mono-apache-server2 apache2".
I went to the directory "/usr/lib/mono" and I created a directory "phalanger".
I created a file "phalanger_install_3.0.sh", but when I execute the script nothing happens, I don't know why? Could you guide me if you like it?
best regards
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
after reboot and chmod 777 on directory "/usr/lib/mono/phalanger" the script works but...
but I don't know the next step...?
root@raspbmc:/usr/lib/mono/phalanger# ./phalanger_install_3.0.sh
Reading package lists... Done
Building dependency tree
Reading state information... Done
xmlstarlet is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
apache2 is already the newest version.
libapache2-mod-mono is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Enter Phalanger installation directory: (default=/usr/local/lib/phalanger)nothing happens then, I press enter key here
cp: cannot stat `phalanger/bin': No such file or directory
but I don't know the next step...?
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
Hi, in the tutorial there is: (script assumes that you have necessary Phalanger assemblies in /phalanger/bin folder next to the script itself, that you are using Ubuntu and you are running it with root rights - sudo ./phalanger_install_3.0.sh) do you have that directory with the phalanger bin files there?
- marosik
- Posts: 2
- Joined: December 16th, 2012, 4:38 pm
Re: Protect a php configuration file on a linux server / apa
hello,
I did not at any directory "/usr/local/lib/phalanger" so I tried to create this directory, but it does not change anything, I do not know or retrieve the binary and copy any places ... In "/usr/local/lib/phalanger/bin" ?
But I don't use Ubuntu, It is a Raspbian wheezy distribution for Raspberry Pi...
Here are the files and directories that I get after installing apt-get
I did not at any directory "/usr/local/lib/phalanger" so I tried to create this directory, but it does not change anything, I do not know or retrieve the binary and copy any places ... In "/usr/local/lib/phalanger/bin" ?
But I don't use Ubuntu, It is a Raspbian wheezy distribution for Raspberry Pi...
Here are the files and directories that I get after installing apt-get
root@raspbmc:/usr/lib/mono# l
total 52
drwxr-xr-x 3 root root 4096 Dec 16 22:42 2.0
drwxr-xr-x 3 root root 4096 Dec 16 22:39 3.5
drwxr-xr-x 3 root root 12288 Dec 16 22:42 4.0
drwxr-xr-x 2 root root 4096 Dec 16 22:41 compat-2.0
drwxr-xr-x 109 root root 4096 Dec 16 22:43 gac
drwxr-xr-x 3 root root 4096 Dec 16 22:41 mono-configuration-crypto
drwxr-xr-x 3 root root 4096 Dec 16 22:39 xbuild
drwxr-xr-x 3 root root 4096 Dec 16 22:39 xbuild-frameworks
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
Could someone help me please ?
- nicolas33
- Posts: 11
- Joined: December 15th, 2012, 1:58 pm
Re: Protect a php configuration file on a linux server / apa
You need to compile Phalanger first (as noted at http://wiki.php-compiler.net/Installation/3.0/Linux). The installation script assumes, you've prepared installation package (run build.sh to copy compiled DLLs).
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
18 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 12 guests