First thing you have to connect to ssh using macos or putty for windows by added the downloaded key file. Run the following command:
sudo yum update -y
The above command ensure that all of your software packages are up to date.
you can install the Apache web server, MySQL, and PHP software packages.
sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
sudo service httpd start
Test your web server. In a web browser, type the public DNS address. If there is no content in /var/www/html, you should see the Apache test page.
Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.
ls -l /var/www
To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.
Add your user (in this case, ec2-user) to the apache group.
sudo usermod -a -G apache ec2-user
Log out and then log back in again to pick up the new group, and then verify your membership.
Log out (use the exit command or close the terminal window):
exit
To verify your membership in the apache group, reconnect to your instance, and then run the following command:
groups
Change the group ownership of /var/www and its contents to the apache group.
sudo chown -R ec2-user:apache /var/www
To add group write permissions and to set the group ID on future subdirectories
sudo chmod 2775 /var/www
Then:
find /var/www -type d -exec sudo chmod 2775 {} \\;
To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:
find /var/www -type f -exec sudo chmod 0664 {} \\;
Now, the ec2-user user (and any future members of the apache group) can add, delete, and edit files in the Apache document root. Now you are ready to add content, such as a static website or a PHP application.
Create a PHP file in the Apache document root.
echo "" > /var/www/html/phpinfo.php
If you get a “Permission denied” error when trying to run this command, try logging out and logging back in again to pick up the proper group permissions that you configured in Set File Permissions.
http://my.public.dns.amazonaws.com/phpinfo.php
sudo nano /etc/httpd/conf/httpd.conf
Save the file ctrl + ^O and restart the apache:
sudo service httpd restart
sudo mysql_secure_installation
When prompted, type a password for the root account and then set Y
to all question being asked.
(Optional) If you want the MySQL server to start at every boot, type the following command.
sudo chkconfig mysqld on
- Navigate to the Apache document root at /var/www/html
cd /var/www/html
- Create a phpMyAdmin folder and extract the package into it using the following command
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
- Delete the phpMyAdmin-latest-all-languages.tar.gz tarball.
rm phpMyAdmin-latest-all-languages.tar.gz
sudo service mysqld start
phpmyadmin url should something like here: http://my.public.dns.amazonaws.com/phpMyAdmin
# Install PHP 7.2
# automatically includes php72-cli php72-common php72-json php72-process php72-xml
sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd
# Install additional commonly used php packages
sudo yum install php72-gd
sudo yum install php72-imap
sudo yum install php72-mbstring
sudo yum install php72-mysqlnd
sudo yum install php72-opcache
sudo yum install php72-pdo
sudo yum install php72-pecl-apcu
sudo service httpd restart