how to run a symfony and a non-symfony project on the same server - apache2.4

I want to run different php project on my apache server : one is a symfony 5 project and other are classic php projects.
in my httpd-vhosts.conf apache configuration file, I put these parameters for running the symfony projet :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/em_occurence_v2/public"
DirectoryIndex index.php
<Directory "C:/xampp/htdocs/em_occurence_v2/public">
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
</VirtualHost>
this URL (for my symfony project) works fine : http://localhost/aff_date_prep_data
but my other non-symfony projet, like this URL, doesn't : http://localhost/em_occurence/em_occ.php
how can I configure my httpd-vhosts.conf file to add these others projects ?
thank you for your help

I finaly find how to access to Symfony project without modifing any apache configuration file.
the name of the Symfony project is : "em_occurence_v2", so I could access to all symfony route (for example "aff_date_prep_data"), with this kind of URL :
http://localhost/em_occurence_v2/public/index.php/aff_date_prep_data
So I could access my old non-Symfony project with using this URL :
http://localhost/em_occurence/em_occ.php

Related

Ruby on Rails on Google Cloud Engine

I deployed a Ruby stack on GCE with Passenger. It was the default click-to-deploy option.
Now to serve my app I placed it in /var/www/app-name/
I edited the virtual host file for the same with this
<VirtualHost *:80>
ServerName app-name
DocumentRoot /var/www/app-name/public
<Directory /var/www/app-name/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>
I have edited the host file too to include the IP of the project
Apache still can't serve the Rails app. What am i doing wrong? I am new at cloud hosting and Rails and there is no proper documentation for this to follow.
Any kind of help appreciated :)

redmine and mod_vhost_dbd

I've problem to run redmine with vhost_dbd_module from apache. Redmine was installed under /var/www/redmine/ directory. My apache config look:
<VirtualHost *:80>
ServerName HOSTNAME
DocumentRoot "/var/www/" # THIS IS NOT WORKING
# DocumentRoot "/var/www/redmine/public" # THIS WORKS WITH REDMINE
<Directory />
Options FollowSymLinks -MultiViews -Indexes
AllowOverride All
</Directory>
DBDriver mysql
DBDParams host=localhost,user=test,pass=test,dbname=test
DBDocRoot "SELECT document_root FROM vhosts WHERE server_name = %s" HOSTNAME
</VirtualHost>
Field document_root from database return '/var/www/redmain/public' - so it should works. It works for php projects where index file is under '/var/www/project/public'. Besides the page return 404 because in /var/www/redmain/public there is no index file. I want universal config
Any suggestions?
Best regards, Peter
Not havng a index.html is ok :) Check your config/routes.rb.
If rails service is running then your redmine rails check your routes.rb and deliver the default page there (view).
Passenger as an apache module is not compatible with about all modules used to define "dynamic" document roots (including mod_vhost_dbd). For passenger, you have to statically configure your apps in the Apache configuration.
Generally, you will have a hard time emulating your PHP setup with any Ruby app server, as they expect to be started once and run continuously, unlike PHP "apps" which act as scripts resolved and started new for each request. You should rethink your setup for persistent application server processes.
I created .htaccess with content below and it working :)
RailsBaseURI /
PassengerAppRoot /var/www/redmine

get 404 with passenger and rails

I'm trying to run a rails app on a shared hoster.
I create the app in the directory /home/rails_projects/jens_blog and the document root is /home/www/jens_blog.
In the /home/www/jens_blog dir is a symlink public -> /home/rails_projects/jens_blog/public/
I created a scaffold posts. But when i run the mydomain/ or mydomain/posts in the browser I get always an 404 error.
File does not exist: /home/www/jens_blog/public/posts
<VirtualHost ip.port>
ServerName www.mydomain.de
ServerAdmin webmaster#www.mydomain.de
DocumentRoot /home/www/jens_blog/public
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/bin/ruby
PassengerDefaultUser myuser
PassengerAnalyticsLogUser myuser
CustomLog /home/log/access_log mesos2
<Directory "/home/www/jens_blog/public">
Allow from all
Options -MultiViews
Options FollowSymLinks
</Directory>
</VirtualHost>
if I put a index.php file into the /home/rails_projects/jens_blog/public/ dir the file content will be show.
Can anybody help me?? I am desperated.
I have only a shared web hosting.
Update: I added "PassengerResolveSymlinksInDocumentRoot on" to the apache config. But now I get Exception LoadError in PhusionPassenger::Rack::ApplicationSpawner (no such file to load -- bundler)
:-((
Cheers
Jens
My question was quite similar to yours Deployed rails site on ec2 using capistrano, but it doesn't show up on the browser, here is the site -> http://passionate4.net/
I would say place your site in this directory /var/www/myapp/public.
Use these settings.
ServerName www.passionate4.net
DocumentRoot /var/www/capi_app/current/public
RailsEnv production
Allow from all
Options -MultiViews
I have written couple of blogs on how to successfully deploy the site on Ubuntu. I believe you problem is quite similar to mine. http://recipe4developer.wordpress.com/

Multiple Zend applications on same host

I'm developing a Zend application that should be installed on a host that I don't access to it. I have two problems:
On the server there is no zend-server-ce installation.
Application should be installed beside some other CMS'es like wordpress and Jumla.
There is two choices available for me to implement, first one is place each cms in a sub-domain and second is place each cms in a folder.
for example first one may look like this:
blog.host.com --> for Wordpress
contents.host.com --> for Jumla
management.host.com --> for zend application
and second one may be:
host.com/blog --> for Wordpress
host.com/contents --> for Jumla
host.com/management --> for zend application
I can't configure Document Root for some specific folder on host. Currently I configured a virtual host on my local machine changing /etc/apache2/httpd.conf to:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/my_project/name/public"
ServerName pl.localhost
</VirtualHost>
So what should I do for doing same on a host that I don't access to it's apache?
as for me - better way is to use sub-domains.
config fo example blog.host.com
DocumentRoot - is a full path to index.php
<VirtualHost *:80>
DocumentRoot "/var/www/blog.host.com/www"
ServerName blog.host.com
</VirtualHost>
for zend application - just read docs/README.txt in your project witch looks like:
README
======
This directory should be used to place project specfic documentation including
but not limited to project notes, generated API/phpdoc documentation, or
manual files generated or hand written. Ideally, this directory would remain
in your development environment only and should not be deployed with your
application to it's final production location.
Setting Up Your VHOST
=====================
The following is a sample VHOST you might want to consider for your project.
<VirtualHost *:80>
DocumentRoot "/mnt/winc/www/zend_test/public"
ServerName zend_test.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/mnt/winc/www/zend_test/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but when deploying Indexes better set to -Indexes to disallow browsing your files.
EDIT 1
also check apache doc for options
and AllowOverride
for detailed information

Prevent access to files in a certain folder

I have a folder with a lot of .php files. I would like to deny access to them (using .htaccess). I know an option is to move this folder outside public_html, but this is not possible in this situation.
Is is possible to block access to a whole folder?
Add this to the .htaccess file:
order deny,allow
deny from all
Apache 2.4 now uses a different way to do this so the method that works for Apache 2.2 will not work. See below for the method that will work for Apache 2.4. Place this in your Apache .htaccess file or better yet in a <Directory> directive in the Apache .conf file for your site.
Using .htaccess:
If using Apache 2.2:
order deny,allow
deny from all
If using Apache 2.4 use:
Require all denied
Using Apache Configuration files:
Instead of using a .htaccess file, it is usually preferred to place the configuration directly in your Apache .conf file as follows:
<Directory "/var/www/mysite">
Require all denied
</Directory>
Or if using a virtual host:
<VirtualHost *:80>
### Other configuration here ###
<Directory "/var/www/mysite">
Require all denied
</Directory>
### Other configuration here ###
</VirtualHost>
Of course the above configurations are examples, and you will need to adjust according to your requirements.
Create .htaccess file inside the desired folder with the following contents:
Deny from all
Edit apache2.conf or httpd.conf, whatever you find in Apache2 directory (probably located in /etc/apache2). You'll need to edit/check the following:
AllowOverride ALL (in the related <Directory> tag)
AccessFileName .htaccess
Edit your site's configuration file only in case you have a <Directory> tag specified inside it and add the following line:
AllowOverride ALL
Restart your Apache2 server
service apache2 restart
The above steps are all meant for Linux environments. The same instructions would work well for Windows environments except for the paths and the server restart command.
Reference: http://www.cyberciti.biz/faq/apache-htaccess/
Just add a .htaccess file with the code Deny from all to the folder.
More info at http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html