====== Set Up Amazon Linux AMI with LAMP ====== ===== Fix timezone: ===== sudo su - rm /etc/localtime ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime vi /etc/sysconfig/clock edit ZONE: ZONE="America/New York" ===== Add users ===== sudo su - groupadd useradd -g -G wheel,apache -s /bin/bash -d /home/ -m ===== Lock ec2-user ===== sudo su - passwd -l ec2-user ===== Change hostname ===== edit /etc/sysconfig/network change: HOSTNAME=localhost.localdomain to: HOSTNAME= ===== Sudo Changes ===== sudo su - vi /etc/sudoers.d/zz_zustom chmod 0440 /etc/sudoers/zz_custom Add the following: %wheel ALL=(ALL) ALL ALL=(ALL:ALL) NOPASSWD:ALL ===== Install mailx ===== sudo yum install mailx ===== Change /etc/aliases ===== Add line: root: you@somewhere.com Then execute run /usr/bin/newaliases ===== Install logwatch ===== yum install logwatch ===== Install Mysql ===== sudo su - yum install mysql mysql-server mysql-libs service mysqld start mysql -u root use mysql set password for 'root'@'localhost' = password(''); delete from user where password = ''; flush privileges; drop database test; quit mysql -u root -p quit chkconfig --levels 235 mysqld on ===== Install PostgresSQL ===== Edit .bashrc and /etc/skel/.bashrcadd line: export PGDATA=/pgdata sudo su - yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs cd / mkdir /pgdata chown postgres:postgres /pgdata su postgres - initdb -D /pgdata Edit /pgdata/postgresql.conf, uncomment: listen_addresses = 'localhost' ... port = 5432 ... Edit /pgdata/pg_hba.conf, do Nothing: Set Startup chkconfig postgresql on Edit /etc/init.d/postgresql: PGDATA=/pgdata PGLOG=$PGDATA/pgstartup.log Start up postgres /etc/init.d/postgressql start Create database user: sudo su - postgres psql create user alter user with password ''; create database with owner ; \q Connect as database user: psql -U Some SQL stuff: create table connection_test(message char(100) not null); insert into connection_test values('Your Connection worked'); select * from connection_test; \list <== lists all databases aka schemas \dt <== lists tables in the database/schema \q <== quit psql utility Ref: http://imperialwicket.com/aws-install-postgresql-90-on-amazon-linux ===== Install gcc ===== sudo su - yum install gcc make libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap ===== Install xauth for ssh X11 forwarding ===== sudo su - yum install xorg-x11-xauth xterm xorg-x11-server-utils ===== Install Apache 24 + PHP 54 + Extensions ===== sudo su - yum install httpd24 mod24_ssl httpd54-devel yum install php54 php54-devel php54-gd php54-xml php54-pear pcre-devel php54-mbstring php54-xmlrpc php54-bcmath php54-pdo php54-pgsql php54-mysql ###pear install pecl/apc ###pear install pecl/uploadprogress chkconfig --levels 235 httpd on Note that **php54-5.4.8-1.27.amzn1.x86_64** viz. **php54-common** does not have the zip.so support. I am sure that they will eventually notice this and fix it but in the mean time I am sticking with **php54-5.4.7-1.25.amzn1.x86_64**. To downgrade, remove the php packages installed above and use the following... This will also lock the php version at 5.4.7: sudo su - yum install php54-5.4.7-1.25.amzn1.x86_64 php54-devel-5.4.7-1.25.amzn1.x86_64 php54-gd-5.4.7-1.25.amzn1.x86_64 php54-xml-5.4.7-1.25.amzn1.x86_64 php54-pear-5.4.7-1.25.amzn1.x86_64 pcre-devel-5.4.7-1.25.amzn1.x86_64 php54-mbstring-5.4.7-1.25.amzn1.x86_64 php54-xmlrpc-5.4.7-1.25.amzn1.x86_64 php54-bcmath-5.4.7-1.25.amzn1.x86_64 php54-pdo-5.4.7-1.25.amzn1.x86_64-5.4.7-1.25.amzn1.x86_64 php54-pgsql-5.4.7-1.25.amzn1.x86_64 php54-mysql-5.4.7-1.25.amzn1.x86_64 yum install yum-plugin-versionlock yum versionlock php54-common php54 php54-bcmath php54-cli php54-devel php54-gd php54-mbstring php54-mysql php54-pdo php54-pgsql php54-xml php54-xmlrpc To unlock the version edit /etc/yum/pluginconf.d/versionlock.list Add the following to /etc/php.d/zz_custom.ini: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Enable Custom Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ###extension=apc.so ###extension=uploadprogress.so expose_php = Off apc.rfc1867 = 1 error_log = /var/log/httpd/php-error.log date.timezone = "America/New_York" Logrotate for apache: sudo su - vi /etc/logrotate.d/httpd /var/log/httpd/*log { rotate 5 size=10M missingok notifempty sharedscripts delaycompress postrotate service httpd restart > /dev/null || true endscript } ===== Setfacl for apache in /var/log ===== setfacl -m u:apache:rw /var/log ===== Maintenance: ===== Sample yum commands: yum list updates yum list installed yum remove xxx yum info xxx yum update xxx yum update yum check-update yum clean all yum clean packages yum clean headers yum clean oldheaders ===== For applications needing libstdc++.so.5: ===== You may see the error: **: error while loading shared libraries: libstdc++.so.5:**. To resolve this error do the following: sudo yum install libstdc++.so.5 This will install the **compat-libstdc++-33.i686** (32-bit)package. ===== Installing 32-bit libs: ===== Just in case you have 32-bit apps that need to be installed on your 64-bit linux ami. Install the following to get support. This is equivalent to **ia32-libs** on Redhat or **multilib** on Ubuntu yum install alsa-lib.i686 atk.i686 audit-libs.i686 avahi-libs.i686 cairo.i686 cups-libs.i686 \ dbus-libs.i686 expat.i686 flac.i686 fontconfig.i686 freetype.i686 gamin.i686 \ gdk-pixbuf2.i686 glib2.i686 glibc.i686 gnutls.i686 gtk2.i686 jasper-libs.i686 \ keyutils-libs.i686 krb5-libs.i686 libICE.i686 libSM.i686 libX11.i686 libXau.i686 \ libXcomposite.i686 libXcursor.i686 libXdamage.i686 libXext.i686 libXfixes.i686 \ libXft.i686 libXi.i686 libXinerama.i686 libXrandr.i686 libXrender.i686 libXtst.i686 \ libasyncns.i686 libcom_err.i686 libgcc.i686 libgcrypt.i686 libgpg-error.i686 \ libjpeg-turbo.i686 libogg.i686 libpng.i686 libselinux.i686 libsndfile.i686 \ libstdc++.i686 libtasn1.i686 libthai.i686 libtiff.i686 libuuid.i686 libv4l.i686 \ libvorbis.i686 libxcb.i686 nss-softokn-freebl.i686 pango.i686 pixman.i686 \ pulseaudio-libs.i686 tcp_wrappers-libs.i686 xcb-util.i686 zlib.i686