I have a laravel app, which I test with php artisan serve.
I discovered that this is a bad practise, because it is not used on production.
I have installed apache2.4, it worked, when I open localhost I see 'It Works'.
Now I try to start my laravel app through apache on my PC.
For this I have done the following steps:
Edited the httpd.conf in Apache\conf, I uncommented this line:
LoadModule rewrite_module modules/mod_rewrite.so
Edited the httpd-vhosts.conf in Apache\conf\extra, I added:
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
</VirtualHost>
Edited the hosts file in Windows\System32\drivers\etc, I added:
127.0.0.1 www.localhost.eu localhost.eu
After every step I restarted the Apache2.4 service, but I still cant access my laravel application. The only thing, what changed is that I now get 'It Works' also on this domain: localhost.eu
What have I missed?
Currently I am starting my laravel app through php artisan serve. I can then access the app at localhost:8000.
Also I know I could set up homestead. But I discovered it too late. I have already configured and installed everything myself, and besides this one issue, everything works.
I'd like to understand how I would connect my laravel app to the apache server correctly myself.
Probably you forgot include file httpd-vhosts.conf file in httpd.conf. Sometimes this line commented by default and you should uncomment this line. After then you should restart apache2 service.
Add server alias on your file config
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
ServerAlias www.localcost.eu
</VirtualHost>
Related
i have an issue that i want to run my laravel project without cmd command php artisan serve , i want something like usually in php project localhost/projectName , when i do all the steps like changing hosts in System32/driver/etc/hosts
and changing E:\wamp\bin\apache\apache2.4.33\conf\extra\httpd-vhosts.conf with all recommended option i restart wamp but when i put on the url projectname.dev the cercle above browser still Spins and nothing displays in the browser!!!!
someone has any idea
the configurations is
<VirtualHost *:80>
ServerAdmin webmaster#ahssanstore.dev
DocumentRoot "E:\wamp\www\AhssanStore\public"
ServerName ahssanstore.dev
ServerAlias www.ahssanstore.dev
ErrorLog logs/ahssanstore.dev-error.log
CustomLog logs/ahssanstore.dev-access.log common
<Directory "E:\wamp\www\AhssanStore\public">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
and in C:\Windows\System32\drivers\etc
i add 127.0.0.1 ahssanstore.dev
and i restart wamp and after that i navigate to localhost/ahssanstore.dev
For windows, you can try use Laragon.
For those that have an Ubuntu Dev Server (with the possibility of other projects in your /var/www) I did the following to make it work.
Rename your-app/server.php to your-app/index.php
Copy .htaccess from your-app/public/ to your-app/
PS: If anyone knows that this creates some problems down the line please advice.
Done
Sometimes, servername: 'projectname.dev' doesn't work (I'm used to meet like this). Try changing 'projectname.me' instead 'project.dev'.
For VirtualHost configuration, you only need to set two lines:
<VirtualHost *:80>
DocumentRoot "E:\wamp\www\AhssanStore\public"
ServerName ahssanstore.dev
</VirtualHost>
Just Sharing my knowledge. Hope it also works!
I want to access my site via testing.dev instead of localhost:8000.
How can I achieve this?
<VirtualHost *:8000>
DocumentRoot "C:/Websites/test"
ServerName www.testing.dev
ServerAlias testing.dev
</VirtualHost>
I googled the problem, but they all speak of a httpd-vhost.conf file, but I don't seem to have one in my project.
Where / how can I find it? FYI, I'm using the built in webserver (bin/console server:run)
Tried this already
I found a httpd-vhost.conf in my xampp folder (don't use xampp tho)
Hello I'm trying to run project using newest symfony on my localhost.
What i already did:
I added this to my vhosts file in Xampp.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "F:\Programy\XAMP\htdocs\Anka\web"
ServerName Anka
DirectoryIndex app_dev.php
ErrorLog "logs/vark.local-error.log"
CustomLog "logs/vark.local-access.log" common
</VirtualHost>
I added this in my hosts file in Windows\System32...
127.0.0.1 Anka
This is what i see after typing
anka\
In my browser.
My localhost website
And when i click on web i see this:
web
Can somebody help me what else i should do to see normal Symfony index page?
Try http://anka/app_dev.php or http://anka/web/app_dev.php
Also You can Change the directory to this one with the application and run:
php bin/console server:run
Then access http://localhost:8000/ in your browser
Like this:
https://symfony.com/doc/current/setup.html#running-the-symfony-application
First of all - ServerName value is case-sensitive, to Apache is not really recognizing request as this VirtualHost and you're getting listing of root directory.
Use http://Anka url, or change ServerName Anka to ServerName anka and 127.0.0.1 Anka into 127.0.0.1 anka.
Next thing is that you have some errors in your code and PHP cannot find AnkaBundle\AnkaBundle class. You're probably missing an autoloader, but that's only my guess. Not enough information to be sure.
I am pretty new in PHP and moreover in Laravel and I am pretty desperate trying to deploy a Laravel 5.4 application that works fine on my local environment on my Linux remote server.
So I think that it is something related to virtual host configuration or something like this (maybe also something related to the .htaccess file)
In my local environment (I am using XAMPP on Windows) I have setted this virtual host into the C:\xampp\apache\conf\extra\httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/HotelRegistration/public"
ServerName laravel.dev
</VirtualHost>
So opening the laravel.dev URL I obtain the standard Laravel homepage (I have yet not replaced it with a landing page).
Then if I open this URL: http://laravel.dev/registration
I obtain the user registration page developed by me, this because I have this route into my web.php file into my project:
Route::resource('/registration', 'RegistrationController');
Then into my RegistrationController.php there is this method showing the resources/views/registration/index.blade.php view
public function index(){
return view('/registration/index');
}
All works fine.
Now I have uploaded this Laravel website into my remote Linux server, into this folder: /var/www/html/HotelRegistration
But now my problem is that in this remote environment I have not virtual host (correct me if I am doing wrong assertion: from what I have understand the virtual host is used on the local environment to simulate a domain that Laravel need to point to the public folder, is it this reasoning correct?)
Anyway, this is the URL of the public folder of my deployed web site on my remote server:
http://89.36.211.48/HotelRegistration/public/
As you can see opening it the Laravel landing page is correctly shown, the problem is that I can access to the previous registration page, the only way that I have found is to open this URL:
http://89.36.211.48/HotelRegistration/public/index.php/registration
but it is pretty horrible and above all when the registration form is submitted it is generated a POST request toward this URL http://89.36.211.48/registration that end into a 404 Not Found error.
So I think that it depend by the fact that in this remote server I can't use a virtual host that simulate a domain (as I have on my local environment), but I am not sure about it.
What can I do to solve the situation? Do you think that using a effective domain (something like: www.myregistration.com) that points to this directory of my remote server http://89.36.211.48/HotelRegistration/public/ I can solve this problem?
You need to configure your domain in your server and need to reconfigure the apache. I'm considering you are having apache2 server so here you can do:
Step 1 Go to the apache2 folder cd /etc/apache2
Step 2 You can see sites-available folder go inside it cd sites-available
Step 3 Make a new file name it laravel.dev.conf
Step 4 Write down the following sudo nano laravel.dev.conf
Step 5 Write down the following option:
<VirtualHost *:80>
ServerAdmin webmaster#laravel.dev
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /var/www/html/laravel.dev/public/
ErrorLog /var/www/html/laravel.dev/logs/error.log
CustomLog /var/www/html/laravel.dev/logs/access.log combined
<Directory /var/www/html/laravel.dev/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Step 6 Now go to this folder/create a new one cd /var/www/html/laravel.dev
Step 7 Copy/Install your laravel application here.
Step 8 Now you can enable your site by typing sudo a2ensite laravel.dev.conf
Step 9 Now restart the apache2 sudo service apache2 restart
Now you can have proper access to your domain. Hope this helps.
Since you are using XAMPP
Add the following into your VirtualHost Directive:
<Directory "LINUX PATH TO /HotelRegistration/public">
AllowOverride All
</Directory>
Your final VirtualHost Directive should look like:
<VirtualHost *:80>
DocumentRoot "LINUX PATH TO /HotelRegistration/public"
ServerName 89.36.211.48
<Directory "LINUX PATH TO /HotelRegistration/public">
AllowOverride All
</Directory>
</VirtualHost>
After the configuration changes, restart Apache then you are good to go.
I'm trying to create a virtual host on my MAMP setup so I can access http://api.localhost for a PHP API I'm trying to build with Slim. Here's the code I've appended to my httpd.conf file:
Name VirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "/Applications/MAMP/htdocs/slim"
ServerName api.localhost
</VirtualHost>
When I restart the server and try to start it up again with this new configuration, it simply won't load. I commented out the new code and it loads fine. Any ideas?
try to use this line
<VirtualHost *:80>
instead of yours
and I think you can remove the first line too...