How to create an alias for phpmyadmin in apache? - apache

Using Ubuntu 16.04, apache2.
I have the following virtual host in apache, but my URL http://example.com/phpmyadmin gives a 404 error. Any ideas?
From looking at other stackoverflow posts, this should work, but it isn't working. I'm fairly new to the Linux/Apache world (if this was on IIS I'd be fine!) so if you can give any pointers that'd also be appreciated.
<VirtualHost *:80>
ServerName example.org
Alias /phpmyadmin/ /user/share/phpmyadmin/
DocumentRoot "/var/www/html"
<Directory /usr/share/phpmyadmin>
Require all granted
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
</IfModule>
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
Thanks in advance.

Related

apache httpd is automatically redirecting to https

Server is running on RHEL 7.9, httpd 2.4.6 and I have the following structure in my /var/www/html directory:
/site
index.php
I can reach the root index.php by visiting the IP address. However, when I try to access content inside /site directory, it automatically switches to https, hence the content does not load.
Some snippets from /etc/httpd/conf/httpd.conf:
DocumentRoot "/var/www/html"
<Directory />
AllowOverride None
Require all denied
Options -Indexes +FollowSymLinks
</Directory>
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
IncludeOptional conf.d/*.conf
I have a virtual host setup for /etc/httpd/conf.d/site.conf
<VirtualHost <server ip>:80>
ServerAdmin webmaster#sitename.com
DocumentRoot /var/www/html/site/
ServerName www.sitename.com
ServerAlias sitename
<Directory /var/www/html/site>
Require all granted
</Directory>
</VirtualHost>

Prestashop configuration multishop

i have to migrate from prestashop 1.6 to prestashop 1.7, in the new version i have made a multishop site.
how should I set the httpd.conf and the conf file of the related site for it to work?
now my conf site file is:
<VirtualHost *:80>
ServerAdmin name#example.com
ServerName www.example.it
ServerAlias example.it
DocumentRoot /home/sites/www.example.it/web/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/sites/www.example.it/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
RewriteEngine on
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !^/.well-known/ [NC]
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
#RewriteOptions inherit
</VirtualHost>
<VirtualHost *:443>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.it/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/www.example.it/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.example.it/chain.pem
ServerAdmin name#example.com
ServerName www.example.it
ServerAlias example.it
DocumentRoot /home/sites/www.example.it/web
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/sites/www.example.it/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
php_admin_value open_basedir "/home/sites/www.example.it:/home/sites/www.example.it/private:/home/sites/www.example.it/tmp:/tmp"
php_admin_value session.save_path "/home/sites/www.example.it/tmp"
php_admin_value upload_tmp_dir "/var/www/clients/client1/web1/tmp"
php_admin_value sendmail_path] "/usr/sbin/sendmail -t -i -f webmaster#example.it"
php_admin_value max_input_vars 10500
php_admin_value memory_limit 512M
php_admin_value max_execution_time 44000
php_admin_value upload_max_filesize 512M
RewriteEngine on
RewriteOptions inherit
<Directory /home/sites/*/web>
AllowOverride All
</Directory>
</VirtualHost>
What should I add or change in this file?
is there any other file I need to change?
thanks
You don't have to change your server's virtual host when turning on multishop option. Do you have some problems with the configuration ?

Simple 301 redirect using mod_alias not working

I tried to redirect a page '/page-one' to '/page/one/' just using Redirect directives but it doesn't work. I tried several options but none of them make it works:
Redirect 301 /page-one /page/one/
Redirect permanent /page-one /page/one/
Redirect 301 /page-one https://www.example.com/page/one/
Please find below the whole apache2.conf file I am using in my project:
<VirtualHost xx.xxx.xx.xx:8080>
ServerName example.com
ServerAlias www.example.com
redirect / https://www.example.com/
Redirect 301 /page-one /page/one/
DocumentRoot /home/admin/web/example.com/public_html
<Directory /home/admin/web/example.com/public_html>
AllowOverride All
Options +Includes -Indexes +ExecCGI
php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp
php_admin_value upload_tmp_dir /home/admin/tmp
php_admin_value session.save_path /home/admin/tmp
<Files *.php>
SetHandler fcgid-script
</Files>
FCGIWrapper /home/admin/web/example.com/cgi-bin/fcgi-starter .php
</Directory>
<Directory /home/admin/web/example.com/stats>
AllowOverride All
</Directory>
<Directory "/home/user1/public_html">
AllowOverride All
</Directory>
IncludeOptional /home/admin/conf/web/apache2.example.com.conf*
</VirtualHost>
Any suggestions are welcome!
Thanks!

zabbix.conf redirect to another port

I'm having trouble understanding how to reconfigure the initial zabbix.conf file to not hijack port 80 out of the box.
Here is the default zabbix.conf provided by the application:
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
What I want to be able to do is configure my zabbix similar to how I've done other apps on my server something like this. There are actually already 2 apps on this server. jira which is a Reverse Proxy on port 8080 and confluence which is a Reverse Proxy on port 8090. I want to have zabbix on a Reverse Proxy on another port, say 8070.:
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Redirect / https://zabbix.domain.com
</VirtualHost>
<VirtualHost *:443>
ServerName zabbix.domain.com
ServerAlias zabbix
Include ssl/default/ssl.cfg
ProxyPass / http://localhost:8070/
ProxyPassReverse / http://localhost:8070/
</VirtualHost>
The problem is this doesn't work because Zabbix runs on the assumption that nothing else is using port 80.
Doing something like this just gives a page not displayed
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Redirect / https://zabbix.domain.com
</VirtualHost>
<VirtualHost *:443>
ServerName zabbix.domain.com
ServerAlias zabbix
Include ssl/default/ssl.cfg
ProxyPass / http://localhost:80/
ProxyPassReverse / http://localhost:80/
</VirtualHost>
I was so close! Doing this -
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone America/Toronto
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
</VirtualHost>
Allowed me to hit the URL of http://zabbix.domain.com/zabbix and get the site.
Actually you should change this in Apache conf. You can search for it like so:
grep -rE "\b80\b" /etc/apache2
You will get a list of places to change. That would most probably be something like Listen 80 and <VirtualHost *:80>.
Note that original zabbix configuration doesn't have any configuration for ports.
So after changing what you need you should restart apache and make sure it is running:
service apache2 restart
service apache2 status
URLs
Also note that you don't need ServerName in VirtualHost. Zabbix will only "hijack" the "zabbix" folder and only on specific port on which apache is listening. So if you changed 80 to 8081 you should see zabbix running on:
http://localhost:8081/zabbix/
And if your machine is accessible from external domain like zabbix.domain.com then this will work fine:
http://zabbix.domain.com:8081/zabbix/

Why do I get an Access forbidden in Apache?

Why do I get this error on apache when I access a certain js file??? I tried changing the httpd-xampp.conf from Require local to Require local granted but still to no avail.
I have the right permission to the js file I can even edit it using notepad++.
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.14
here is inside the http-xampp.conf file.
#
# XAMPP settings
#
<IfModule env_module>
SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
SetEnv PHPRC "\\xampp\\php"
SetEnv TMP "\\xampp\\tmp"
</IfModule>
#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php5ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
# SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
# Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>
<IfModule php5_module>
PHPINIDir "C:/xampp/php"
</IfModule>
<IfModule mime_module>
AddType text/html .php .phps
</IfModule>
ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
<Directory "C:/xampp/cgi-bin">
<FilesMatch "\.php$">
SetHandler cgi-script
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler None
</FilesMatch>
</Directory>
<Directory "C:/xampp/htdocs/xampp">
<IfModule php5_module>
<Files "status.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
</Directory>
<IfModule alias_module>
Alias /licenses "C:/xampp/licenses/"
<Directory "C:/xampp/licenses">
Options +Indexes
<IfModule autoindex_color_module>
DirectoryIndexTextColor "#000000"
DirectoryIndexBGColor "#f8e8a0"
DirectoryIndexLinkColor "#bb3902"
DirectoryIndexVLinkColor "#bb3902"
DirectoryIndexALinkColor "#bb3902"
</IfModule>
Require all granted
</Directory>
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require all granted
</Directory>
Alias /webalizer "C:/xampp/webalizer/"
<Directory "C:/xampp/webalizer">
<IfModule php5_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
Require all granted
</Directory>
</IfModule>
#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Require local granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
In this section:
<Directory "C:/xampp/php">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
Change
Require all denied
to
Require all granted
Not the perfect solution imho, but should make your dev environment work.
UPDATE:
Change the enitre section to this:
<Directory "C:/xampp/php">
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
This is the default I use (from symfony.com).
I figured it out. There was just a typo in my code....
this causes the error..
<script src="/hris/admin/../template/assets/js/jquery-ui.custom.js </script>"></script>
doubled the </script> tag