Vagrant did not install Apache2 nor php - php

I just created a configuration file (it's a zip actually) for my vm on puphpet.com, downloaded the zip, extracted it. Then I run vagrant up in the folder where is located the vagrantfile. The vm is correctly setup under virtualbox, it runs well and the shared folders are working.
However when I access my vm from the host, using 127.0.0.1:7893 it displays : SSH-2.0-OpenSSH_6.0p1 Debian-4. Which is weired since I checked both install php and install apache on puphpet.
I decided to verify their existance on the vm : which apache2, whereis php etc.
Nothing was returned.
So appearently php and apache2 have not been installed, even though the config.yaml file (that I created on puphpet) did specify to install both php and apache2.
At this point, I don't really know what to do (I'm new to php/vagrant/puphpet) :
should I install them myself on the vm with apt-get ?
??
EDIT: during the installation process (vagrant up), I get errors like :
Err http://http.us.debian.org/debian/ wheezy/main linux-headers-3.2.0-4-amd64 am
d64 3.2.51-1
404 Not Found [IP: 64.50.233.100 80]
Fetched 238 kB in 1s (167 kB/s)
Failed to fetch http://http.us.debian.org/debian/pool/main/l/linux/linux-headers
-3.2.0-4-common_3.2.51-1_amd64.deb 404 Not Found [IP: 64.50.233.100 80]
EDIT2: I 'solved' the problem by using a differents virtual machine.

EDIT: during the installation process (vagrant up), I get errors like : ....
Check that you packages db in VM is up to date.
just run
sudo apt-get update
and then try again with apache2 and php installation.

I just ran the default config:
[01:26 PM]-[vagrant#packer-virtualbox]-[~]
$ php -v
PHP 5.5.10-1~dotdeb.1 (cli) (built: Mar 6 2014 18:55:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
Everything looks to be fine on my end.
A couple of things:
You can access the VM from your browser using the IP address you chose during initial config.
Looks like your main issue is that you couldn't connection to the Debian repos. Are you behind a firewall?
To try again, do:
$ vagrant destroy
$ rm -rf .vagrant
$ vagrant up

I had the same problems when I opted for CentOS.
Where did the choosing Debian, the problems stopped occur.

Related

Apache on Mac M1 Silicon will not load xdebug.so - "code signature not valid for use in process"

I'm setting up a new macbook (Monterey 12.2.1 chip Apple M1 Pro), and installed PHP 7.4 with homebrew. I configured PHP to run as a module for the Apache2 server that comes with MacOS (Apache/2.4.51). I immediately ran into trouble because gatekeeper wouldn't allow me to run php as an apache module from homebrew until I codesigned it. I did codesign it:
codesign --sign "Mike Andersen" --force --keychain ~/Library/Keychains/login.keychain-db /opt/homebrew/opt/php#7.4/lib/httpd/modules/libphp7.so
And afterwards PHP worked perfectly. Then I installed xdebug with PECL:
arch -x86_64 sudo pecl install xdebug
When I checked it from the command line, everything looked right:
php -v
PHP 7.4.28 (cli) (built: Feb 28 2022 07:33:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
with Xdebug v3.1.3, Copyright (c) 2002-2022, by Derick Rethans
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/7.4
Loaded Configuration File: /opt/homebrew/etc/php/7.4/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/7.4/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/7.4/conf.d/20-ext-opcache.ini,
/opt/homebrew/etc/php/7.4/conf.d/99-xdebug.ini
But loading from a browser failed - the browser listed the 99-xdebug.ini file:
Additional .ini files parsed /opt/homebrew/etc/php/7.4/conf.d/20-ext-opcache.ini, /opt/homebrew/etc/php/7.4/conf.d/99-xdebug.ini
But nothing else about xdebug. I checked the apache error log and saw:
Failed loading /opt/homebrew/lib/php/pecl/20190902/xdebug.so:
dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 0x0009):
tried: '/opt/homebrew/lib/php/pecl/20190902/xdebug.so'
(code signature in <8E9B311F-7332-3812-89A8-91BA8FB71682> '/opt/homebrew/lib/php/pecl/20190902/xdebug.so'
not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)),
'/usr/lib/xdebug.so' (no such file)
I tried signing the xdebug.so file as well:
codesign --sign "Mike Andersen" --force --keychain ~/Library/Keychains/login.keychain-db /opt/homebrew/lib/php/pecl/20190902/xdebug.so
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: replacing existing signature
And restarted apache, but still got the same error in the apache log. I've also tried re-signing PHP, no help. I've also tried disabling gatekeeper:
sudo spctl --master-disable
That made no difference either.
I've been googling this all morning, and can't find anything about how to address this problem. Somebody must have seen this by now, so I'm hoping one of you is that somebody and can help a brother out. Thanks in advance for any help you can offer.
It looks like the simplest way to fix this problem is to not use the Apache that Apple ships with Mac OS.
I installed apache with brew:
brew install apache2
And updated the httpd.conf file for brew to use port 80, and to point to Exactly. The. Same. Libphp7.so file that I used for Apple's Apache. No re-compiling, no codesign, nothing. Then I stopped and disabled Apple's Apache:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo apachectl stop
And finally, restarted brew's apache:
brew services restart httpd
Reloaded my phpinfo file, and all the xdebug goodness was there. First try!
I think the root problem here is that Apple compiles Apache to insist on codesigning, and then makes codesigning opaque and difficult. I'd still love to know if there's a real solution to this problem, but until then, use Brew's Apache and you should be good to go.
If you need help with codesigning PHP, this is the guide I used:
https://www.simplified.guide/macos/apache-php-homebrew-codesign

Postgresql database with PHP server error on MacOS Bash

I ran a PHP server with postgresql on my college computers which works fine, however on my local machine (which runs MacOS), I get the following error message:
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
Now, I thought it's an issue of missing the postgresql packages for php, so I used brew to install the php postgresql packages. I ran the following commands:
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
However, even after running these commands I get the same error when running the php server, i.e.
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
The php version I have is 5.5.30:
mac$ php -v
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
Please could you suggest what I am doing wrong to install the packages. I read on stack overflow that the packages can be installed with an apt-get command on linux, however I'm not sure as to what the solution is with the Mac operating system.
Thanks in advance.
The solution was edit the php.ini on your server then find this below line and uncomment that line.
extension="pgsql.so"
then restart the server apache and test it out again.
Also, check this link for the steps regarding installation of the postgress to mac OS.

Class Memcached Not Found Lumen 5.4

When trying to run artisan commands I get the following error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Memcached' not found
I had recently been been working on another project that used Lumen 5.3 and had no problem running artisan commands. Both projects are on the same virtual box and apart from the Lumen versions there is no differences in server setup.
I've checked that Memcached is running and there is no problems.
I've tried composer dump-autoload, deleting the vendor folder and re-installing but none of these have made a difference.
I'd prefer not to have to go back to 5.3 if possible.
Is there a way to solve this issue?
Had the same problem.
Check if you have the memcached extension installed for the php version that you're using, and check also if it is correctly configured in the php.ini file (it could be looking in the wrong directory).
looks like your memcahed is not installed or not properly configured.
for quick solution ,
use file cache driver instead of memcached
CACHE_DRIVER=file
Ubuntu 16.04 LTS, try this:
sudo apt-get install php-memcached
Just to add to the os specific responses. Here is the one using OS/X and homebrew.
First you have to determine which version of PHP you're using locally.
$ php -v
PHP 7.0.19 (cli) (built: May 21 2017 11:56:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
$ brew search memcached
homebrew/php/php53-memcached homebrew/php/php70-memcached
homebrew/php/php54-memcached homebrew/php/php71-memcached
homebrew/php/php55-memcached libmemcached ✔
homebrew/php/php56-memcached memcached ✔
Since I'm running PHP 7.0 I chose to install homebrew/php/php70-memcached
$ brew install homebrew/php/php70-memcached
If you don't have homebrew installed go to https://brew.sh/ and install it to use these instructions. This was the command last time I used it.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once I was done with all that then I tested by clearing the cache.
$ php artisan cache:clear
Cache cleared successfully.
$
Cheers, this fixed it for me for local development.
If you are on Mac OSX, you will need to install Memcached and its PHP dependencies via Homebrew.
brew update
brew doctor
brew install memcached
Then check your PHP version and install your relevant PHP hooks for Memcached.
php -v
in my case...
PHP 7.1.4 (cli) (built: Apr 14 2017 15:02:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
So I used:
brew install php71-memcached
But you can lookup your required version using
brew search memcached
Once you have performed these steps you will probably get a new error
No Memcached servers added.
So fire it up with
brew services restart memcached
Done!

Install php 5.4 on Ubuntu 16.04 Xenial

I want to install php5.4 on Ubuntu 16.04 (Xenial). I know it's obsolete but I came across an old application which I need test before updating the code to be compatible on php7.
When I do the following:
apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
sudo apt-get install -y php5
and check with php -v, it shows php5.6 installed.
This is the output from php -v:
PHP 5.6.28-1+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.0rc1, Copyright (c) 2002-2016, by Derick Rethans
(Steps followed as at http://tecadmin.net/install-php5-on-ubuntu/)
Is there a way I can force php5.4 to be installed instead of letting it chose whatever php5 package it finds?
I have tried with apt-get install -y php5.4 but that does not work.
Edit: Since the app was going to be used for a long time, I decided to change the whole application to php7-ready code instead. If anyone else wants to do this, be careful to test the application on different browsers and also on the OS you will be hosting the application (very important!). Took me some time but I guess it's worth it in the long run! Thanks for your help!
**EDIT:**Scratch My suggestion below. It doesn't declare the Ubu image in the Vagrantfile. Oops. Like I said, I'm a wee bit wet under the wings in all things *nix.
I'll still leave just in case it causes you to think of something.
If you run vagrant, you might be able to swap Trusty for Xeny in the scotch.io box Vagrantfile (github link) and spin it up. It's still on PHP 5.6. I've only been on linux for a month or so, so not sure how universal Vagrantfile scripts are across Ubu versions. I'm running Trusty in Azure and Xeny in Vultr and locally on desktop and laptop and haven't seen any big differences regarding web dev stuff.
https://box.scotch.io/
https://github.com/scotch-io/scotch-box
git clone https://github.com/scotch-io/scotch-box.git my-project
Features
Server Stuff
Ubuntu 14.04 LTS (Trusty Tahr)
PHP 5.6
Ruby 2.2.x
Vim
Git
cURL
GD and Imagick
Composer
Beanstalkd
Node
NPM
Mcrypt
Database Stuff
MySQL
PostreSQL
SQLite
MongoDB
Caching Stuff
Redis
Memcache and Memcached
Node Stuff
Grunt
Bower
Yeoman
Gulp
Browsersync
PM2
Laravel Stuff
Laravel Installer
Laravel Envoy
Blackfire Profiler
Mailcatcher
First: `vagrant ssh`
Run: `mailcatcher --http-ip=0.0.0.0`
Then visit: http://192.168.33.10:1080
Other Useful Stuff
WP-CLI
No Internet connection required
PHP Errors turned on
No Internet connection required
Laravel and WordPress ready
Operating System agnostic

How to update the path of PHP to the new version I just installed on mac osx mountain lion?

first I am new to macs, I just installed PHP 5.4.6 on my machine after downloading the PHP package from http://www.php.net, I unzipped it and navigated to the directory through the terminal, then I ran the following commands:
./configure --with-config-file-path=~/php-5.4.6/php.ini
make
make test
sudo make install
I restarted the Apache with sudo apachectl graceful but and when I gone to the info.php it still said PHP 5.3.13 the default version that macs shipped with, I tried to run echo $PATH I got this result /usr/local/php5:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin when I searched the internet they said something about changing the path because the default PHP is installed on /usr/local/php5 and the new one is installed on /usr/local/bin/, when I run /usr/local/bin/php -v I get
PHP 5.4.6 (cli) (built: Aug 18 2012 22:52:55)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
So I wanted to know how to update that path.
Thanks in advance and sorry for being long.
You will need to point your httpd.conf configuration to use your new mod_php library... assuming that you passed the proper --with-apxs2 flag during the build.
If using the built-in Apache server, see: /etc/apache2/httpd.conf
LoadModule php5_module <MY_NEW_PATH>/libphp5.so

Categories