OK I had no plan to make this post but recently I spent quite a few time to figure it out so thought to make it as a post for self and others who come across issue to deal with this simply thing otherwise.
Alright, let’s proceed!
Below is the details of my Amazon Distro:
cat /etc/*-release NAME="Amazon Linux AMI" VERSION="2017.09" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2017.09" PRETTY_NAME="Amazon Linux AMI 2017.09" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2017.09:ga" HOME_URL="http://aws.amazon.com/amazon-linux-ami/" Amazon Linux AMI release 2017.09
Repo setting
Before we proceed, first make sure that you are downloading stuff from the right repository. Remove all irrelevant repos, specially remi-safe
.
wget https://mirror.webtatic.com/yum/el6/latest.rpm sudo yum install latest.rpm sudo vi /etc/yum.repos.d/webtatic.repo 'set repo enables sudo yum clean all
You can see list of available repos, if all goes well you should see something like below:
yum repolist Loaded plugins: priorities, update-motd, upgrade-helper repo id repo name status !amzn-main/latest amzn-main-Base 5,883 !amzn-updates/latest amzn-updates-Base 1,353 !nodesource/x86_64 Node.js Packages for Enterprise Linux 7 - x86_64 80 !webtatic/x86_64 Webtatic Repository EL6 - x86_64 243 repolist: 7,559
Alright, we now have correct repo setup, it’s time to install things
Apache 2.2 Installation
yum install http httpd-devel
Make sure it’s Apache2.2. I tried Apache2.4 but it gives error:
/etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load modules/libphp7.so
So I rather will settle with Apache 2.2
Check whether httpd
is up or not:
sudo service httpd restart
PHP 7.1 Installation
Two different PHP Packages need to be installed:
- PHP Module for Apache so that php based websites can work
- PHP CLI for executing scripts from command line. It’s needed for
php artisan
.
sudo yum install --enablerepo=webtatic php71w
If installed well you should be able to execute PHP. In my case phpinfo()
shows:
Now, we need to install PHP CLI:
sudo yum install --enablerepo=webtatic php71w-cli
and if all installed well:
[ec2-user@ip..]$ php -v PHP 7.1.14 (cli) (built: Feb 4 2018 09:25:54) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
OK before I quit, we gotta install PDO
and MySQL libraries:
sudo yum install php71w-pdo
sudo yum install php71w-mysqlnd
By doing php-m
it should show PDO
available.
Conclusion
In this post I tried to make your life easier by making this quick and short post so that others don’t waste hours to figure things out.