Installing Yii2 on Graviton Servers
Steps to configure EC2 instance
Create EC2 instance
- Login to AWS console
- Go to Services > EC2 > Instances > Launch Instances
- Select Amazon Linux 2 64-Bit ARM
- Select instance type and click next to launch the instance.
Configure EC2 instance
To configure the instance SSH into the EC2 instance and follow the steps below
Install Apache, PHP and other dependencies
yum update
amazon-linux-extras install epel
amazon-linux-extras install php7.4
yum install httpd php-ctype php-mbstring php-intl php-fpm php-zip php-xml php-gd php-imagick php-curl php-memcache php-opcache php-bcmath php-soap php-apcu php-pdo php-pdo_mysqlInstall imagick
yum install php-pear
yum install php-devel
yum install gcc
yum install ImageMagick
yum install ImageMagick-devel
pecl install imagick
echo "extension=imagick.so" > /etc/php.d/imagick.ini
service httpd restartOpen
/etc/php.ini
and edit the following linesexpose_php = off
session.use_strict_mode = 1
max_execution_time = 180
memory_limit = 512MOpen
/etc/httpd/conf/httpd.conf
and edit the following lines# Supplemental configuration
<IfModule mpm_event_module>
ServerLimit 500
StartServers 100
MinSpareThreads 75
MaxSpareThreads 250
ThreadLimit 16
ThreadsPerChild 8
MaxRequestWorkers 4000
MaxConnectionsPerChild 10000
</IfModule>
KeepAliveTimeout 600
MaxKeepAliveRequests 500
TimeOut 600
ServerSignature Off
ServerTokens Prod
# Load vhost configs
IncludeOptional conf.d/vhosts/*.confCommnt out in file
conf.modules.d/00-mpm.conf
:LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
and uncomment :LoadModule mpm_event_module modules/mod_mpm_event.so
Run
mkdir /etc/httpd/conf.d/vhosts/
.Edit '/etc/httpd/conf.d/vhosts/test.conf'.
<VirtualHost *:80>
# ServerName [domain].samarth.ac.in
# ServerAlias www.[domain].samarth.ac.in
# RequestHeader set "Host" "[domain].samarth.ac.in"
DocumentRoot /var/www/html/
CustomLog /var/log/httpd/access_log combined
ErrorLog /var/log/httpd/error.log
<Directory />
Options FollowSymlinks
DirectoryIndex index.html index.php
AllowOverride All
Require all granted
</Directory>
<LocationMatch "^(.*\.php)$">
ProxyPass unix:/var/run/php-fpm/www.sock|fcgi://localhost/var/www/html/
DirectoryIndex /index.php index.php
</LocationMatch>
</VirtualHost>Check Syntax
httpd -t
open
/etc/php-fpm.d/www.conf
pm.max_children = 150
pm.start_servers = 30
pm.min_spare_servers = 20
pm.max_spare_servers = 70Check syntax
php-fpm -t
Restart apache and php-fpm
service php-fpm start
service httpd startAdd apache and php-fpm to auto restart
chkconfig httpd on
chkconfig php-fpm onCreate test files in
/var/www/html
Change the timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtimeInstall yum-cron
yum install yum-cron
Edit
/etc/yum/yum-cron.conf
filechange the folowing line:
apply_updates=no
toapply_updates=yes
Go to
http://[ec2-pblic-ip]/test.html
andhttp://[ec2-pblic-ip]/test.php
to check if everything is working.
Note: The pre-configured AMI is
ami-05579e96af93dc54a
.
Warnings while performing composer update with Php7.2+ need to resolved after thorough testing.
- Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.
- Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
- Package codeception/base is abandoned, you should avoid using it. No replacement was suggested.
- Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
- Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.