AWS EC2 standard AWS AMI with PHP 7.0 - install libsodium recipe - php-7

(edited for clarity - rolled in accepted answer)
Libsodium has been prepped for PHP 7. In doing this, the namespace was removed and a prefix of sodium_ for methods and SODIUM_ for constants was added. Also the version methods were removed.
This github page documents all the new functions and constants and the project provides backward compatibility with the \Sodium namespace: https://github.com/Firehed/sodium/blob/master/src/we_cant_have_nice_things.php
Recipe: install Libsodium on PHP 7 on and AWS AMI
# PHP 7.0 Libsodium install AWS AMI
yum install -y php7-pear re2c php70-devel
yum groupinstall -y "Development Tools"
pecl7 install libsodium
vi /etc/php-7.0.d/20-libsodium.ini
; Enable libsodium extension module
extension=sodium.so
service httpd restart
command line test to verify sodium is installed
php7 --info | grep sodium
test php function to verify calling pattern for password hash
<?php
$password = "hello";
$hash_str = sodium_crypto_pwhash_str(
$password,
\SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
\SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
var_dump($password, $hash_str);
Thanks to #GracefulRestart for the help.

I see a couple problems here, the first is that your test file appears to be non-functional.
Running your test code with libsodium working in PHP 7 returns the following error:
PHP Fatal error: Uncaught Error: Call to undefined function Sodium\\library_version_major()
If you want to check the version, it may be easier to search the data from the phpinfo() function:
<?php phpinfo(); ?>
# or from CLI
php7 --info |grep sodium
The other problem I notice is in your install steps, you install libsodium both from source and from PECL. The make install command by default places the libraries in /usr/local/lib, while pecl7 install libsodium will normally install libraries into the default PHP modules directory.
If you were attempting to install from source, your /etc/php-7.0.d/20-libsodium.ini file is incorrect as that is loading the libsodium libraries you installed from PECL (you can check which directory it is loading from by check the extension_dir ini setting from phpinfo()).
If you only need to install from PECL, you do not need all of the development packages or any manual compiling.
EDIT I modified your posted recipe to remove the extraneous steps of downloading the source and just do everything with PECL:
yum install -y php7-pear re2c php70-devel
yum groupinstall -y "Development Tools"
# PHP 7.0
pecl7 install libsodium
vi /etc/php-7.0.d/20-libsodium.ini
; Enable libsodium extension module
extension=sodium.so
service httpd restart
If the YUM repositories for your distribution offer the php7-libsodium package, that would be an even smaller recipe
Hope that helps

Here's my solution to this recipe.
wget -c https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz
tar -xvf libsodium-1.0.18.tar.gz
cd libsodium-1.0.18
./configure
make && make check
make install
sudo pecl7 install -f libsodium
pecl7 should install and modify the php.ini file to include the following in the php.ini
extension="sodium.so"
If you running PHP in Elastic Beanstalk, the following file ./ebextentions/script.config :
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/001_libsodium.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
wget -c https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz && tar -xvf libsodium-1.0.18.tar.gz && cd libsodium-1.0.18 && ./configure && make && make check && sudo make install && sudo pecl7 install -f libsodium

Related

How to install PhantomJS on vps?

I tried to use pip install, but it tells cannot find such package.
I also see someone say we can use brew and nodejs to install. This is what I tried to install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It returns that ruby doesn't found.
I have no idea about nodejs.
Anyone knows how can I install PhantomJS in the server?
Meet npm!
Npm stands for Node Package Manager.
You can install packages for using them from the CLI or from your nodejs app.
You can install NPM from here.
If node isn't installed yet, you can use NVM, which makes it really easy -
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
For your question,
See this specific package.
You can install it via:
$ npm install phantomjs-prebuilt
And then you should be able to: $ bin/phantomjs [phantom arguments] to run phantomJS from the terminal.
PhantomJS is a standalone application with its own website which has binaries for all major platforms and documentation. You don't really need pip or npm or bundler to install it, just do it manually.
Go to http://phantomjs.org/download.html
Choose the appropriate binary (Linux x32 x64 / OSX / Windows), download archive, extract it and run the binary.
For example you have a x64 Linux distribution.
Log in to your server via ssh.
Go to your home directory:
cd ~
Download PhantomJS binary:
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Extract archive:
tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
A new directory is created: phantomjs-2.1.1-linux-x86_64. The PhantomJS binary is phantomjs-2.1.1-linux-x86_64/bin/phantomjs. You can run it right now:
~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs --version
2.1.1
(If it says "not found " instead that means you chose the wrong distribution, e.g. x64 instead of x32).
But this way of running it is inconvenient. It would be way better to be able to just type phantomjs script.js in any directory. To make it so add a link to a directory where binaries are kept by default:
sudo ln -s ~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
Then you can call PhantomJS from anywhere:
cd /var/www/
phantomjs --version
2.1.1

Which file extension should be in for MediaWiki installation for pecl issue

I am trying to install Mediawik in my ubuntu apache2 server.
As the Mediawiki installation page shows up
Warning: The intl PECL extension is not available to handle Unicode normalization, falling back to slow pure-PHP implementation.
I had followed some searched article as follow :
sudo apt-get install php-pear
You will be prompted to confirm the install. Just press “y” and enter. If all goes well you should see it download and install the php-pear package.
Now you will need to install the php5-dev package to get the necessary PHP5 source files to compile additional modules. Enter the following from a shell prompt:
sudo apt-get install php5-dev
If you do not install the php5-dev package and try to install a PECL extension using “pear install”, you will get the following error:
sh: phpize: not found
ERROR: `phpize’ failed
The PECL_HTTP extension requires an additional dependency package to be installed. You can probably skip this for other extensions:
sudo apt-get install libcurl3-openssl-dev
Now we are finally ready to actually install the extension. From a shell prompt enter following but substitute “pecl_http” with the PECL extension name you are installing:
sudo pecl install pecl_http
now I can't figure out what file extension name should go in the "pecl_http" side.
Try sudo apt-get install php5-intl.

implement janus gateway for webrtc

I am following janus documentation to build a video mcu system. I installed all the dependencies of it according to the read me file.
http://janus.conf.meetecho.com/docs/
after that when I run the script using sh install.sh I am getting following error
In file included from test.c:1:0:
../websock/src/websock.h:55:26: fatal error: event2/event.h: No such file or directory
#include <event2/event.h>
^
compilation terminated.
make[1]: *** [test.o] Error 1
make[1]: Leaving directory `/home/gayan/MyDetails/MyApplications/virtualClassRoomTest/janus-gateway/wstest'
make: *** [wstest] Error 2
The installer couldn't find the libwebsock lib, which is needed for WebSockets
You can install version 1.0.4 (required!) with the following steps:
wget http://paydensutherland.com/libwebsock-1.0.4.tar.gz
tar xfv libwebsock-1.0.4.tar.gz
cd libwebsock-1.0.4
./configure --prefix=/usr && make && sudo make install
[Note: you may need to pass --libdir=/usr/lib64 to the configure script if you're installing on a x86_64 distribution]
If you're not interested in WebSockets support, you can disable them passing nowebsockets to the install script:
./install.sh nowebsockets
I also install the libwebsock according to the above steps, but still the error is showing. event2 directory is not in the janus-gateway codes. here is the github link for all the source code. https://github.com/meetecho/janus-gateway.git
Any kind of help would be appreciated.
The full installation steps to have websockets working(Ubuntu 14) are:
mkdir -p ~/build
sudo apt-get install libmicrohttpd-dev libjansson-dev libnice-dev libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev libini-config-dev libcollection-dev libwebsockets-dev pkg-config gengetopt automake libtool doxygen graphviz git cmake
sudo apt-get install libavformat-dev
echo "Start installing libwebsockets"
cd ~/build
git clone git://git.libwebsockets.org/libwebsockets
cd libwebsockets
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT=ON ..
make && sudo make install
echo "Start installing Janus"
cd ~/build
git clone git://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --disable-data-channels --disable-rabbitmq --disable-docs --prefix=/opt/janus LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CFLAGS="-I/usr/local/include"
make && sudo make install
sudo make configs
Make sure to copy certificates if using wss, chrome is really picky about that stuff. If using self signed certificates you have to trust them in chrome(very intuitive procedure:)))
sudo cp mycert.pem /opt/janus/share/janus/certs/
sudo cp mycert.key /opt/janus/share/janus/certs/
I had this problem and solve it after
sudo apt-get install libevent-dev
My system is ubuntu 14.04 64 bit

PHP Fatal error: Class 'Phalcon\Script\Color' not found

I'm running Ubuntu Server 12.10 and have installed phalcon like this
sudo apt-get install php5-dev php5-mysql gcc git-core
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
then I've added
extension=/usr/lib/php5/20100525/phalcon.so
to php.ini which located in /etc/php5/apache2/php.ini and restarted apache2. If I execute
<?php print_r(get_loaded_extensions()); ?>
I can see that the phalcon extension is loaded. Then I've installed phalcon-devtools like that
git clone git://github.com/phalcon/phalcon-devtools.git
cd phalcon-devtools
sudo ./phalcon.sh
and restarted apache2. No errors were shown during that operations, but when I'm trying to execute
phalcon commands
I get an error like this
PHP Fatal error: Class 'Phalcon\Script\Color' not found in /home/user/phalcon-devtools/phalcon.php on line 84
What I'm doing wrong?
So the problem was in php.ini for CLI, which is located in /etc/php5/cli/, after I added extension=/usr/lib/php5/20100525/phalcon.so there, I was able to use Devtools. Thanks to #NikolaosDimopoulos
Official documentation is a bit confusing so try this:
I think this is a problem of extension not loaded
After successfully compile steps:
sudo apt-get install php5-dev php5-mysql gcc git-core
git clone git https://github.com/Phalcon/cphalcon.git
cphalcon cd/build
sudo ./install
Create a new file called "30-phalcon.ini"
and within it call the extension Phalcon with this single line:
extension=phalcon.so
save the file and copy the folder "/etc/php5/apache2/conf.d /" and "/etc/php5/cli/conf.d/"
restart the server: sudo service apache2 restart
While the devtools do this:
sudo git clone https://github.com/phalcon/phalcon-devtools /var/www/devtools
then create a symbolic link to run via terminal:
1: sudo ln -s /var/www/devtools/phalcon.php /usr/bin/phalcon
2: sudo chmod ugo+x /usr/bin/phalcon
3: type "phalcon" in the terminal and see if it's work.
it should work now: D
I always install the devtools from the PEAR channel
pear channel-discover pear.phalconphp.com
pear install phalcon/Devtools
You might get an error that the Devtools are not in stable mode but (as of the time of this writing) you can use this command:
pear install phalcon/Devtools-0.5.0
Source

Upgrade native apache from 2.2.21 to 2.4.2 - Lion 10.7.4

As stated in the title, i have apache 2.2.21 running natively as part of my LAMP stack. I would like to upgrade apache to the latest version - 2.4.2. Is there a recommended or best practice to safely perform this operation without breaking stuff of loosing existing settings, etc?
Thank you for the time and direction.
I was able to install the latest version (2.4.2) using the steps below.
Install pcre (perl compatible regular-expression library) using fink (or what ever osx package manager you use)
$ fink install pcre
Install the latest (2.4.2 as of writing this) using the steps below
$ sudp apachectl stop
$ cd ~/Downloads/
$ curl -O http://mirror.uoregon.edu/apache//httpd/httpd-2.4.2.tar.gz
$ gzip -d httpd-2.4.2.tar.gz
$ tar xvf httpd-2.4.2.tar
$ cd httpd-2.4.2
$ ./configure
$ make
$ sudo make install
However, the new binaries got installed under /usr/local and doesn't seem to have overridden the default install locations on OSX lion. And I could not find a config.nice file to use as suggested by the apache upgrade documentation.
The original apache files httpd, apachectl and ab were located on /usr/sbin. Without having found any documentation to confirm this was the right thing to do, I went ahead and backed up the original files and sym-linked the new files from /usr/local/bin into /usr/sbin, as follows.
$ cd /usr/sbin
# backup the original files ...
$ sudo ln -s ../local/bin/ab ab
$ sudo ln -s ../local/bin/apachectl apachectl
$ sudo ln -s ../local/bin/httpd httpd
This seems to have worked, although it would be nice to get a confirmation from someone in the know.