Good EC2 Image with memcache and php - php

I'm planning to use the following setup on EC2: PHP (recent version) plus memcached on an ec2 instance, and using Amazon's RDS service for the MySQL database.
Is there a recommended instance that has PHP and Memcached installed with the most often used php extensions? I am not much of a sysadmin and would prefer one that is already configured.

I don't know of any image that comes only with LAMP and memcached - but I setup something a while back - on a Amazon Linux AMI (which is a cut down centOS distro). You can always use this as a guide and set it up yourself (and create your own image afterwards).
DISCLAIMER: I'm doing this off memory- I might have missed a step or two here so read the error messages and figure out what is missing.
Install Apache, PHP, mySQL:
yum -y install httpd php mysql mysql-server php-mysql
Make sure this services start when you start your instances:
chkconfig httpd on
chkconfig –add mysqld
chkconfig mysqld on
Start apache and mySQL:
service httpd start
service mysqld start
Login to mysql and setup a root account. Create your DBs, setup users, remove test db etc.
Before we install memcached, you need to add EPEL repo to yum for extra centOS packages and then install some dependencies:
Create a new file /etc/yum.repos.d/epel.repo and paste:
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=0
[epel-source]
name=Extra Packages for Enterprise Linux 5 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=0
Install dependencies:
yum groupinstall "Development Tools"
yum install openssl-devel openssl
Now try installing memcached:
yum install memcached
Hope it helps

Related

Ubuntu Amazon Web Service LAMP stack setup

I am trying to set up a LAMP stack on my Amazon Web Service AMI, which is an Ubuntu System.
I went through this tutorial: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
The only difference which I made is installing php 7.
I stuck at this Point: Start the MySQL server.
[ec2-user ~]$ sudo service mysqld start
Currently it Returns this error:
mysqld: unrecognized Service
Same for These commands:
[ec2-user ~]$ sudo service mysql start
[ec2-user ~]$ sudo service mysqlnd start
If I run php -i | grep mysqlnd I get following Output:
/etc/php-7.0.d/20-mysqlnd.ini, Client API library version => mysqlnd
5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ mysqlnd mysqlnd => enabled Version => mysqlnd 5.0.12-dev - 20150407
- $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_sha256_password mysqlnd statistics => Client API version => mysqlnd 5.0.12-dev -
20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
On Ubuntu 16.04, the command would be:
sudo service mysql start
It looks like the MySQL server might not be installed. You can install the MySQL server and client tools with:
sudo apt-get install mysql-server
You will be asked to create a password for the MySQL root user during installation.
The tutorial you link to is for Amazon Linux, which (amongst other differences) uses a different package manager than Ubuntu to install and manage software. In the tutorial, the line sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd would have installed the mysql56-server package alongside apache and php.
If you need a web server quickly without have to worry about setup you may as well launch an instance picked from the AWS Marketplace. There are perfect Amazon Machine Images (AMI) for any situation.
For instance, Bitnami offers LAMP solutions on AWS Marketplace with no extra cost besides EC2 pricing.

Could not establish Memcached connection

I'm trying to create a connection from my PHP application to Memcache, however I keep getting the error 'Could not establish Memcached connection'.
Here's my package version information
Laravel Version: 5.0.32
PHP Version:5.4.39-0+deb7u2
Database Driver & Version:mysql Ver 14.14 Distrib 5.5.31
Server&Version :Debian:7.1.
-memcached:1.4.13-0.2
-php5-memcached:2.0.1-6
I have ensured that memcached is running, as executing service memcached status yields "memcached is running".
I have two servers where my project is deployed:
ubuntu, with memcached:2.1.0 installed
debian, with memcached:2.0.1 installed
Is there a version conflict?
Fixed by myself.
My solution as follow:
1.delete memcache file and apc file in config dir
2.restart php5-fpm and memcached service.
Although issue is fixed, but I'm still not figure out why it was triggered.
This issue only occurs on the server with Debian os installed rather than the other server which with ubuntu os installed.
Hope help somebody~
i solved the problem with
sudo apt-get install memcached
sudo service memcached status
sudo service memcached start
You need to first install memcached :
sudo apt install memcached
Then you need to start it :
sudo service memcached start
After that it will connect. I resolve it by above step in my case.

How to install memcached with PHP55

First my web server run on Redhat6.6 and I need to build PHP by my own to enable Sybase support.
Today I want to enable memcached support.
To my knowledge I can't use yum install php55-php-pecl-memcached.x86_64 because it would also install the default php package as dependency, and make memcached enable only for its php dependency.
I looked into PECL packages, but it seems to be available for PHP5.2 only.
I installed libmemcached-devel.x86_64 but I can't phpize it because it miss some files into libmemcached folder, it seems not to be sources that phpize needs...
What can I do more
Start from scratch and there is a good way of doing it.
Install memcached through RPM
The easiest way to install Memcached is through a package manager such as yum or apt (in your case yum because its redhat). However, Memcached is not available from the default collection of packages, so the first thing we need to do is add a new RPM (Red Hat Package Manager) server so that we can install Memcached through yum.
One of the best 3rd-party RPM servers is provided by Dag Wieers, which will provide us with up-to-date packages that are not provided by Red Hat directly. The one tricky part of setting up an RPM server is making sure you get the repository that matches your server version and architecture (32-bit or 64-bit). So we need to collect that information first.
From a shell prompt, get the CentOS/RedHat version number:
$ cat /etc/redhat-release
CentOS release 5.3 (Final)
Then get the server architecture information. This is a typical response for a 32-bit machine:
$ uname -a
Linux server1.example.com 2.6.18-92.1.13.el5 #1 SMP Wed Sep 24 19:33:52 EDT 2008 i686 i686 i386 GNU/Linux
Or if you have a 64-bit machine you will probably get something like this:
$ uname -a
Linux server.example.com 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:35:07 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
Now install the RPM server that matches your architecture and CentOS version from http://dag.wieers.com/rpm/FAQ.php#B2.
The server I was using when I wrote this was a 32-bit machine running CentOS version 5.x. So my particular server was:
http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
To install a new RPM server, we can just use the rpm command. Note that you must find the RPM server string that matches your architecture and software. Do not use the URL unless you have a 32-bit machine running CentOS 5.x, instead get the server that's appropriate from http://dag.wieers.com/rpm/FAQ.php#B2.
$ rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Now we can simply use yum (or apt) to install Memcached:
$ yum install memcached
Afterwards you can confirm memcached is up and running by calling it.
$ memcached -h
memcached 1.2.6
Install the Memcache PECL Extension
Even though memcached is happily running on the server, it's not accessible from PHP without the PECL extension. Fortunately this is a very easy process, just use the pecl command.
$ pecl install memcache
Then add the memcache extension to your php.ini file, usually at /etc/php.ini.
extension=memcache.so
And finally restart Apache so that it will pick up the new extension:
$ /etc/init.d/apache2 restart
Running phpinfo() on your webserver should now confirm that memcache is installed:
The output of phpinfo() showing that memcache is successfully installed
Set up Memcached as a service
Just having memcache installed will not do anything by itself, we need to actually start up some instances of it for our web server to connect to, and we need memcached to automatically start up when the server restarts.
For this we need to install a new script at /etc/init.d/memcached. For this I usually use a custom script that's a bit crude, since it assumes that memcached is being used exclusively for our web server. However, most of the time this is true and it works just fine.
Download the memcached script (rename to just "memcached").
So simply load this script into /etc/init.d. Then set the permissions on it to make it executable:
$ chmod 755 memcached
Then register the script to start up with the server:
$ chkconfig --add memcached
Now you can start up memcached as a service.
$ service memcached start
And you can confirm that memcached has fired up several instances by checking ps.
$ ps -e | grep memcached
22805 ? 00:00:59 memcached
22807 ? 00:00:58 memcached
22809 ? 00:01:16 memcached
22811 ? 00:00:55 memcached
22813 ? 00:00:01 memcached
22815 ? 00:01:02 memcached
22817 ? 00:00:27 memcached
22819 ? 00:00:35 memcached
22821 ? 00:00:01 memcached
22823 ? 00:00:01 memcached
22825 ? 00:00:01 memcached

how to install lamp/xampp server on beaglebone black

i am unable to install lamp or xampp server on my BBB.when i typed
sudo apt-get install apache2
it says "sudo :command not found"
opkg install php php-cgi php-cli
opkg install lighttpd lighttpd-module-fastcgi
opkg install mysql5
also the above commands do not work.The error says "unknown package ..."
Basically i am trying to develop a webserver which over the internet can be accessed to control hardware interfaced to BBB.
is there any way to solve this problem.I am using only usb connection to connect BBB using putty.
If you are using an Angstrom Distribution apache may not work. It freezes in between installation. Try upgrading to Ubuntu or Debian. Previous versions of BBB had very low memory (2GB) of which 1.5GB was taken by the OS. So try expanding it using a micro-SD card.
And it is a good practice to always update and upgrade your OS before installing any software.
sudo apt-get update && apt-get upgrade

Running PHP 5.3 on CentOS 5.4 - fatal error Class 'PDO' not found

What is the best way to get PHP 5.3 up and running on CentOS 5.4.
My machine says I have PHP 5.3 installed but running into an issue with my script that says
Fatal error: Class 'PDO' not found in /var/www/html/lib/rb.php on line 45
It fails trying to new up a PDO class in the RedbeanPHP 3.0 lib.
How can I fix this missing PDO problem?
I tried to follow these instructions:
from http://www.computingunplugged.com/issues/issue201102/00002619002
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# THIS LINE FAILED FOR ME
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
UPDATE
Someone removed their answer. It was good. I'm putting it back in with exact steps.
First I had to yum install php53u-devel
To quote "
You need the PDO extension. Usually the best way to install extensions is via PECL.
Before you can install any PECL extensions you need to install the php5-dev package
sudo pecl install pdo
sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.
extension=pdo.so
extension=pdo_mysql.so
"
Now I get a mysql_query_missing when trying to run sudo pecl install pdo_mysql
and not sure how to get past this.
You'll have to install the php-pdo package as well.
Edit: Maybe this helps as well: How do I enable PDO using CentOS?
I have been successfully able to install PHP-5.3 on CentOS 5.4 Linux. I needed this to be able to successfully install and run Drupal 7 - which also worked out for me. Here are the details:
This is a copy of the answer I wrote up in ServerFault: https://serverfault.com/a/392168/29205
(...for my question: https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168 )
The solution is based on the accepted answer in:
https://serverfault.com/questions/391839/how-to-force-centos-yum-to-use-a-later-version-of-a-package-dependency-already-i
In summary: move to php5.3.
Reason: support for php5.2 as been removed owing to security issues as explained in that other question's accepted answer. This removal causes mismatch of the versions of the dependencies and therefore the error seen.
Background
I wanted to run Drupal 7 on a CentOS 5.4 machine. So I needed 5.3 version of PHP.
Here are the full working steps to upgrade to PHP 5.3 with working repositories as of May 24 2012 ( I provide comments preceded by # - you don't need these, just for your info)
# Comment: sites like http://www.computingunplugged.com/issues/issue201102/00002619001
# provide a good start for remedying the problem whereby we need 5.3 on CentOS 5.4 to run Drupal 7. But although their packages worked at the time, the links are now outdated, and updates to these are below.
# comment: (as of May 2012 - the following work, the reason for failures was use of 1) older packages no longer on the server and 2) change of address of one of the servers to dl.fedoraproject.org/pub/epel (credit to: http://osdir.com/ml/centos/2012-03/msg00057.html )
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
# After doing the above, php -v shows 5.3.x But on attempting to install Drupal 7 you may get complaint of something "Your PHP installation is too old 5.1.6 Drupal requires at least PHP 5.2.4. See the system requirements page for more information." and php.info shows the same
# The remedy is to simply restart your apache server
service httpd restart
# credit to following for suggesting service httpd restart :-
# https://serverfault.com/a/207806/29205
# https://serverfault.com/questions/207762/centos-updating-php-via-yum-doesnt-change-the-version-apache-uses
# Drupal 7 install on CentOS 5.4 worked after applying the above steps
# If your MySQL server is not running (check by ps -ef | grep mysql ) then you can run:
/etc/init.d/mysqld
# ...to start it, and to make sure it starts when the machine is restarted or cold booted:
chkconfig mysqld on

Categories