Commands To Setup Nginx and Phpmyadmin in Ubuntu Ec2 Instance
Commands To Setup Nginx and Phpmyadmin in Ubuntu Ec2 Instance
Note: At first create the Ubuntu EC2 instance in your Amazon Web Service as shown in the
video.
-------------------------------------------------------------------------------------------------------------
It means that the user name is ‘admin’ and password is also ‘admin’
php --version
In below configuration, you have to add index.php as shown in screenshot below and
server_name is your ec2 instance Public IPv4 DNS or Public IPv4 address:
In my case it's an elastic ip address i have created i.e., 34.239.223.82.
After changing into this above file type ctrl+o to write and save and ctrl+x to exit.
------------------------------------------------------------------------------------------------------------
10.Type below command to check whether configuration files have error or not:
sudo nginx -t
It should say:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Prepared by Dipendra Shrestha
If it’s giving an error then re-check the configuration file in a calm manner.
-----------------------------------------------------------------------------------------------------------
During the installation process of Phpmyadmin you will be asked to choose web
server as we are using ‘Nginx’ as a web server so don’t choose any of them press ‘tab’
and press enter on ‘ok’.
After that you will be asked for configure database for phpmyadmin with dbconfig-
common hit enter on ‘yes’ option’
After that you will be asked for a password. Give the password that is used to create
the user as in step 7 in my case it’s ‘admin’. I will give the same password.
For the Nginx web server to find and serve the phpMyAdmin files correctly, we’ll need
to create a symbolic link. Use the command as:
This will create the symbolic link also known as symlink to the /var/www/html
directory.
14.Now all configuration Completed!! Go to your browser and give url as
http://you_public_ipv4_address/phpmyadmin/
In my case it’s:
http://34.239.223.82/phpmyadmin/
sudo apt-get install python3 python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev
libssl-dev
Also Run:
sudo apt install libmysqlclient-dev
------------------------------------------------------------------------------------------------------------
3. Install Gunicorn:
Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. Gunicorn knows how
to run a web application based on the hook between the WSGI server and the WSGI-
compliant web app.
pip install gunicorn
To learn more about Gunicorn follow below link:
https://www.fullstackpython.com/green-unicorn-gunicorn.html
----------------------------------------------------------------------------------------------------------------------------------
5. Install supervisor:
Supervisor is a process manager to ensure gunicorn starts, restarts, and runs when we need it.
Supervisor will look after the Gunicorn process and make sure that they are restarted if anything goes
wrong, or to ensure the processes are started at boot time.
Prepared by Dipendra Shrestha
sudo apt-get install -y supervisor
----------------------------------------------------------------------------------------------------------------------------------
6. Configure supervisor
Create configuration so that supervisor could read from that configuration.
cd /etc/supervisor/conf.d/
mkdir /var/log/gunicorn
----------------------------------------------------------------------------------------------------------------------------------
Example:
location / {
include proxy_params;
proxy_pass http://unix:/var/www/html/Django/app.sock;
}
Check whether the configuration file is ok or not by giving the command as:
sudo nginx -t
----------------------------------------------------------------------------------------------------------------------------------
12. Restart nginx and the supervisor using the command as:
cd /etc/nginx/sites-available/default
Then add following configuration below and save it ctrl+o and ctrl+x
location /phpmyadmin/
{
root /usr/share/;
index index.php;
try_files $uri $uri/ =404;
}
Then restart nginx:
sudo service nginx restart