I am trying to build a vm, where exactly one user (as sudo or not) can brew and start a custom php build.
The current "default" php version should be started as phpbrew fpm process on system start. I was putting something like
phpbrew fpm start
in /etc/rc.local which seems to result in starting up the process. But the process is terminated as soon, as the rc.local script finished. It seems, that without an active login session, the process can't live.
Any suggestions, as how to make the fpm process survive?
Many thanks in advance.
You can modify this config according your needs.
phpbrew 1.22.0 now supports "fpm setup --systemctl" command to help you setup the service.
be sure to enable --with-fpm-systemd when building your php.
In phpbrew build directory it is exists ready file. For example:
~/.phpbrew/build/php-7.0.22/sapi/fpm/init.d.php-fpm
But more comfortable way is: temporary change owner of /etc/init.d to current user, then run command
phpbrew fpm setup --initd
then return back
sudo chown root:root /etc/init.d
sudo chown root:root /etc/init.d/phpbrew-fpm
and then
sudo update-rc.d phpbrew-fpm defaults
If you run it in macOS.
sudo PHPBREW_PHP=$PHPBREW_PHP phpbrew fpm setup --launchctl
and then add it to your launchctl list.
# Activate a system-wide daemon to be loaded whenever the system boots up (even if no user logs in):
sudo launchctl load /Library/LaunchDaemons/<path_to_phpbrew>.plist
Related
I'm writing a webhook to automatically publish a site when I push to GitHub. Part of the process requires that I build the site with
bundle exec middleman build --clean
I'm trying to invoke that with a PHP script, the script called by the GitHub webhook, so the user is www-data. No matter what I try, however, I'm getting an error that bundle cannot be found.
How can I run a bundle command from a PHP script?
I was able to figure this out. First, I installed rvm as a multi-user installation to ensure the www-data account can access it.
$ curl -sSL https://get.rvm.io | sudo bash -s stable
Install the desired ruby version, in my case 2.3.1, then set rvm to use it:
$ rvm install 2.3.1
$ rvm use 2.3.1
Run gem to install any gems that are needed. Because rvm is a multi-user installation, these gems are stored to the system and not your specific user.
$ gem install packagename
I don't know if this is necessary, but I would close the SSH session and reopen it. rvm messes with environment variables, so better safe than sorry.
Run env to print all environment variables. printenv also works if env doesn't for some reason. You'll get a big list of everything set, you only need the ruby-related ones. Do not copy/paste these values, they are examples I pulled from my system. Yours will be different!
PATH=/usr/local/rvm/gems/ruby-2.3.1/bin:/usr/local/rvm/gems/ruby-2.3.1#global/bin:/usr/local/rvm/rubies/ruby-2.3.1/bin:/usr/local/rvm/bin:/home/steven/bin:/home/steven/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-2.3.1
IRBRC=/usr/local/rvm/rubies/ruby-2.3.1/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.3.1
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
rvm_ruby_string=ruby-2.3.1
GEM_PATH=/usr/local/rvm/gems/ruby-2.3.1:/usr/local/rvm/gems/ruby-2.3.1#global
RUBY_VERSION=ruby-2.3.1
Now we need PHP to recognize these variables. You'll need to find the right file on your system, which can be tricky. I don't have a way of knowing which one is correct, I used trial and error.
The file on my system is /etc/php/5.6/fpm/pool.d/www.conf. Add all of the environment variables you previously grabbed into this file with the below format. Note that you DO need PATH in here as well!
env[rvm_path] = /usr/local/rvm
env[rvm_prefix] = /usr/local
Now restart php-fpm. Your service name may be different from mine; I'm using the 5.6 build from ondrej/php.
Ubuntu 15.04 and newer (systemd):
$ sudo systemctl restart php5.6-fpm
Ubuntu 14.10 and newer:
$ sudo service php5.6-fpm restart
Finally, in the script itself you'll need to cd to the directory you're running the bundle command from. My short script is this:
cd /opt/slate
/usr/bin/git reset --hard
/usr/bin/git pull
bundle exec middleman build --clean
cp -R /opt/slate/build/* /var/www/docs
Works for me!
First of all: I only know some basics on linux, but I wanted to try out Phalcon. So I've rented a small v-server with Debian 8 and installed php7.
At the time phalcon was at version 2.1.0r and I followed the tutorials until it seemed to work. Then I've had no time to really start working on it anymore (just created the first to 2 controllers from the tutorial).
Now I do have an idea for a test project and a little time, but I've seen that Phalcon 3.0 is out.
So I went into my cphalcon folder and got the 3.0 branch via git.
With git status I get Your branch is up-to-date with 'origin/3.0.x'.
Then I switched to the "build" folder and ran sudo ./install.
The process ran through without any errors and both /usr/include/php/20151012/ext/phalcon/php_phalcon.h and /usr/lib/php/20151012/phalcon.so are shown as recently updated within their respective folders.
In /etc/php/7.0/fpm/conf.d I do have a link called 30-phalcon.ini that points to /etc/php/7.0/mods-available/phalcon.ini containing only the line extension=phalcon.so
Then I've restarted the server via /etc/init.d/nginx restart.
When I run phpinfo(), it does still show phalcon version 2.1.0r though.
I'll try to get a linux training, but I'd love to try starting on Phalcon until then
The solution:
First, I recompiled via zephir, then I restarted php.
$ cd cphalcon/
$ zephir fullclean
$ zephir compile
$ cd build/
$ sudo ./install
$ /etc/init.d/nginx restart
$ /etc/init.d/php7.0-fpm restart
I don't know if I needed to do all this, but it worked and I'm happy. Thank you all.
For dev branches, e.g 3.0.x always use Zephir:
# PHP 5
$ zephir fullclean
$ zephir build
# PHP 7
$ zephir fullclean
$ zephir build --backend=ZendEngine3
Service php7-fpm restart ? Nginx is not php handler, it's fpm which handles php.
I'm having trouble installing IonCube Loader on my Amazon Linux x64 instance.
I'm following these instructions below but the paths are way off and I can't seem to locate the right ones on my install.
For x64:
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz
Proceed as follows:
cp ioncube/ioncube_loader_lin_5.3.so /usr/lib/php5/20090626/ioncube.so
Now edit to match:
zend_extension = /usr/lib/php5/20090626/ioncube.so
nano /etc/php5/conf.d/ioncube.ini
First, there is no /usr/lib/php5/20090626/ folder. I changed these paths to /usr/lib64/php/modules and included the .so file in there.
However, I cannot seem to locate any ioncube.ini file to edit. Any help is appreciated...
Thank you!
For future readers sake, there is a difference between Amazon's Linux and other versions that most articles online refer to.
You can follow the first two steps above to get the installer, I like to use a temporary folder. Do this as root:
sudo -i
cd /tmp
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz
Copy the required extension to a slightly different folder under EC2 linux instances, and the loader wizard to your webroot:
cp ioncube/ioncube_loader_lin_5.4.so /usr/lib64/php/modules/ioncube.so
Create your ini file:
echo "zend_extension=/usr/lib64/php/modules/ioncube.so" > /etc/php.d/ioncube.ini
Reload Apache (if you're using it):
service httpd restart
I'm using NGINX and PHP-FPM, in this case you'd probably want to restart PHP-FPM as well as NGINX.
Lastly, use the loader wizard to test it by navigating to http://example.com/loader-wizard.php, and delete the temp files and loader wizard when finished:
rm -rf /tmp/ioncube*
rm /var/www/html/loader-wizard.php
I followed the instructions provided here in the first answer, making allowance for the fact that I'm runnning PHP 5.6:
sudo cp ioncube_loader_lin_5.6.so /usr/lib64/php/5.6/modules/ioncube.so
echo "zend_extension=/usr/lib64/php/5.6/modules/ioncube.so" > /etc/php.d/ioncube.ini
However, when restarting Apache, I found that it started then failed immediately. The Apache log gave me this error:
PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0
I changed the name of the file from ioncube.so to 00-ioncube.so and restarted Apache. This solved the problem by making this file load before the other modules.
Hi I have had an incredibly rough time trying to run three cgi-files for a website that i am working on. After reading up a ton, I have honestly found no solution and have tried many recommended solutions. I am on Ubuntu 13.10 and I installed Apache2. Right now I am following these instructions Configure Apache
I go thru all the steps and everything works fine, but I get to this step sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/fiz-ix and it returns this in the terminal.
cp: cannot stat ‘/etc/apache2/sites-available/default’: No such file or directory
I then put the files inside sites-available into a folder in sites-available that i made called default and it sitll didn't work though.
I really need some help. I have invested hours trying to get this to work and I really need to get apache to run CGI-Files soon.
Thanks
After some trial and error with cgi and ubuntu 13.10 the following worked
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/cgi.load .
sudo ln -s ../mods-available/cgid.load .
sudo service apache2 restart
Regards,
Olav
I am newbie in PHP. I have successfully installed PHP on Ubuntu, now I want start my first program. I am using gPHPEdit as IDE.
Where should I save .php files that I create? And how to run/test them?
Make sure you have LAMP installed. Do a sudo tasksel and select lamp then hit enter, its gotta be the most simple *amp install ever made. Its a good idea to install phpmyadmin: sudo apt-get install phpmyadmin. After that just copy the files to /var/www/ and then they will show up on http://localhost. I recommended using Eclipse PDT or the Netbeans build for PHP.
You should pick up a book or start following some good tutorials on the web.
If you are just scripting using php, you can save them anywhere and run the php on the terminal using the php command line interpreter.
If you are trying write web scripts (and I think you are), you need to install and configure a web server (typically apache) and save your scripts in the server's document root (typically /var/www). Also, I highly recommend you to read up a little about servers and HTTP and figure out how all this works on the inside before learning to building websites in php.
If you cannot save or copy to var/www/html, to run your php scripts on your browser. If you are using Ubuntu 14.04.
I followed these steps and it worked for me.
Execute sudo su on the terminal.
Enter your password
Execute sudo subl /etc/apache2/sites-available/000-default.conf on your terminal to open this file. Note you can change the subl to any text editor to open the file e.g sudo nano /etc/apache2/sites-available/000-default.conf.
Change DocumentRoot /var/www/html to /home/user/yoursubdir
Save the file and close it.
Execute sudo subl /etc/apache2/apache2.conf on your terminal to open this file.
Add the following to end of the file
<Directory /home/user/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Save and Close the file.
Execute sudo service apache2 restart
Go to your browser, type the URL of your script e.g 127.0.1.1/directory/document.php.
I hope this helps.
remove the index.html file from /var/www/
$ sudo rm index.html
create a new php file there:
$ sudo gedit /var/www/index.php
write in it:
<?php
print_r(phpinfo());
?>
Restart your Apache2 Server :
$ sudo service apache2 restart
OR
$ sudo /etc/init.d/apace2 restart
and point to yout localhost and /index.php
if err arises visit : http://www.allaboutlinux.eu/how-to-run-php-on-ubuntu/
https://www.php.net/manual/en/features.commandline.webserver.php
this is an easy way to test your files in php.
$ cd ~/public_html
$ php -S localhost:8000
then you can go to your browser and enter localhost:8000/myfile.php.