How can I define my work path in XAMPP so I could write my code there and test it.
Example: In WAMP, I just added the folder 'courses01' in the 'wamp/www/' directory.
Can I do the same in XAMPP ? Just add my courses folder in the system files? But where? and how can I access them in the 'localhost/xampp' menu??
I need this so I could work with my PHP files from my courses :(
Put your folders/php_file.php in xampp\htdocs. then access http://localhost/folder or http://localhost/php_file.php in your browser.
Here is what you should do:
Step 1:
Create a dir in your Home folder usually located here:
C:/Users/Yourname/www/courses01
Step 2: Edit virtual hosts located in:
C:/xampp/apache/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\Users\Yourname\www\courses01"
ServerName courses01.dev
<Directory "C:\Users\Yourname\www\courses01">
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Step 3: Modify hosts file located in:
C:\Windows\System32\Drivers\etc\hosts
add a line:
127.0.0.1 courses09.dev
Step 4: Restart apache
Related
I have created a virtual host for a drupal website on Windows 10 using Bitnami (WAMPstack),
and when start the website , i can access to the home page only but not to sub pages or sub-directories.
in the windows etc folder i did update the hosts file and added
127.0.0.1 website.local
also edited the httpd.conf enabled the virtual host
(Include conf/extra/httpd-vhosts.conf)
also edited the httpd-vhosts file : added the follwoing
<Directory C:/vhosts>
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/Bitnami/wampstack-7.1.15-0/apache2/htdocs/website/"
ServerName website.local
</VirtualHost>
when i start browsing the site and click on any subpage i got a 404 (Not Found)
please advise.
Seems like you are missing some directives on the directory level. Here is a config that works that basically follows https://www.drupal.org/node/953296#comment-9866119
<VirtualHost *:80>
DocumentRoot /home/myrepo/mydocroot
ServerName mysite.localhost
<Directory /home/myrepo/mydocroot >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
You might need to activate the mod_rewrite in apache.
Edit the httpd.conf and search for "#LoadModule rewrite_module modules/mod_rewrite.so" remove the "#". Save and restart the apache.
Requirement is to create two website
www.example1.com
www.example2.com
with the same codebase and database without copying it to another directory or importing the sql file.
Is it possible through just pointing it based on domain name and using .htaccess file.
Any help or hints is appreciated.
Yes you can. Start by placing all of your project files on the same directory, for the sake of this example let's call it /var/www/example
Then go to /etc/apache2/sites-available and create two .conf files:
example1.conf: Virtual Host Configuration for www.example1.com
example2.conf: Virtual Host Configuration for www.example2.com
The contents of the two configuration files:
example1.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example1.com
</VirtualHost>
exampl2.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example2.com
</VirtualHost>
As you can see both of them refer the same directory as Document Root but listen to different URLs.
After you're done creating those files don't forget to run the following commands on your terminal:
a2ensite example1.conf
a2ensite example2.conf
and finally,
service apache2 reload
I am very new to magento and php and i am trying to create a virtual host url for my magento site.
Currently the url is
http://localhost:8080/Magento/
And if i create any website i have to use url's such as below
http://localhost:8080/Magento/website1
http://localhost:8080/Magento/website2
...
After referring to several examples such as this http://sawmac.com/xampp/virtualhosts/ i have managed to configure my files such as below
Step 1:
In the file C:\Windows\System32\drivers\etc\hosts i have append the below mapping
127.0.0.1 clientA.local
Step 2:
And in the file C:\xampp\apache\conf\extra\httpd-vhosts.conf i have append the below code
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs\magento"
ServerName clientA.local
<Directory "C:\xampp\htdocs\magento">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After step 1 typing typing clientA.local:8080/magento opens localhost:8080/magento
But step 2 doesn't change anything.
I want to do something as below
clientA.local should open http://localhost:8080/Magento/website1
clientB.local should open http://localhost:8080/Magento/website2
...
I have tried changing the Document root , directory in several ways nothing helped.
If any one has any idea on this senario please contribute here.
thanx
I have a dedicated server, on which I'm running several project. Lets say this is example.ro.
The server is running CentOS 6.
I've created a unix user 'dev' and a subdomain: dev.example.ro.
Lets say that I want to work on a project called 'cpl', and I have to test it live on this server (it is a php project).
I would like to use the subdomain dev.cpl.example.ro, and on the filesystem it would be under /home/dev/public_html/cpl folder.
How should I modify my .htaccess in the public_html folder in order to dynamically use subdomains?
I don't think you need to edit the .htaccess file to achieve this. But you have to create a separate site in Apache server. To demonstrate I am using am ubuntu lamp server but I think you can do the same on your CentOS.
Create a virtual site in Apache
sudo nano -w /etc/apache2/sites-available/example.conf
paste the following into the file and make necessary changes
<VirtualHost *:80>
ServerName cpl.example.ro
ServerAlias *.cpl.example.ro
DocumentRoot /home/dev/public_html/cpl
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Save the file. After that you need to enable the newly site.
sudo a2ensite example
service apache2 restart
Edit the host file to resolve the dev.cpl.example.ro
sudo nano -w /etc/hosts
add the following line to the end and save the file
127.0.0.1 dev.cpl.example.ro
I'm trying to change documentroot on my local windows machine to point at a sub directory below htdocs. I've changed the DocumentRoot location inside httpd.conf along with the Directory location. I've restarted Apache but prinitng out document root with PHP it still points to the default location.
Changes inside httpd.conf:
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/folder_test/website"
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/folder_test/website">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
When I navigate to http://localhost/folder_test/website I see the following from my PHP output:
C:/Program Files/Apache Software Foundation/Apache2.2/htdocs
My PHP code:
<?php
//Get the document root
$root = getenv("DOCUMENT_ROOT") ;
Echo $root;
?>
I've restarted Apache...What am I missing?
Open the "\conf\extra\httpd-vhosts.conf" file.
Change the
<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs"
#ServerName www.example.com:80
</VirtualHost>
section to reflect the desired directory, in your case:
<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs/folder_test/website"
#ServerName www.example.com:80
</VirtualHost>
Hey if this is not answered still:
Sometimes when you change document root and other info in httpd.conf it does not reflect that it because the changes you have dont is not saved at all. In notepad++ and diffmerge it does not show that it is not saved on the contrary it shows as saved. Open it in normal notepad and when you try to replace it it says access denied. May be this is because these folder dont have the modification permission for users. Hence for this purpose you need to
Save the changes in a separate file else where with the same name
httpd.conf
Rename http.conf inside your apache root document to
httpd_backup.conf or just delete it.
now copy the new file you have created i.e. httpd.conf to apache
root document.
Go to "Open apache monitor" and restart
clear all cache and cookies in your browser and try again