Run yii project using hhvm - php

How can I start Yii2 project using HHVM?
Run
hhvm yii serve
but I got the following error:
Server started on http://localhost:8080/
Document root is "/home/hgminh95/Documents/pk-homepage-server/web"
Quit the server with CTRL-C or COMMAND-C.
Error in command line: unrecognised option '-S'
Usage:
/usr/bin/hhvm [-m <mode>] [<options>] [<arg1>] [<arg2>] ...

HHVM is linux only. It doesn't have anything for Windows and for MacOS it works in limited mode without JIT compiler.
Check this
https://yii2-cookbook.readthedocs.io/performance-hhvm/
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
echo deb http://dl.hhvm.com/debian wheezy main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm

Related

Is Ubuntu 21.04 compatible with PHP sqlsrv driver?

I have a web system developed with PHP + MS Sql Server and I do maintenance on Windows environment. But I prefer working in Linux environment, Ubuntu to be more accurate.
But I cannot find a way to install this database driver. I googled but I cannot find any solution. Some tutorials shows how to install in 20.04, 18.04 versions, but even following the steps to the letter, I could no install.
Some tutorials that did not worked.
How to Install the PHP SQLSRV Extension
Linux and macOS Installation Tutorial for the Microsoft Drivers for PHP for SQL Server
Any suggestions?
It seems, at least today, that msodbcsql17 mssql-tools are not available in the Ubuntu 21.04 repos...
$ curl -s https://packages.microsoft.com/config/ubuntu/21.04/prod.list
deb [arch=amd64,armhf,arm64] https://packages.microsoft.com/ubuntu/21.04/prod hirsute main
$ curl -s https://packages.microsoft.com/ubuntu/21.04/prod/dists/hirsute/Contents-amd64.gz | gzip -d | grep -E "msodbcsql|mssql"
# No output.
As a result you'll get errors when you try to install them via apt-get:
$ curl -s https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ sudo bash -c "curl -s https://packages.microsoft.com/config/ubuntu/21.04/prod.list > /etc/apt/sources.list.d/mssql-release.list"
$ sudo apt-get update --yes
# ...
$ sudo ACCEPT_EULA=Y apt-get --verbose-versions --yes install msodbcsql17 mssql-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package msodbcsql17
E: Unable to locate package mssql-tools
Update
I have written a bash script to automatically install the appropriate drivers for Ubuntu or Debian: https://github.com/sfinktah/bash/blob/master/add_sqlsrv_repo_combined.sh
I couldn't test support for other Linux vendors, but the capability is there if someone wants to send a PR.
Original Post
21.04 drivers are now available.
Follow the instructions on
https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15 and https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17
Or as above:
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version
# Automatic version selection (does not work for 21.10, but 20.10 or 21.04 are fine)
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -r -s)/prod.list > /etc/apt/sources.list.d/mssql-release.list
# Manual specification: Ubuntu 21.04
curl https://packages.microsoft.com/config/ubuntu/21.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev

Running composer command not woking in an EC2 AWS instance in user data script

There's a shell script that works partially when in a bootstrap script in Amazon Linux EC2 instance (script as user data setted before instance launching). And I still doesn't know why it not works when as a bootstrap script.
The script does the following:
Updates operating system packages
Installs Apache2 webserver
Sets the webserver to start everytime the system is booted
Installs PHP with amazon installer utility
Restarts the webservice
Downloads and installs Composer
Installs WordPress using Composer
This is the script:
#!/bin/bash
echo Bootstrap script starting at $(date) >> /home/ec2-user/log-bootstrap.txt
echo Updating OS and installing webserver at $(date) >> /home/ec2-user/log-bootstrap.txt
yum update -y
yum install httpd -y
chkconfig httpd on
service httpd start
echo Installing PHP at $(date) >> /home/ec2-user/log-bootstrap.txt
amazon-linux-extras install php7.4 -y
service httpd restart
echo Installing Composer at $(date) >> /home/ec2-user/log-bootstrap.txt
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
echo The composer version is $(/usr/local/bin/composer --version) >> /home/ec2-user/log-bootstrap.txt
echo Installing Wordpress. Time: $(date) >> /home/ec2-user/log-bootstrap.txt
cd /var/www/html
/usr/local/bin/composer create-project johnpbloch/wordpress .
shutdown -P +5
The intent is to do everything in the machine at startup time by user data script.
The script works until the Composer installation. But the line echo The composer version is $(/usr/local/bin/composer --version) >> /home/ec2-user/log-bootstrap.txt was the first line showing some problem. It does not executes the part of $(/usr/local/bin/composer --version). It saves the echo in the file, but where it whould print the composer version remains empty.
But further analysis shows that Composer has been succesfully installed. I can put exact same remaining lines from script and everything works great, but just when I access the machine through ssh and execute the remaining code. Installing WordPress using composer works as well. Composer does not works only when it is in the user data script.
I tried to simulate the problem by two ways:
Printed the whole script in the clipboard and past direct in the terminal, after a ssh login in the machine.
Created a shell script file with this exact content, send to the machine through scp and executes it inside the machine.
In both cases the script works perfectly! And I did not forget to change to sudo before trials to simulates something more similar when the machine is executing the bootstraping script.
Does someone knows how to install and run composer in the same script for an Amazon machine in the user data? Why just the Composer does not works only if it is in an user data script from Amazon instance, although Composer was successfully downloaded and remains executable when access machine through ssh?
The composer will require export HOME=/root set. I tested it and it installs successfully with:
#!/bin/bash
echo Bootstrap script starting at $(date) >> /home/ec2-user/log-bootstrap.txt
echo Updating OS and installing webserver at $(date) >> /home/ec2-user/log-bootstrap.txt
yum update -y
yum install httpd -y
chkconfig httpd on
service httpd start
echo Installing PHP at $(date) >> /home/ec2-user/log-bootstrap.txt
amazon-linux-extras install php7.4 -y
service httpd restart
echo Installing Composer at $(date) >> /home/ec2-user/log-bootstrap.txt
export HOME=/root
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
echo The composer version is $(/usr/local/bin/composer --version) >> /home/ec2-user/log-bootstrap.txt
echo Installing Wordpress. Time: $(date) >> /home/ec2-user/log-bootstrap.txt
cd /var/www/html
/usr/local/bin/composer create-project johnpbloch/wordpress .
shutdown -P +5

/usr/bin/env: �php\r’: No such file or directory

I have a problem during Propel ORM configuration.
I prepared environment on my Vagrant with PHP 7.1 following this provision file:
# Install software
add-apt-repository ppa:ondrej/php
apt update
apt install python-software-properties
apt update
apt install -y apache2
apt install -y php
apt install -y php-mcrypt
apt install -y php-mysql
apt install -y php-curl
apt install -y php-cli
apt install -y php-xml
apt install -y libapache2-mod-php
apt install -y mc
# install composer, configure Apache and create database
service apache2 restart
/etc/init.d/mysql restart
Currently I want to install Propel ORM. I added Propel to composer, installed, and now I type (by SSH in Vagrant)
/var/www/application/Vendors/bin/propel init but unfortunately I get error:
/usr/bin/env: �php\r’: No such file or directory
What can I do to resolve it?
EDIT:
File that I run (not edited, installed via Composer):
#!/usr/bin/env sh
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../propel/propel/bin" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/propel" "$#"
I don't use propel but had the same problem with phpunit.
The problem is often that the vendor/propel/propel/bin/propel, or in my case the vendor/phpunit/phpunit/phpunit file you try to execute is Windows encoded and not Unix encoded. It happens when you do composer install/update on Windows but run your code in a vagrant box.
You have multiple ways of getting rid of the CRLF:
dos2unix command (sudo apt-get install dos2unix)
use your prefered text editor (Sublime, PHPStorm, they can both do that)
get rid of vendor and run composer install/update from your vagrant box
Remember that the problem is not the vendor/bin/propel file but the vendor/propel/propel/bin/propel file.
Hope this help!

Installing PHP driver for Cassandra

I create server on linode and installed Ubuntu 15.10 and in my console, enter command for install php
apt-get update
apt-get install -y php5
sudo apt-get install php5-dev
Then, I Installed software: boost, openssl, libtool и cmake
sudo apt-get install libboost-all-dev
sudo apt-get install openssl
apt-get install cmake
sudo apt-get install automake libtool curl
curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src
cd /usr/local/src/libuv-1.4.2
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/
sudo ldconfig
sudo apt-get install libssl-dev
And then, I installed cassnadra use datastax documentation
echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
sudo apt-get update
sudo apt-get install dsc20=2.0.11-1 cassandra=2.0.11
I checked cassnadra
sudo service cassandra status
and i get it:
● cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra)
Active: active (running) since Mon 2016-02-08 09:12:59 EST; 21s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/cassandra.service
└─27880 java -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+CMSClassUnloadingEnabled -XX:+UseThreadPriorities -XX:Threa...
Feb 08 09:12:59 ubuntu systemd[1]: Starting LSB: distributed storage system for structured data...
Feb 08 09:12:59 ubuntu systemd[1]: Started LSB: distributed storage system for structured data.
I check the status of the cluster and cqlsh:
sudo nodetool status
and get:
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 41.32 KB 256 100.0% 2eaa4bd9-136d-4c2a-a65e-7444eb9d8824 rack1
and:
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.11 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
Everything is working! finally I try install PHP Driver for Cassandra use this:
git clone https://github.com/datastax/cpp-driver.git
cd cpp-driver
cmake . && make && make install
ln -s libcql.so.0.7.0 /usr/lib/libcql.so.0
ln -s /usr/lib/libcql.so.0 /usr/lib/libcql.so
git clone https://github.com/aparkhomenko/php-cassandra.git
cd php-cassandra
phpize && ./configure && make
But I get Error
checking for specified location of CQL library... yes, shared
checking for CQL in default path... not found
configure: error: Please reinstall the cassandra distribution
Where is my mistake?
I think that the problem is that you are installing the Cassandra's driver for C/C++:
git clone https://github.com/datastax/cpp-driver.git
Instead, you have to use the PHP one:
git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext
./install.sh
Then, add the extension in the php.ini.
For apache2:
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php5/cli/php.ini
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php5/apache2/php.ini
/etc/init.d/apache2 reload
Everything you did prior to that was ok.
Source: https://github.com/datastax/php-driver/blob/master/ext/README.md

PHP version is wrong in phpinfo() output

I run my web application in nginx server with php-fpm version on debian wheezy, inside a docker container.
I update my php version to 5.6.1.
RUN echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list
RUN echo "deb-src http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list
RUN echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list
RUN echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list
RUN wget http://www.dotdeb.org/dotdeb.gpg
RUN apt-key add dotdeb.gpg
RUN apt-get update
RUN apt-get install -y nginx php5-fpm php5-mysqlnd php5-cli supervisor
If I do the following commands inside my container, version is ok and seems correctly updated:
php -v // 5.6.6
/usr/sbin/php5-fpm -v // 5.6.6
But if I go to my document root and do phpinfo(), the php version is wrong in Core -> PHP version (5.4.36, the default one with debian:wheezy). More nginx version output is wrong too.
Any ideas ?
Run the following command.
If apache
sudo service apache2 restart
If nginx
sudo service nginx restart
After you install any server modules, it is a good habit that you restart your apache,nginx.
All right, it was a "docker-compose" misunderstanding.
I needed to do a docker-compose up -d to rebuild, recreate and restart my services.

Categories