Access two directories using httpd.conf on same domain - php

How can I configure httpd.conf to access laravelapp and phpmyadmin in below way:
http://something.com
Wants to access laravel app,
http://something.com/phpmyadmin
to access phpmyadmin.
Directories laravelapp and phpmyadmin in /var/www/html
I did below code in /etc/httpd/conf/httpd.conf file, but not working.
DocumentRoot "/var/www/html/laravelapp/public"
#
# Relax access to content within /var/www.
#
<Directory "/var/www/html/laravelapp">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html/phpmyadmin">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
Laravel app /public dir contains default .htaccess file as comes with laravel.

Your phpadmin installation is outside the DocumentRoot so you need something else. You can either:
Create a symlink to the PMA installation (you'll need Options +FollowSymlinks for this which you should have, since All is the default).
Use mod_alias. You just need to add the following to your current config:
Alias "phpmyadmin" "/var/www/html/phpmyadmin"

Related

whoami returns apache instead of root

I'm trying to serve an application from location /usr/local/administer/. There is a index.php file inside /usr/local/administer/index.php inside that index.php file is the following code
echo exec('whoami');
The result from the above code is apache however the result should be root as per my configuration in the vhost using mod-ruid2
administer.conf
The following is the configuration that I'm currently working with.
<Directory /usr/local/administer/web>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /usr/local/administer/
ServerName administer.com
ServerAlias www.administer.com
RMode config
RUidGid root root
RGroups root
</VirtualHost>
Any suggestions or advise?
As Mike 'Pomax' Kamermans has mentioned in the comment that not to run any task via PHP with root user. You'll get into trouble. If you are logged-in as root and running whoami via PHP then root won't show up. I'm not sure why this is happening. A possible solution in my preference is:
Create another user
Replace root with the new username
Restart Apache

How to remove public from the URL of Laravel project?

I've followed this and this answers to remove /public form the URL of my Laravel project. Now /public is removed from the URL. But my IDE (phpstorm) is throwing an error:
Does anybody know how can I fix it?
Note: I use Laravel 5.4
Change your apache vhost / host document root to projects public folder. its realted to apache config.
<VirtualHost *:80>
ServerName findexample.com
DocumentRoot c:/xampp/htdocs/find_people/public
<Directory c:/xampp/htdocs/find_people/public>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/find-people-error.log
CustomLog ${APACHE_LOG_DIR}/find-people-access.log combined
</VirtualHost>
See how to setup apache vhost on windows
You dont need to touch on any file to get what you want.
Try setting your document root to
path/to/your/laravel_app/public/
If your root is pointing to your public folder, when you access it from Browser, you will not need to use public in the url.
Remember that you must enable ModRewrite.

making Laravel coexist with multiple other LAMP projects using apache virtual host

I'm trying to make Laravel coexist with other projects on a local installation under /var/www, the current solution I have is to use an alias for the Laravel directory and several other aliases for the other projects.
For instance:
<VirtualHost *:80>
Alias /laravel /var/www/laravel/public
Alias /other_project /var/www/other_project
<Directory /var/www/other>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel/public>
AllowOverride All
</Directory>
</VirtualHost>
the solution above however makes http://localhost and http://localhost/laravel both redirect to Laravel, if I put say an index.php on the root directory of /var/www this is ignored and the Laravel installation is shown instead.
The directory other_project instead works correctly being completely separated from Laravel and showing its contents.
How can I make http://localhost/ show a standard index.php, http://localhost/laravel show a Laravel installation and http://localhost/other_project show another php project??
Change
DocumentRoot /var/www/laravel/public
To
DocumentRoot /var/www
That is if you want to display anything form /var/www

Downloaded Files Are Not Working on Apache DocumentRoot

I'm serving my pages with Apache 2.4 on a Ubuntu Mate OS. I've been building a system that allows my clients to download many files from a directory which has been created by each one of them at the moment they sign in.
Apache DocumentRoot is /var/www/public_html and Downloads process works fine in it but by the time I create a folder CLIENTS (absolute path: /var/www/public_html/CLIENTS/) file downloads arent working as they should. There`s just a message saying "Failed - No File" on incoming files.
I've already changed Directory permissions with chown on Linux, changed masks as well as checked Apache configuration using Directory directives but no results! Apache settings below:
VIRTUAL HOST CONFIGURATION
<Directory /var/www/public_html/CLIENTS/>
Options -Indexes +FollowSymLinks +Multiviews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
APACHE2.CONF
<Directory /var/www/public_html/CLIENTS/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
LINUX PERMISSIONS
drwxrwxrwx 3 www-data www-data public_html

Accessing files above the web server document root folder

Reading elsewhere, I have come across the concept of placing files I don't want accessible to the public above my web root folder. Doing this on my local WAMP stack works without issue, but once transferring over to my VPS (running Ubuntu 10.04.4 LTS) the PHP scripts can only see files under the root directory.
VirtualHost setup for my subdomain:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin ##########.com
ServerName admin.########.com
ServerAlias www.admin.########.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php admin.php
DocumentRoot /srv/www/#######.com/public_html/admin/web_pages
<Directory /srv/www/#######.com/public_html/admin/web_pages>
Options +Indexes
AllowOverride All
</Directory>
# Log file locations
LogLevel warn
ErrorLog /srv/www/########.com/logs/error.log
CustomLog /srv/www/########.com/logs/access.log combined
</VirtualHost>
Log error given: File does not exist: /srv/www/#######.com/public_html/admin/web_pages/css, referer: http://www.admin.########.com/
(My css folder is above the web_pages folder, and is called via this path: ../css/####.css)
Is this an issue with my configuration settings, or am I attempting to do something I shouldn't be, and instead have everything I need under my web root? I would really like constants files and application logic not accessible, but css,html pages, and images are ok.
If you want to grant public access to some folders above web root, you may use Alias directive:
Alias /css/ "/srv/www/#######.com/public_html/admin/css"
<Directory /srv/www/#######.com/public_html/admin/css>
# some configuration directives here
</Directory>
After that, your css files will be accessible via new path (without ..): /css/####.css
Don't forget to switch on mod_alias Apache module

Categories