installing php.5.5 with mcrypt on AWS Linux - php

This is kind of a n00b question, but I'm a much better developer than a sys admin.
Im setting up an Amazon Linux instance on EC2 and can't seem to get php 5.5 with mcrypt installed. yum seems to throw php 5.3 at me each time i try to do a group install or just as a dependency of mcrypt.
Any suggestions? This is for a Laravel 4.1 application.
Thanks!

If you are using amazon linux, you will need to install the php packages that start with php55.
Older packages are kept for compatability.

Since start configuring an EC2 instance can be tricky and indeed there is not much available support or documentation at the date I'm writting this answer, I'll post the steps I followed that worked for me. So I hope it will be useful to someone else:
Start an EC2 instance as described on the AWS documentation. Do not use elastic beanstalk for deploying your php app.
Start you PuTTY session, it is well described on the AWS documentation.
When PuTTY session is on, install in the following order: apache server (v 2.4), php55, php55-mcrypt, php55-pdo and mysql55
sudo yum install httpd24
sudo yum install php55
sudo yum install php55-mcrypt
sudo yum install php55-pdo
sudo yum install mysql55
Check your server properly working sudo service httpd start. If succesfully installed, you'll see 'OK' and you should be able to see a sample page in the public DNS.
Add a group in order to allow "ec2-user" modifying and writing files inside var/www/html
sudo groupadd www
sudo usermod -a -G www ec2-user
Exit PuTTY and reenter again (so changes will be applied) exit
Reconnect and check membership
groups
Modify permissions on writing and editing files
sudo chown -R root:www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
find /var/www -type f -exec sudo chmod 0664 {} +
Test your server
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
sudo service httpd restart
visit http://publicdomain/phpinfo.php. If properly working (it should) it will display the php info page.
All these steps worked well for me after hours dealing with php versions that are not compatible with laravel 4.1>=

Related

Install symfony project using sudo or not

I am learning how to use the Symfony framework to do PHP web applications. When you install a new project, it warns me because it cannot create cache repository because is not writable. But when I start a new project with sudo keyword, the terminal complain about running the composer as a root/user.
So I don't know if I start a new project using sudo keyword or not? What is the correct?
You actually can use sudo when using composer in spite of the warning. The resulting project will work just fine.
I ran into this after installing a linux subsystem under Windows 10. For some reason my $HOME/.composer directory ended up being owned by root. I guess it was a byproduct of the composer install process. I didn't bother to figure out why for awhile. Just used sudo.
But it would be better to go ahead and just fix the directory using basic linux commands:
cd $HOME
sudo find .composer -exec chown myusername {} \;
sudo find .composer -exec chgrp myusername {} \;
And that should take care of the problem.

Getting some errors when installing Magento via XAMPP

I have a problem when you want to install Magento via XAMPP for Linux (I use 32-bit Ubuntu), some of the output error in the browser :
screenshoot
I tried changing the file permissions :
sudo chown -R www-data:www-data /opt/lampp/htdocs/shit
and
sudo chmod -R 755 /opt/lampp/htdocs/shit
After that I restart the apache2 :
sudo service apache2 restart
I tried to find a solution in Google, but it does not work, then what is the problem?
Is there a solution?

PHP code is rendered as text

I'm using Ubuntu 16.04 and I want to run php files.
I installed Php 7 on it using:
sudo mkdir -p /var/www/html
sudo chown -R $USER:$USER /var/www/html
sudo apt install php
sudo apt install apache2
I created a php file (e.g. test.php) in /var/www/html. I can access it in the browser (e.g. http://localhost/test.php). Instead of executing the <?php ... ?> code, it is displayed as plain text:
I tried to turn short_open_tag to On. So I edited the /etc/php/7.0/fpm/php.ini and enabled it.
Then I ran sudo service php7.0-fpm restart. This didn't make any change in the browser. The php code is still displayed as plain text.
How can I fix this?
You didn't install apache properly, doing an apt-get on apache2 does not install everything.
what #newman stated is correct you can follow that guide, or here is a digitalocean link that is usuable for production server (since you would do this on a droplet). Note this is full stack LAMP, which I would assume you would get to eventually when you want to dab with mysql
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04

Any docs about V8JS in PHP?

Is there any documentation about V8JS?
Do I need only standard PHP or some extensions to use V8JS?
I'll be very thankful for any information about V8JS in PHP.
Requirements
PHP 5.3.3+ and V8 library and headers installed in proper paths.
Install
I've found this docs on the v8js class.
The docs out there aren't complete or are not updated. I'm actually currently in the process of doing v8JS myself and it took me a few days to get the back end libs sorted out. First off, you must know that you can't do this is you have python < 2.7
Here is my install notes that I'm putting together for our dev vagrant boxes running centos 7.
cd /tmp
# Install depot_tools first (needed for source checkout)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
# Download v8
fetch v8
cd v8
# Build (disable snapshots for V8 > 4.4.9.1)
make native library=shared snapshot=off -j8
# Install to /usr
sudo mkdir -p /usr/lib /usr/include
sudo cp out/native/lib.target/lib*.so /usr/lib64/
sudo cp -R include/* /usr/include
echo -e "create /usr/lib64/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M
cd /usr/lib64
sudo chrpath -r '$ORIGIN' libv8.so
========================
Compile php-v8js itself
========================
cd /tmp
git clone -b master https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure
make
make test
sudo make install
sudo service httpd restart
A note on the line make native library=shared snapshot=off -j8. I had the compile stop on me a couple times, I just restarted it. I'm not sure why it stopped, but it restarted just fine and completed just fine.
After that is done, you need to create the php extension file /etc/php.d/v8js.ini with the following content
; Enable v8js extension module
extension=v8js.so
Run the following to make sure it is installed correctly
php -r "phpinfo();" | grep v8js
If you get output back and no errors you're good to go.

How do I install Pdftk on my server?

I am using a Linux Server and am trying to install Pdftk, but I am problems trying to figure out what exactly to do.
I found the following documentation on how to install it, but they refer mostly to installing it on the local Windows machine.
They are:
http://www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/
http://www.accesspdf.com/pdftk/#packages
Can someone help me unserstand exactly what files I need to place where on my server so I can refer to pdftk?
Pdftk is a version of iText which has been converted from Java to c++ and rebuilt with a command-line bridge for easy access from PHP applications.
To build pdftk on Redhat / CentOS please follow the below instructions.
ssh [server to install pdftk on]
Now that we are in the server we need to create the directories to store pdftk.
cd /
sudo mkdir extra
cd extra
sudo mkdir src
cd src
sudo wget http://www.pdfhacks.com/pdftk/pdftk-1.41.tar.gz
sudo tar zxvf pdftk-1.41.tar.gz
cd pdftk-1.41/pdftk
Now we need to install the gcj libraries.
sudo yum install java-1.4.2-gcj-compat-devel.i386
The gcc-c++ library doesn't get installed with the gcj package so we will install it now, so we don't get an error halfway through the compile process.
sudo yum install gcc-c++
If you compile the application right now you will receive a warning that tmpnam is dangerous to use and you should use mkstemp.
sudo vi report.cc
Run this from inside VI to do a search and replace for the tmpnam method.
:%s/tmpnam(/mkstemp(/g
Press escape and save the changes with
:wq!
Now that we have all the packages installed, we are going to start compiling pdftk-1.41
from /extra/src/pdftk-1.41/pdftk run the following command
sudo make -f Makefile.RedHat
This will kick off the build process for compiling and converting the java file to c++. This could take SEVERAL minutes to convert iText to c++. Go grab yourself a margarita from our new margarita machine in the break room :).
Now with the pdftk file created we will want to copy it to the /bin directory so that we can run it from anywhere.
sudo cp pdftk /usr/local/bin
Let's make sure the build was successful and run
pdftk --version
As of 2020, things are different now. CentOS 6 is stepping out and pdftk can only support CentOS 5/6. GCJ on CentOS 7 is removed, so installing from source is not easy too. But we have docker now:
FROM centos:centos6
RUN yum install -y https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-1.el6.x86_64.rpm
Then build with docker build . -t pdftk and run as:
docker run -it --rm -v $PWD:/data --workdir /data pdftk pdftk ./input.pdf output ./output.pdf
The example above can repair a pdf file missing a dozen of KB of data if you are lucky.
As mentioned by #rsc, pdftk-java will be available for Rocky Linux, but currently (2021.10.28), still cannot install it via yum.
Fortunately, there is a built command for x86_64 GNU/Linux systems, which does not require any runtime dependencies. So we can use it as follows
# the version number might be updated, check https://gitlab.com/pdftk-java/pdftk
wget https://gitlab.com/pdftk-java/pdftk/-/jobs/1527259632/artifacts/raw/build/native-image/pdftk
chmod +x pdftk
./pdftk ...
It works well in the server with the following system info,
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Rocky
Description: Rocky Linux release 8.4 (Green Obsidian)
Release: 8.4
Codename: GreenObsidian
As of 2021, there is pdftk-java: A port of the original GCJ-based PDFtk to Java, which is currently on the way to the repositories for Fedora 33+ and EPEL 7+ (latter for CentOS, RHEL or Rocky), allowing yum install pdftk-java to succeed (once the package reached the stable repositories).
Edit: The pdftk-java package is in the stable repositories since yesterday, 2021-10-29.

Categories