phpmyadmin forbidden in Red Hat Enterprise Linux running on Amazon Web Services EC2 - amazon-web-services

I am unable to access phpmyadmin in my server. I'm getting Forbidden.
Os version : Red Hat Enterprise Linux Server release 7.3 (Maipo)
I have checked answers in stackoverflow but, I'm unable to resolve my issue.
I installed phpmyadmin using command line.
running phpmyadmin Version information: 4.5.4.1
I have modified values in /etc/httpd/conf.d/phpMyAdmin.conf
My server is running on Amazon Web Services free tier.
here is the content present in phpMyAdmin.conf
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
# <IfModule mod_authz_core.c>
# Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
# Deny from All
Allow from all
# Allow from 127.0.0.1
# Allow from ::1
# AllowOverride all
# Require all granted
# </IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/libraries/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/lib/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/frames/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>

can you tell me what version of apache you are using apache 2.4 or apache 2.2 .
assuming 2.4
add to you httpd.conf
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
</Directory>
your below settings is restricting your access from browser .
Order Deny,Allow
Deny from All
Allow from ::1
Restart your httpd (apache)

Related

How to access wampserver 2.5 localhost in LAN

I have a windows 10 PC with wampserver 2.5 and I want to access it on my phone. I can get to 192.168.22.3/phpmyadmin using my mobile phone but not in localhost or any other vhosts like 192.168.22.3/wordpress. I have already edited the
# offlineonline tag - don't remove
Require all granted
Require ip 192.168.22
and I still get the 403 Forbidden on my mobile when accessing 192.168.22.3/wordpress
If your server is, for example, 192.168.1.254 and you want access from, for example, 192.168.1.5 or everywhere like public IPs or free dns services, you have to edit the file c:\wamp\alias\phpmyadmin.conf and change
<IfDefine APACHE24>
Require local
</IfDefine>
in
<IfDefine APACHE24>
Require all granted
</IfDefine>
my file:
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.1.14/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Require local
#
# by
#
# Require all granted
#
<Directory "c:/wamp/apps/phpmyadmin4.1.14/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
<IfDefine APACHE24>
Require all granted
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
</IfDefine>
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>

can't run a django project with apache on a subdomain

I have an online shop which contains a main page and a shop page. now this main page and shop page are actually two different projects, so in order to have them online, I have to run two instances of django.
now the things is, i want to have the main page on www.setakshop.ir, and the shop on shop.setakshop.ir. The thing is, after setting up the necessary settings, both shop.setakshop.ir and setakshop.ir point to the main page! and I can only see the shop page through setakshop.ir:8000, which I expected apache to proxy it to shop.setakshop.ir
I serve the DNS myself and here are my DNS settings:
;
; BIND data file for setakshop.ir
;
$TTL 3h
# IN SOA ns1.setakshop.ir. admin.setakshop.ir. (
1 ; Serial
3h ; Refresh after 3 hours
1h ; Retry after 1 hour
1w ; Expire after 1 week
1h ) ; Negative caching TTL of 1 day
;
# IN NS ns1.setakshop.ir.
# IN NS ns2.setakshop.ir.
setakshop.ir. IN MX 10 mail.setakshop.ir.
setakshop.ir. IN A xx.xx.xx.xx
ns1 IN A xx.xx.xx.xx
ns2 IN A xx.xx.xx.xx
www IN CNAME setakshop.ir.
mail IN A xx.xx.xx.xx
ftp IN CNAME setakshop.ir.
shop IN A xx.xx.xx.xx
and when run
nslookup shop.setakshop.ir
i get a valid response. So I think the DNS setup is actually fine.
Now the other thing I suspect, is my apache settings. I suspect that I haven't set the proxy settings right. here it is:
<VirtualHost *:80>
WSGIDaemonProcess main python-path=/var/www/setak:/var/www/setak/setakenv/lib/python2.7/site-packages
WSGIProcessGroup main
WSGIScriptAlias / /var/www/setak/setakenv/main/ashop/ashop/ashop/wsgi.py
ServerAdmin admin#setakshop.ir
ServerName www.setakshop.ir
ProxyPass / http://www.setakshop.ir:8001/
ProxyPassReverse / http://www.setakshop.ir:8001/
Alias /media/ /var/www/setak/setakenv/main/ashop/ashop/static/media/
Alias /static/ /var/www/setak/setakenv/main/ashop/ashop/static/
<Directory /var/www/setak/setakenv/main/ashop/ashop/static>
Order allow,deny
allow from all
</Directory>
<Directory /var/www/setak/setakenv/main/ashop/ashop/static/media>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:8080>
WSGIDaemonProcess setak python-path=/var/www/setak:/var/www/setak/setakenv/lib/python2.7/site-packages
WSGIProcessGroup setak
WSGIScriptAlias / /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/wsgi.py
ServerAdmin admin#setakshop.ir
ServerName shop.setakshop.ir
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://shop.setakshop.ir:8000
ProxyPassReverse / http://shop.setakshop.ir:8000
Alias /robots.txt /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/static/robots.txt
Alias /media/ /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/media/
Alias /static/ /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/static/
<Directory /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/static>
Order allow,deny
allow from all
</Directory>
<Directory /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/media>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Now I dont get what I'm doing wrong here!
I run both the projects with the following command :
./manage.py runserver 0.0.0.0:8000
./manage.py runserver 0.0.0.0:8001
Can anybody tell me what I'm doing wrong?
thanks in advance.
That really is not how you run Django applications via Apache. runserver is not designed for or appropriate for production; it makes no sense to use Apache as a reverse proxy to runserver.
Confusingly it seems that you have correctly set up WSGIScriptAlias for one of your sites, but you are still proxying it. You need to remove the proxy stuff altogether, forget about runserver, and use mod_wsgi throughout.
The way to get Apache to serve two sites on two domains is to use NamedVirtualHosts. You simply set up two separate ones, each with the correct server name.
First of all you should not use ./manage.py runserver along with apache and you should not use ./manage.py runserver when you move your website to production. runserver is only for development environment, it can handle only one request at a time.
You should use mod_wsgi for running your project using Apache. Look the docs here
Or else gunicorn and nginx can be used for running your project. Have a look at this.

how can i resolve the default apache page for django with apache

im new at deploying and i've been trying to deploy my django app and i can only seem to get the default :"it works" page to work. i have followed a few tutorials to no luck.
my '/etc/apache2/sites-available/37.***.22.**' Virtual host:
`<VirtualHost *:80>
ServerAdmin webmaster#37.***.22.**
ServerName 37.***.22.**
DocumentRoot /var/www/37.***.22.**/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/37.***.22.**/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
WSGI file:
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/myprojectenv/local/lib/python2.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('~/MyProject/django-bookmarks')
sys.path.append('~/MyProject/django-bookmarks/django_bookmarks')
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_bookmarks.settings'
# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.$
execfile(activate_env, dict(__file__=activate_env))
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
i had SCP'ed my files for my djagno app into the MyProject dir on the server.
i also ran the a2ensite 37.***.22.25 and restarted apache, but even with that i still get the "it works" default page. how can i resolve this?
i had also installed Postfgress. i really want to deploy this app asap and have been struggling, and learning alot also at the same time! any advise would be appreciated.
thanks in advance.
Make sure that you have mod_wsgi installed and enabled for Apache.
You will also want to ensure that you have defined both WSGIProcessGroup and WSGIScriptAlias (configuration directives for mod_wsgi) for the virtual host.

mod_wsgi apache and django configuration not working

*Using Django 1.5, mod_WSGI 3.3 and Apache 2.2*
The Mod_WSGI module has been successfully installed into Apache.
I have also created a very basic project using django-admin.py called "check"
So now according to the Django Documentation on how to configure mod_wsgi
I have entered the following code into the Apache httpd.conf where it looks like this -
<VirtualHost 192.254.132.95:80>
ServerName bangtestwsgi.mbox140.com
ServerAlias www.bangtestwsgi.mbox140.com
DocumentRoot /home/bangwsgi/public_html
ServerAdmin webmaster#bangtestwsgi.mbox140.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/bangtestwsgi.mbox140.com combined
CustomLog /usr/local/apache/domlogs/bangtestwsgi.mbox140.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User bangwsgi # Needed for Cpanel::ApacheConf
UserDir enabled bangwsgi
<IfModule mod_suphp.c>
suPHP_UserGroup bangwsgi bangwsgi
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup bangwsgi bangwsgi
</IfModule>
</IfModule>
WSGIScriptAlias / /home/bangwsgi/check/check/wsgi.py
WSGIPythonPath /home/bangwsgi/check
<Directory /home/bangwsgi/check/check>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
</VirtualHost>
Currently my DNS hasn't propagated so I am using 192.254.132.95/~bangwsgi/ to access the app (as told to me by Hostgator)
The thing is that nothing is happening. There is nothing in the Apache error log. There seems to be sign that the wsgi script is even running. Can someone tell me what I can do differently to make this work?
I'm not sure why you are going to /~bangwsgi/. Your WSGI app is being served at /, as defined by the first parameter to WSGIScriptAlias.
It works on removing the line
WSGIPythonPath /home/bangwsgi/check
And changing Require all granted
to Allow from all

running two django apps with SSL in same apache server

I have apache2 installed in ubuntu lucid ,and have enabled ssl .Now I am running a django app (lets say myapp1 )on it using mod_wsgi.
I have configured the /etc/apache2/sites_enabled/ssl file and /etc/apache2/sites-available/ssl as below.
Now I can run my app using the url
https://127.0.0.1/myapp1
I need to run another django app (say myapp2 )in the same server,and that also uses SSL.So,how should I configure it?Can somebody please help me?
<VirtualHost *:443>
ServerAdmin webmaster#localhost
DocumentRoot /home/me/dev/python/django/myapp1
SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
WSGIScriptAlias /myapp1 /home/me/dev/python/django/myapp1/myapp1.wsgi
Alias /site_media/ /home/me/dev/python/django/myapp1/media/
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
By adding:
WSGIScriptAlias /myapp2 /home/me/dev/python/django/myapp2/myapp2.wsgi
You will need to resolve any conflict though if they can't share the same static media files. That is, have each have media in different locations and configure settings for each Django project appropriately.