Configuration of virtual host - php

I was trying to create a virtual host on my localhost, I followed a tuto on the internet. Here're the steps :
1) I created my project on desktop (using laravel 5)
2) I opend the file "httpd-vhosts.conf" (C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\httpserver\apache2418x161221110224\conf\httpd-vhosts.conf ) to uncomment this line : "Include conf/extra/httpd-vhosts.conf"
3) I edited the file "httpd-vhosts.conf" I added the following lines :
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\Users\Sony\Desktop\links"
ServerName links.localhost
</VirtualHost>
4) I edited the file "hosts" (C:\Windows\System32\drivers\etc\hosts)
and added this line "127.0.0.1 links.localhost"
5) Then I restarted easyphp and executed the following command on my command line : ipconfig /flushdns
--> Results :
The file "httpd-vhosts.conf" is empty
This line is commented again : "Include conf/extra/httpd-vhosts.conf"
When I try to access the vhost "http://links.localhost", is just like if i am accessing the localhost
This is what I have at the end of "httpd.conf"
# VIRTUAL HOSTS
## Virtualhost localweb
<VirtualHost 127.0.0.1>
DocumentRoot "C:/Program Files (x86)/EasyPHP-Devserver-16.1/eds-www"
ServerName 127.0.0.1
<Directory "C:/Program Files (x86)/EasyPHP-Devserver-16.1/eds-www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
</Directory>
</VirtualHost>
#Costumized vhost config file
Include conf/links-vhost.conf

First create a file (say) name it links.conf and add your Virtual host
<VirtualHost *:80>
DocumentRoot "C:\Users\Sony\Desktop\links"
ServerName links.localhost
</VirtualHost>
Now at the the end of your httpd.conf add : Include conf/links.conf.

Related

How can I run my Laravel project without cmd command "php artisan serve"?

<VirtualHost *:80>
ServerAdmin webmaster#hujjaj.dev
DocumentRoot "C:\xampp\htdocs\hujjaj_app_new\public"
ServerName hujjaj.dev
ErrorLog "logs/hujjaj.dev-error.log"
CustomLog "logs/hujjaj.dev-access.log" common
I am doing so in my virtual host file and update 127.0.0.1 hujjaj.dev then i restart XAMPP and after that I navigate to localhost/hujjaj.dev but showing 404|Not Found.
Please try the following
<VirtualHost 127.0.0.2:80>
DocumentRoot “D:\laravel-gkb\public”
DirectoryIndex index.php
ServerName laravel-gkb.test
<Directory “D:\laravel-gkb\public”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then add the save domain in your hosts file
127.0.0.2 hujjaj.dev
Refer this for more details : link
Yes, There is another way to run laravel project, with following command..
php -S 127.0.0.1:8001 server.php
This will run your application at 127.0.0.1:8001 mentioned address.
Note: laravel default entry point is server.php thats why we mentioned it. other wise it will be index.php

Windows 10 and PHP a file_get_contents() responds with permission denied

Error:
Warning: file_get_contents(C:\Users\ET\projects\results.php): failed to open stream: Permission denied in C:\Users\ET\projects\results.php on line 16
line 16: $fileContents = file_get_contents("Files/$file","r");
XAMPP with PHP 7.3
IntelliJ PHPStorm 2019.2.3
Windows 10 Home
This fails in both the IntelliJ IDE's terminal, in CMD and in CMD opened as admin.
How is this fixed in windows where there is no chmod?
Copy your project files to (it is xampp documents folder: c:/xampp/htdocs for (php,html,css,js)):
c:/xampp/htdocs/proj1
c:/xampp/htdocs/proj2
Then set virtualhost: C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/proj1"
ServerName proj1.xx
ServerAlias www.proj1.xx
<Directory "c:/xampp/htdocs/proj1">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/proj2"
ServerName proj2.xx
ServerAlias www.proj2.xx
<Directory "c:/xampp/htdocs/proj2">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Create in windows hosts file: C:\Windows\System32\drivers\etc
127.0.0.1 localhost proj1.xx proj2.xx
Restart xampp apache2, browser and then run in browser:
http://proj1.xx
Or
http://proj2.xx
You can change c:/xampp/htdocs/proj1 to your project path C:\Users\ET\projects ofcourse in xampp virtualhosts file.
P.S. You don't know the basics ... read and learn.

Virtual host redirecting to the xampp folder, but only getting This site can’t be reached

I know I'm probably missing something simple, but I've exhausted all resources trying to get this working.
I'm running my Apache on Port:5000 and trying to direct to lsapp.dev instead of http://localhost:5000/lsapp/public/ with:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/lsapp/public"
ServerName lsapp.dev
</VirtualHost>
I have tried VirtualHost *:5000 but still can't get it work?
you can use this on command line in your project root
php artisan serve --port=your_port_number
or do this:
edit httpd-vhosts.conf that is located in C:\xampp\apache\conf\extra\httpd-vhosts.conf and add following lines at the end of the file:
# VirtualHost for LSAPP.DEV
<VirtualHost lsapp.dev:80>
DocumentRoot "C:\xampp\htdocs\lsapp\public"
ServerAdmin lsapp.dev
<Directory "C:\xampp\htdocs\lsapp">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
our apache is listening to lsapp.dev connections, but we have to configure our hosts file that allows to redirect lsapp.dev to the localhost that is located in C:\Windows\System32\drivers\etc
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lsapp.dev
Set your Virtual host file like this.
<VirtualHost *:80>
DocumentRoot "D:\laravel Task\laravel\blog" //here set your project storage path
ServerName localhost.test.com // set your url for your project
<Directory "D:\laravel Task\laravel\blog"> // again set your project storage path
AllowOverride All
Order allow,deny
Allow from all
Require all granted
set your hosts file like this
127.0.0.1 localhost.test.com
Now you can Run your project
localhost.test.com
//OR//
If you dont want to use virtual host, then you can run your project like this
goto your project folder=>
command line in your project root=>php artisan serve
your project will run in
http://127.0.0.1:8000/

XAMPP - Alias 127.0.0.1

Currently, I have XAMPP setup to where typing 127.0.0.1 in the browser redirects me to the home page found within htdocs.
I would like to be able to type "devtest" and have that be an alias for 127.0.0.1.
What I have tried so far is modifying: C:\xampp\apache\conf\extra\httpd.vhosts.conf where I added an entry that looks like:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot C:\xampp\htdocs\Workspace\MyProject
ServerName devtest
ErrorLog C:\xampp\htdocs\Workspace\MyProject\MyProject-error_log
CustomLog C:\xampp\htdocs\Workspace\MyProject\MyProject-access_log common
</VirtualHost>
Is there another step I'm missing?
Open the hosts file in Notepad:
C:\Windows\System32\drivers\etc\hosts
Add the line:
127.0.0.1 devtest
Navigate to: http://devtest
Use this, and make sure you enable using vhosts config file in apache.
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\Workspace\MyProject"
ServerName devtest.local
<Directory "C:\xampp\htdocs\Workspace\MyProject">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Using xampp/mysql workbench/

Im trying to redirect to a web page on my localhost, I have done all the nessesary configurations from my hosts files and v-hosts it picks up my address from my C:\Windows\System32\drivers\etc hosts file which is name.local but does not show the main page. Keeping in mind the site has both front and backend access. I'm new and wanna work on my application locally before i can start editing it on the server.
You posted this additional comment containing your vhost definition and hosts file contents
v-host file
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:gep.local-access_log" combined
ErrorLog "c:gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
host file:
127.0.0.1 gep.local
Here are a few suggestions:-
Have you rebooted or restarted the DNS Client to activate your HOSTS file changes.
from a command window run started using 'Run as Administrator' do this
net stop "DNS Client"
then once it reports as STOPPED
net start "DNS Client"
This will refresh the windows DNS Cache. ( Double quotes are required as there is a space in the service name )
First change <VirtualHost 127.0.0.1:80> to <VirtualHost *:80>
If you are using Apache 2.2.x you also need a NameVirtualHost *:80 parameter as the first parameter in the vhost definition file. If you are using Apache 2.4.x I believe they removed this requirement so it is not necessary on that version of Apache.
So
new v-host file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/intranet"
ServerName gep.local
ServerAlias gep.local
CustomLog "c:/gep.local-access_log" combined
ErrorLog "c:/gep.local-error_log"
<Directory "c:/xampp/htdocs/intranet">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Then of course to test it use the address `http://gep.local' in your browser address bar to get to this new virtual host.

Categories