Wednesday, 14 June 2017
Write a bash script which remove all the ECS-Task Definition except the latest one
How do we install the PhpMyAdmin on ec2 instance and dockerize the phpmyadmin
write a bash script which remove all the images from the ECR except the latest image
Write a bash script which remove the instance from ECS cluster and chef server
Starting the new ECS task on the ec2 instances using the latest TaskDefinition of EC2 container using bash script
Stopping the ECS Task which are running on ec2 instances using bash script
Wednesday, 22 February 2017
Create a php project which retrieve records from AWS RDS Database instances running on AWS EC2 instances
Welcome to Apace Webserver!
step4: Open a browser window and enter the URL to access the file (It is the public DNS name of the EC2 instance followed by the file name) http://EC2-instance-public-DNS Step5: Add the www group to your instance $sudo group add www step7: Add your user (in our case centos) to the www group sudo usermod -a -G www centos Logout and connect the instance onces again step8:Change the group ownership of /var/www and connects to the www group sudo chown -R root:www /var/www step9: Recursively change the directory permissions of /var/www and its subdirectories to add group Write permissions to set the group ID on future subdirectories sudo chmod 2775 /var/www $find /var/www -type d -exec sudo chmod 2775 {}\; step10: Recursively change the file permissions of /var/www and its subdirectories to add group write Permissions $find /var/www -type f -exec sudo chmod 0664 {}\; ---------------------------------------------------------------------- Install the PHP, extensions and configure the php.ini ----------------------------------------------------------------------- step1: Connect to the EC2 Instance and install the PHP $sudo yum install php Step2: Restart the httpd service $sudo systemctl restart httpd.service Step3: Install the PHP extensions or Modules $sudo yum search php- (display all the php packages) $sudo yum install php-fpm (PHP FastCGI Process Manager) $sudo yum install php-dba (A database abstraction layer module for PHP applications) $sudo yum install php-mysqlnd . (A module for PHP applications that use MySQL databases) $sudo yum install php-pdo (A database access abstraction module for PHP applications) $sudo yum install php-pgsql (A PostgreSQL database module for PHP) Step4: Add the extension in php.ini in same order and restart httpd service (/etc/php.ini) extension pdo.so extension mysqlnd.so extension pdo_sqlite.so extension pdo_mysqlnd.so extension pdo_sqlite.so extension mysqlnd_mysql.so step5: Create files in /var/www/html ------------------------------------------------------------------------- index.html -------------------------------------------------------------------------Connect to the DataBase!
----------------------------------------------------------------- dbinfo.inc ------------------------------------------------------------------ ----------------------------------------------------------------- script.php -----------------------------------------------------------------DATABASE TABLE
"; } // Free result set mysqli_free_result($result); mysqli_close($con); ?> Step6: To bind the address form our httpd web server with RDS instances, we need to run the following Commands: $ausearch -c 'httpd' --raw | audit2allow -M my-httpd $semodule -X 300 -i my-httpd.pp ------------------------------------------------------------------------- Logs and Important files used for debugging ------------------------------------------------------------------------ httpd: /var/log/httpd/access_log /var/log/httpd/error_log /etc/httpd/conf/httpd.conf /etc/httpd/modules PHP modules: /usr/lib64/php/modules /etc/php.ini Datadir /var/lib/mysql Socket /var/lib/mysql/mysql.sock MySQL file /etc/my.cnf ------------------------------------------------------------------------ RDS Database SQL Quieres: ------------------------------------------------------------------------- Step1: MySQL workbench download url: http://dev.mysql.com/downloads/workbench/ Step2: Install the MSI installer [windowns] $sudo apt-get install mysql-server [ubuntu] $sudo yum install mysql-server [linux] Step3: >mysql -h yourDatabaseEndpoint -P 3306 -u USERNAME -p >show databases; [Show the Databases] >use database_name; [use the following database] >Create table Employee( ID integer(3),name varchar(20),desg varchar(20),sal integer(6)); >desc Employee; Step4: >insert into Employee(ID,name,desg,sal)values(101,'fasi','CEO',80000); >insert into Employee(ID,name,desg,sal)values(102,'Raj','SSE',50000); >insert into Employee(ID,name,desg,sal)values(103,'suraj','SE',30650); >insert into Employee(ID,name,desg,sal)values(104,'prem','HW',18800); Step5: > select * from Employee; ---------------------------------------------------------------------------------- IF you want to create Docker container Convert your PHP application into Image by using Docker file below: Note: copy the /etc/php.ini file to your /var/www/html/ where your Dockerfile is there Dockerfile: ------------ FROM centos/httpd RUN yum install -y php RUN yum install -y php-mysqlnd php-fpm php-dba COPY . /var/www/html/ COPY php.ini /etc/php.ini EXPOSE 80 Run these commands: --------------------- docker build -t fasi/httpd . docker run -d -p 80:80 fasi/httpd docker exec -it
Subscribe to:
Posts (Atom)