Do I need to update my host file and apache httpd.conf files manually whenever I create a new zf project using command.
For ex: if my new project is zendi.
in host file:
127.0.0.1 localhost zendi
in httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www\zendi\public"
ServerName zendi
ErrorLog "C:\wamp\logs\apache_error.log"
<Directory "C:\wamp\www\zendi\public" >
Options Indexes FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
If you are using PHP 5.4, then you can use the built-in web server, and you don't even need Apache.
http://php.net/manual/en/features.commandline.webserver.php
If you need to use virtual host for your newly created zf application then the answer is YES you need to configure it manually command line project creation doesn't configure it for you. But if you don't need to have virtual server for every application you create then you can skip the process and go with direct url:
localhost/zendi/public
(But it is often considered good practice to have virtual hosts configured for the projects that you'll be working for a while)
Related
Actually, I downloaded PHP7.2.7 safe thread from PHP's website(php.net) and I don't know if it is possible I can configure PHP to setup a virtualhost like we can do using XAMPP
You can try below configuration:
1) Entry in hosts file as below
127.0.0.1 example.com
2) Set virtual host in httpd-vhosts.conf as below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example/public_html"
ServerAlias quickstart.com
<Directory "/var/www/example/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
PHP has a built-in web server, but is has limited capability. It does not provide all the configuration options a complete web server does. It does not do VirtualHost.
If you need VirtualHost, you will have to include it as a module inside Apache (or other web server). The module will be global. If your pages in a VirtualHost do not need PHP, PHP remains dormant and does nothing.
PHP isn't a web server, you need to create a VirtualHost in Apache. If you're using Linux, open up httpd.conf or /etc/apache2/sites-enabled/000-default.conf
and enter the following lines.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to restart your web server/apache in order to these changes to work.
I use Windows 10 and XAMPP for local development. I want to create project on laravel 5.5 and access it in browser by project.dev
I add next lines to httpd-vhosts.conf file
<VirtualHost project.dev:80>
DocumentRoot "C:\xampp7\htdocs\server\laravel\project_name\public"
ServerAdmin project.dev
<Directory "C:\xampp7\htdocs\server\laravel\project_name">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and
127.0.0.1 project.dev
to hosts file. But it does not work (only for laravel),I get 400 error.
This works with all the rest my local projects except those ones on laravel.
I have no problem with access to this project by
http://localhost/server/laravel/project_name/public
What other settings do I have to make to access laravel 5.5 project like project.dev?
1- change VirtualHost project.dev:80 to VirtualHost *:80
2- change ServerAdmin project.dev to ServerName project.dev
and after these changes restart your apache service
Hello i am learning Laravel and trying to modifying vhost file of my xampp server for laravel practice project, but its not working.
code of vhost file is
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/laravel5Prc/public"
ServerAdmin admin#localhost
ServerName laravel5.prc
ServerAlias laravel5.prc
<Directory "D:/xampp/htdocs/laravel5Prc/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# if you want access from other pc's on your local network
#Require ip 192.168.1.121
# Only if you want the world to see your site
#Require all granted
</Directory>
</VirtualHost>
i have taken this code from this url
How to enable Virtual Host on Xampp for Laravel?
its not working form me, anyone please guide me what am i doing wrong in it ?
I'm strongly recommend you to use Laravel's vagrant box called Homestead instead of xampp, it's really amazing! You can read about it here. It's much more flexible and easier to understand than anything else.
I was using php-7.3.2 and had similar problem. This is not the solution to the problem, but an alternative. I went back to php-7.1.25 and ran again. I'm still going to check out what the problem is with version 7.3 and laravel, but maybe this will help some people who come here with the same problem.
This is what you should do, add or uncomment this below at the top of the xampp vhost file
NameVirtualHost *:80
Change this to you valid assumed domain and add the Directory index
ServerName laravel5.test
ServerAlias laravel5.test
DirectoryIndex index.php
And then go to the this folder C:\Windows\System32\drivers\etc\hosts in windows and add your domain of choice for example see this below
127.0.0.2 laravel5.test
127.0.0.3 anotherdomain.test
**** Please note don't use the localhost or 127.0.0.1 created by default to set yours's
you should create you own e.g. (127.0.0.2, 127.0.0.3, 127.0.0.4) in that order
After then restart you xampp server you should be good to go
**** I notice your Document and Directory has this "D:/xampp/htdocs/laravel5Prc/public"
change the D to C and please I would advise your laravel project should be outside the xampp folder, you can use the Document folder for this.
//Open C:\Windows\System32\drivers\etc\hosts
127.0.0.1 laravel5.prc
//Open xampp/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/laravel5Prc/public"
ServerName laravel5.prc
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/d`enter code here`ummy-host2.example.com-access.log" common
</VirtualHost>
why you don't use
php artisan serve
to run laravel on localhost.
from https://laravel.com/docs/5.4/
This problem has been bugging me for days and I really need an answer.
I have a previous WAMP server in which I have configured properly so I can set up virtual hosts for applications that I build. It served me well for months.
Recently, there's this software, in which I think is a Malware, that run in my pc. The software was removed and I scanned the pc and there were no viruses.
I re-installed WAMP server and configured it again. It went well but the virtual hosts are not behaving properly.
These are what I have declared:
In httpd-vhost:
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/Thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/Thesis">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
In my hosts file:
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
The thing is, I am able to access the pixtcha.dev properly and there were no problems, while the copers.com is inaccessible, when I type it, it redirects me to some website from the web. I just don't understand why this happens. I even tried flushing the dns if there were corrupted local files but I just can't figure it out.
Also, I have tried using the server names from my previous virtual host and they are all inaccessible too. They are giving me:
http://copers.edu.ph is not available
So I resorted to using new server names, but I don't understand why can't I use the previous server names from my previous WAMP configuration. :(
What do you think are the problems? And how to solve them?
Please help. Thanks in advance.
Ok a couple of things that might help here.
As Apache 2.4 is IPV4 and IPV6 aware you need to change your HOSTS file like this so if the browser decides to use IPV6 it knows where to find your domains. I wish I knew what controls the broswers decision, but I dont.
127.0.0.1 localhost
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
::1 localhost
::1 pixtcha.dev
::1 copers.com
Dont forget to restart the dnscache or reboot after changing this file.
From a command windows, started using the 'Run as Administrator' option, do these 2 commands to restart the dnscache.
net stop dnscache
net start dnscache
Also when you create Virtual Hosts the default host, as defined in httpd.conf, is ignored, so you need to add a VHOST definition for localhost.
Also you are using old Apache 2.2 syntax in your VHOST definitions, incorrectly as well as it happens, and this should be changed to Apache 2.4 syntax
Also it is better to stick to lower case for directory names, Windows does not care but if you ever move code to a Unix live server it may cause confusion.
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/thesis">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
Check and make sure that your scripts (PHP?) in your copers.com root (index.php?) are not redirecting to these outside URLs, or to URLs further inside your local site that would redirect outside as well.
Also in Chrome, you can open the Network tab of Developer Tools to see what actual web requests are being made, and in what order.
I am trying to set up symfony on my Ubuntu system. Now as going through the installation tutorial of symfony I found to Create a virtual host for my (to be created) application. I did the same steps as bellow.
httpd.conf
NameVirtualHost 127.0.0.1:9090
Listen 127.0.0.1:9090
<VirtualHost 127.0.0.1:9090>
ServerName www.symfony.jobeet.lcl
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
And Here is My /etc/hosts file
127.0.0.1 www.symfony.jobeet.lcl
Now I restarts my lampp server and entered www.symfony.jobeet.lcl in my browser it takes me to http://www.symfony.jobeet.lcl/xampp/ this Url. If I try without using virtual host, It works fine. also when I try www.symfony.jobeet.lcl:9090 It works. I expect it should work without giving the port number. Am I doing something wrong ?
I have created the simple bash script to simplify the process of new hosts creation. So that you don't have to do anything with config files, etc. Check if you are interested here.
Creating new host is as simple as running a command from terminal $ sudo ./newhost.sh. Then you will be asked to enter desired host name.
Change this lines
NameVirtualHost 127.0.0.1:9090
Listen 127.0.0.1:9090
<VirtualHost 127.0.0.1:9090>
to
NameVirtualHost 127.0.0.1:80
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>