Install a LAMP Web Server with the Amazon Linux AMI

Amazon Linux
– Update Server

sudo yum update -y

– Install Apache, MySQL, PHP

sudo yum install -y httpd24 php71 mysql56-server php71-mysqlnd

– Start Apache server

sudo service httpd start

– Configure the Apache web server to start at each system boot

sudo chkconfig httpd on

verify that httpd is on by running

chkconfig --list httpd

(httpd is on in runlevels 2, 3, 4, and 5)
– Start MySQL server

sudo service mysqld stop

– Configure the MySQL server to start at each system boot

sudo chkconfig mysqld on

– Open port for HTTP and MYSQL
– Create and Remote DB
edit 

vi /etc/my.cnf

add this line

bind-address=YOUR-SERVER-IP

Save, close the file and Restart Mysql 

sudo service mysqld restart

Connect to Mysql server

mysql -u root -p mysql

create db

CREATE DATABASE myweb;

create user

CREATE USER 'thanh' identified by '123456789';

grant user

GRANT ALL ON myweb.* TO thanh@'118.69.72.236' IDENTIFIED BY '123456789';

apply change

flush privileges;
  • Set file permission

– Add user to apache group

sudo usermod -a -G apache ec2-user

Log out (use exit command) and verify

groups

– Change the group ownership of /var/www and its contents to the apache group

sudo chown -R ec2-user:apache /var/www

– Add group write permissions and to set the group ID on future subdirectories, change the directory permissions of /var/www and its subdirectories.

sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;

– Add group write permissions, recursively change the file permissions of /var/www and its subdirectories

find /var/www -type f -exec sudo chmod 0664 {} \;

– Install Git

sudo yum install git

– Install Composer

cd ~
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer

then you can run

sudo composer install

Châu Lai Gia Thành

Hiền, đẹp trai :)) , thích code

Leave a Reply

Your email address will not be published. Required fields are marked *