I have a Django site running on ec2 instance (ubuntu) on apache2 using mod_wsgi. I have placed it in /var/www/django_project. It is Up and running without any issues. Now i want to host another site (php, mysql) on this ec2 instance only. I tried to configure my httpd.conf and added php directory with proper permissions, but I believe due to Alias setting in mod_wsgi, any request above '/' is taken up by django.
I DO NOT have any domain name. I access my Django site with IP of machine (i.e w.x.y.z/django_app).
Correct me if I am wrong : Since i do not have server name, I cannot have both site running on port 80 using virtual Hosts.
And I do not mind running them on different ports either. Please suggest me a way to host php site on this server. which file to configure and how to configure it.
My httpd.conf file:
Alias /static /var/www/resumerepo/static
<Directory /var/www/resumerepo/static>
order deny,allow
Allow From All
</Directory>
WSGIScriptAlias / /var/www/resumerepo/resumerepo/wsgi.py
WSGIPythonPath /var/www/resumerepo
<Directory /var/www/resumerepo>
<Files wsgi.py>
Order deny,allow
Allow From All
</Files>
</Directory>
It works fine and my app is accessible. However if i put it in one virtual host and make another virtual host, apache restart throws an error saying PythonPath can not be in virtual host.
You can't do this easily if your django project is accessible via the root of your domain (or your IP), for example: http://1.2.3.4 -> leads to your django project`.
I think, one solution could be to move your django project to a subdirectory, like http://1.2.3.4/django, and make your php project also accessible in subdirectory, like http://1.2.3.4/php.
Or you can create a new virtual host, listening on port 8080, for example, for your php project. This way :
http://1.2.3.4 leads to your django project
http://1.2.3.4:8080 leads to your php project
The second option may be easier to set up, as you won't have to change config for your django project.
Your vhost file could look like :
<VirtualHost *:8080>
ServerAdmin contact#yourdomain
DocumentRoot /var/www/php
<Directory /var/www/php>
AllowOverride All
Order allow,deny
Allow From All
</Directory>
</VirtualHost>
Maybe this won't work : according to Apache documentation, you should not use virtual hosts without ServerName.
Related
I am trying to setup virtual host for Magento, but its not working, I created magento.localhost.com.conf in the Apache2/sites-avaliable directory, this is my file :
<VirtualHost *:80>
ServerAdmin magento#localhost.com
ServerName magento.localhost.com
DocumentRoot /srv/www/magento_dev/public_html
<Directory /srv/www/magento_dev/public_html/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /srv/www/magento_dev/logs/error.log
LogLevel warn
</VirtualHost>
I am following instructions from book actually ,also changed /etc/hosts file , I added 192.168.36.1 magento.localhost.com. at the end , but when I try to open the site, it says :
This webpage is not available
I enabled apache rewrite, give permission to all this folders ,basically did everything as instructions, but still not working. My os is Ubuntu 14.04, any tips ?
Follow recommendations in comments for a2ensite and for testing with a simple index.php file.
Also make sure to restart Apache.
When that works, then try with the Magento index.php file.
What you do next depends on if this is a brand new copy of Magento or a copy of a previously installed one. If it's new, you should see the setup page. Follow the instructions. If it's a copy, you will need to change the database core_config_data values relating to your website urls.
Edit:
You say
changed /etc/hosts file ,I added 192.168.36.1
On what machine did you change this? Also is your Magento running in a virtual machine on your Windows machine? And the VM machine has that IP?
Edit 2:
Also change your web server name to "Magento.mysite.com" or something like that. localhost has a special meaning! And it doesn't make sense if you are accessing a remote we server!
Check web server ip with ipconfig or ifconfig on the command prompt. Put that ip in the hosts file of the web browser machine.
I have Zend2 website configured on an Ubuntu machine.
Project Path: /var/www/zf2/
Virtual host configuration:
<VirtualHost *:80>
ServerName zf2.localhost
DocumentRoot /var/www/html/zf2/public
SetENV APPLICATION_ENV "development"
<Directory /var/www/html/zf2/public/>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Accessing "localhost/zf2" list the files in the directory. Is there anyway to access this zend2 website without virtual host i.e with localhost/zf2 ?
I already tried by adding .htacess in /var/www/html/zf2, but it does not budge. Any help will be highly appreciated!
The question isn't very clear, but if you're asking if it's possible for someone to access your ZF site without using the zf2.localhost hostname, then because of the way you have set it up, yes (and you should definitely change this).
By default, Apache on Ubuntu has localhost setup to point at /var/www/html/. So by putting your ZF2 app in a subfolder of that, it will be possible for someone to access your ZF app (including files outside of its document root) via. localhost. This is a potential security hole which you should fix. Simply move your ZF2 app to a different folder that isn't inside /var/www/html (e.g. /var/www/zf2) and you won't have this issue.
Also note that if you are using a reasonably recent version of Ubuntu, you will be running Apache 2.4, and your vhost isn't setup correctly. See the second example here: http://framework.zend.com/manual/current/en/ref/installation.html#apache-setup
On my CentOS Linux VPS I have full LAMP installed. I have a CakePHP website (and intend to add a few more) as a virtual host. I also have a web based bug tracker called MantisBT that is implemented in PHP. I'd like to set up my Apache configuration file (/etc/httpd/conf/httpd.conf) to index both side-by-side. My websites are not in DNS. I access them using the raw IP number.
Here's my directory structure:
/var/www/
MyCakePhPApp/
html/
mantisbt/
Here's what I have in my httpd.conf file:
# This makes my MantisBT work under http:/<my_ip>/mantisbt
DirectoryIndex index.php index.html
# This makes my CakePhP work under http:/<my_ip>
<VirtualHost *:80>
ServerAdmin webmaster#tecadmin.net
ServerName example.com
DocumentRoot /var/www/MyCakePhPApp
<Directory /var/www/MyCakePhPApp>
Allowoverride All
</Directory>
</VirtualHost>
With this my CakePhP is accessible as "http:/my_ip" but my mantisbt site is not accessible. "http:/my_ip/mantisbt" goes to CakePhP and says that controller is missing. If I comment out the entire VirtualHost, then Mantis is indeed accessible as: "http:/my_ip/mantisbt", but of course then my CakePHP site is not accessible.
Does anyone know how to get both these websites working side-by-side?
I installed Bitnami WAMP Stack in Windows 7 and I am trying to get my eclipse php code to run. I found a link online that said to add an alias, but that didn't work, how do I get the code to run in
http://localhost/greenmugcafe/
if my eclipse workspace is located here
C:\Users\Robert\Documents\GitHub\greenmugcafe ?
Edit: I could not find anything on doing this for Bitnami WAMP but I found a few for the Bitnami Django stack.
Any Help at all?
Your code would run from http://localhost/greenmugcafe/ if you changed the virtual host directory of localhost to C:/Users/Robert/Documents/GitHub/
Personally, I think it would be better to create a local domain called greenmugcafe.dev rather than having a folder greenmugcafe in the localhost domain.
How to setup virtual hosts in WAMP
Make sure virtual hosts have been enabled:
Edit /installdir/apache2/conf/httpd.conf
Search for line that includes httpd-vhosts.conf and uncomment it by removing the # at the start
Adding a new virtual host:
Edit the hosts file on your windows system (usually located at C:\WINDOWS\system32\drivers\etc\)
Add the following to the end of the hosts file 127.0.0.1 greenmugcafe.dev. This tells your computer that any url with a value of greenmugcafe.dev should be routed to 127.0.0.1 (aka localhost).
Save the hosts file and now edit this file /installdir/apache2/conf/extra/httpd-vhosts.conf
Add the greenmugcafe.dev virtual host entry at the bototm of the /installdir/apache2/conf/extra/httpd-vhosts.conf file, save, and restart the server.
Here's the code:
#greenmugcafe
<VirtualHost *:80>
ServerAdmin webmaster#greenmugcafe.dev
DocumentRoot "C:/Users/Robert/Documents/GitHub/greenmugcafe/"
ServerName greenmugcafe.dev
ErrorLog "logs/greenmugcafe.dev-error.log"
CustomLog "logs/greenmugcafe.dev-access.log" common
<Directory "C:/Users/Robert/Documents/GitHub/greenmugcafe/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Now http://greenmugcafe.dev will point to C:/Users/Robert/Documents/GitHub/greenmugcafe/
This method will also work for other WAMP stacks like Wamp Server and XAMPP.
For a launched website on a linux server, instead of the windows host file, we would change the a record of the domain name to point to the server IP address. Then we still need to setup the virtual host so the server knows to recognise the domain name and point it to the correct folder on the server.
Hope that helps :-)
After much faffing about I got laravel to work with XAMPP. However, I can't seem to access directories in the htdocs folder via localhost now. Attempt to access a file returns Object not found! along with The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
The changes I made to get laravel working seems like a blur now. The only thing I remember doing is editing the hosts file to enable the virtual host to work by adding 127.0.0.1 laravel.dev in the hosts file (using a mac btw). I also added a virtual host to the httpd-vhost.conf file.
I did undo the above changes but it didn't make a difference.
Any thoughts on whats gone wrong?
Thanks.
Dispelling Confusion
Just thought I'd clarify what my experience is. Before installing laravel 4 I could access all my projects with localhost/someProjectName but now it fails.
I'm trying to identify what change caused this behaviour. Btw, I have no problems accessing my laravel project (my mapping allows me access to it via laravel.dev)
Look into your /etc/httpd.conf file and see if you have Virtual hosts activated.
If so, check your etc/extra/httpd-vhosts.conf file. You might have set up a VirtualHost already.
EDIT: I have found that once you turn on Virtual Hosts, XAMPP needs a default VirtualHost for your basic htdocs files
Try adding a default VirtualHost (at the bottom of the file) like so:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"
<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
It sounds to me like it is a problem with the way your directories are configured. Be sure to create a Virtual Host (if you're using Apache) that points to the public folder within your application directory.
For example, if your Laravel project is under /Applications/XAMPP/htdocs/Laravel then set up a Virtual Host like this:
<VirtualHost *:80>
DocumentRoot /Applications/XAMPP/htdocs/Laravel/public
# Other directives here
</VirtualHost>
Additionaly, if you're working with PHP >= 5.4, SSH into the application folder and run
./artisan serve
(Be sure that your PHP executable is in your PATH variable). Then go localhost:8000 and you should have your application running.
Running this command runs the PHP built-in webserver and saves you the trouble of configuring virtual hosts.
In your Apache's http.conf, find the DocumentRoot line and add the subdirectory /public on the end.
Once that is done and you've restarted Apache, you'll be able to access everything which is contained within your htdocs/public folder (including subdirectories of that folder), along with any routes you've defined in Laravel.
Laravel is designed to be set up this way as to protect the code and files by not having them in the folder which is served out to the web.
I have same issue and found that there are miss configuration in vhost. So that's are correct configuration.
in etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/laravel-master/public"
ServerName laravel.local
ErrorLog "logs/laravel-master-error.log"
<Directory D:/xampp/htdocs/laravel-master/public>
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
In the hosts file
127.0.0.1 laravel.local
I don't know if you're running L4 or L3. However, launch CLI and
$ cd ./path/to/project
Then for L4:
$ php artisan serve
For L3:
$ php -S localhost:8000 -t public
Now you can go to localhost:8000 and see your application.
You're having problem because the object really doesn't exist in your htdocs directory. You don't have to append xampp after localhost or 127.0.0.1 because xampp will treat it as an object or a folder under htdocs.
if you want to access your blog, make sure you have a blog folder under htdocs and put in your URL localhost/blog