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
Related
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"
I bought a VPS server, where I installed apache, mysql, php and phpmyadmin. I created database (like in my local project).
So, now I want to migrate a local project to my server and please, tell me I am right:
Files .php has to be in folder var/www on my apache server? (here is index.html too) and from this folder connect with database?
I have to download NPM on ubuntu
I have to download GIT on ubuntu
Download repo from my github where I've got whole code (webpack dist files, node modules, src and whole config) to /var/www catalog
index.html has to be in top-level directory (just in var/www not for example var/www/src
Please help me and tell if I am thinking right.
Files .php has to be in folder var/www on my apache server? (here is index.html too) and from this folder connect with database?
It depends on what you set in /etc/apache2/sites-available/000-default.conf. I assume that you installed with default configuration from apt-get.
index.html has to be in top-level directory (just in var/www not for example var/www/src
If for example your source codes are in /var/www/src instead of /var/www, the just modify the 000-default.conf. Example:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName your_domain_name.com
DocumentRoot /var/www/src/
<Directory />
Options FollowSymLinks
AllowOverride None
Options -Indexes
</Directory>
<Directory /var/www/src>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Options -Indexes
</Directory>
ErrorLog /var/log/your_log_file.log
LogLevel warn
CustomLog /var/log/your_access_log_file.log combined
</VirtualHost>
Restart Apache and try open in your browser to see if it works.
As for the database, since you have phpmyadmin, just export the sql data from your local machine and import it into the VPS phpmyadmin.
I am working in PHP and want to add the source code as existing project in Netbeans 8.1 on Windows 7 using Ampps.
I have setup virtual hosts and edited the hosts file to create the local site www.mysite.com. Here is the code snippet
httpd-vhosts.conf file
<VirtualHost 127.0.0.1:80>
<Directory "c:/program files/ampps/www/mysite/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName www.mysite.com
ServerAlias www.mysite.com
ScriptAlias /cgi-bin/ "c:/program files/ampps/www/mysite/www/cgi-bin/"
DocumentRoot "c:/program files/ampps/www/mysite/www"
ErrorLog "C:/Program Files/Ampps/apache/logs/www.mysite.com.err"
CustomLog "C:/Program Files/Ampps/apache/logs/www.mysite.com.log" combined
</VirtualHost>
Hosts file
127.0.0.1 www.mysite.com
Now as I set up a project in Netbeans with existing sources at the Run Configuration step, the Project URL appears as http:\localhost\www. I want this to be www.mysite.com. How to do this?
Any help appreciated.
Create project from existing source
The image shows the project URL as http:\localhost\www.If it is changed then it displays Project URL is not valid as below
Invalid Project
Creating New Project
Add Project URL and remove index file text if not required.
Already Created Project
Right click on your Project and Select Properties. Select Run Configuration in the left tab. Edit the Project URL as shown in screenshot below.
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.
I have setup a virtual host in apache with multiple directories for www.abc.com and abc.com/api which I need to points towards different directory
<VirtualHost *:8080>
DocumentRoot "/var/www/html/api/"
ServerName www.abc.com
ServerAlias www.abc.com
DirectoryIndex index.php
# Other directives here
# Other directives here
Alias /api/ "/var/www/html/public/"
<Directory "/var/www/html/public">
</Directory>
</VirtualHost>
Its working when I go to www.abc.com/api/ but when I move beyond that www.abc.com/api/v1/ I got the error
Not Found
The requested URL /var/www/html/public/index.php was not found on this server.
How to fix the issue?
I suppose you are using an MVC framework. If that's the case you need to configure your routing path in order to access your desired file.