How to enable php in NixOs - nixos

I'm trying to setup an LAMP environment with NixOs.
I managed to have mysql and apache running, but I can't find a way
to enable php.
At the moment, apache is serving php file as text instead of executing it.
I've seen there is a enablePHP option in the appache-httpd/default.nix file but it doesn't seem visible (it doesn't appear when I do man configuration.nix and I get an error message if I try to set it to true).

Most likely the version of nixpkgs used to build your system (and the configuration.nix man page) is older than the version of nixpkgs you are looking at. After an update of your system the option should be documented in the configuration.nix man page and work as expected.
I successfully use enablePHP and enableUserDir to render php files in my user's public_html. An .htaccess file with DirectoryIndex index.php further enables php index files.

I'm also in the process of setting up a php stack (using nginx / php-fpm) and I found the following, which might answer your question.
Use the extraModules parameter of the httpd config to enable the php module, like so:
extraModules = [
{ name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
];
I found this example here: https://github.com/svanderburg/disnix-stafftracker-php-example/blob/master/deployment/configurations/test-vm1-httpd.nix

Related

Golang app on Heroku htaccess basic auth

Is possible use htaccess on golang application running in heroku??
I had read this link but the solution doesn't work for me (also, the command htpasswd is not recognized in the heroku bash, but I made the htpasswd file usin this tool).
Thank you.
A Go web application is a server so no need to use Apache httpd server, especially on Heroku that has crystal clear deployment instructions for Go :
https://devcenter.heroku.com/categories/go
Follow these instruction closely and you'll find out there is no need for Apache.
htaccess and htpasswd are related to Apache httpd server, they are Apache configuration files.
Finally, Go standard library gives you all the tools you need to implement basic auth yourself :
https://golang.org/pkg/net/http/#Request.BasicAuth

How should I place files on apache2 HTTP server

I am on Kali linux which comes with the apache2 http installed. Under /var/www/ there is a index.html file which is the default index page that will show up on localhost. I have this folder containing all my .html .css .js and some pictures that I want to put on the Apache2 server. Should I just copy/paste the folder under /var/www ?
Thats the traditional way to do it.
if you have virtualhosts or something a bit more complex then you might consider something else but typically people just drop everything in under /var/www (or the equivalent for a given disto or OS )
Yes, though you may need to adjust the accsess rights, and if you want you can use the apache config, or mount --bind, or git clone/pull. Start with the simple option then look into the other options to see if they offer you any benefit.

Setting path variable for apache user on Amazon EC2

I can't add /usr/local/bin to the apache users PATH variable. The user doesn't have a .profile, I can't su to the user, I can't export to the PATH from php using exec and adding
SetEnv PATH /usr/local/bin
To either the http.conf or the .htaccess file doesn't make a difference. I can't find the envvars file to change that but I suspect there's some other problem.
I have restarted apache, and indeed my server.
Ended up following what Alfe suggested in his answer, except rather than in the /etc/init.d/httpd file (which could be overwritten easily on update) I added to /etc/sysconfig/httpd:
export PATH=${PATH:+$PATH:}/usr/local/bin
Have a look at the /etc/passwd to see which login shell the apache user has (on EC2 Ubuntu instances it should be /bin/sh which is a link to /bin/dash). Then have a look at the man page of that shell and find out which configuration files are read upon login. (For /bin/dash that would be .login in the user's home directory.) In those you should be able to extend your $PATH as you like.
EDIT:
Since you seem to have no login shell for that user: Have a look at the /etc/init.d/* scripts which start the system services. Apache will be one of them. They are started as root and may change the current user (e. g. to the apache user). In there you might be able to adjust the PATH as you like it.
Patching those scripts, however, is not considered typical configuration. Updates might overwrite what ever you patch there.

How do I profile a Codeigniter Web App with XDebug?

I'm running XDebug on Linux CentOS. I want to profile pages on a web app built with CodeIgniter, served by Apache.
XDebug is enabled in php.ini with the following settings:
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp/xdebug
Everything works fine when I trigger php scripts from the command line, and XDebug profile logs are written to /tmp/xdebug, as expected. When I load a url from the web app through the browser, XDebug does not create any profile log files.
Has anyone gotten XDebug to work with Codeigniter? From what I can tell, I should not have to trigger XDebug profiling via GET in the url because profiler_enable is turned on for all php scripts, although I've tried this and it doesn't seem to work either.
Apache needed to have write permissions on the /tmp/xdebug folder.
sudo chown -R apache:apache /tmp/xdebug
XDebug can profile Codeigniter page loads from a browser now.
Thanks #J. Bruni.
It seems to me that the issue is not related to CodeIgniter... It seems you may have multiple php.ini files...
In my Ubuntu installation, I have several sub-directories inside /etc/php5 directory: cgi, cli, fpm, etc. Each one of these has a php.ini file inside it, which is specific to a single "mode".
In other words: PHP may have several different php.ini files... one for CLI (command-line), other for CGI, and so on...
Maybe the xdebug configuration lines you pasted above are not in the php.ini file used when you access PHP scripts from the browser. Maybe you added these lines to /etc/php5/cli/php.ini instead of /etc/php5/cgi/php.ini (or another... in my setup, it is /etc/php5/fpm/php.ini, because I use php-fpm)

Node.JS webserver with CGI support (Open Source)

Is there an open source Node.JS webserver available yet that has CGI support?
There is a node-cgi module (found through npm registry) which looks to be actively maintained.
If you are looking for a CGI module to run node.js under webservers like Apache or IIS then cgi-node will allow you to do just that.
Apache example: you can add a .htaccess file within your web folder to point all *.jscirpt files to be executed using Node.js through the cgi-node module. Something like this:
Action cgi-node /cgi-bin/cgi-node.js
AddHandler cgi-node .jscript
Also including the cgi-node.js script found on the cgi-node.org website within the cgi-bin folder.
CGI-Node allows Node.js to behaves exactly like PHP when running under a webserver.
Documentations and tutorials available on the site: cgi-node.org

Resources