Flask on Apache Server for Windows with HTML template Files - windows

I was hoping to get help on an issue that I am having. I am trying to deploy Flask to an Apache server. My flask uses the render template function in order to display HTML pages. I've gotten it to work on my Localhost, but now as I am trying to deploy it to the Apache server, but I am not sure about where to put the HTML files for flask to recognize. I setup my mod_wsgi to work properly with displaying a flask file that does not use HTML files, but could someone tell me where to place the files and what I am supposed to type into the httpd.conf file? Thanks you for reading my post
This is how my httpd file is set up with the wsgi, static and template tht isnt working
httpd.conf:
WSGIScriptAlias /wsgi "C:/wsgi_app/test.wsgi"
<Directory "C:/wsgi_app">
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>
Alias /static "C:/wsgi_app/static"
<Directory "C:/wsgi_app/static">
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>
Alias /templates "C:/wsgi_app/templates"
<Directory "C:/wsgi_app/templates">
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>
This is the current setup for where my files are
File Directory:
--C://
--wsgi-app/
--test.wsgi
--test.py
--static/
--templates/

Related

Apache 2.4 on Windows - Include folder out of DocumentRoot

I need to include a folder on my httpd.conf that is out of my DocumentRoot directory. I know there is a lot of info about this but not specifically for Apache 2.4 running on Windows. I tried a lot of things but anything works, I always get a forbidden error, and this is driving me mad.
Here is my default config made by WAMP:
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
That's OK but I need to include a folder project on my E:\ disk.
I have tried all of these, obviously restarting the apache server after every attempt:
Attempt #1
<Directory "e:/Development/[Git]/projectName/public/">
Require all granted
</Directory>
Attempt #2
<Directory "e:/Development/[Git]/projectName/public/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
Attempt #3
Alias /projectName "e:/Development/[Git]/projectName/public/"
# The <Directory> on attempts #1 and #2
Just to clarify:
I have tried a lot of combinations using / or \. Also using " or without. I even tried to escape the [] like this \[Git\].
I already have a VirtualHost well configured for that directory. I know it because if I remove the security on the <Directory /> then works fine, but as I have read this is a lack of security that I do not want to have:
# Disabling the security as below is not an option
<Directory />
AllowOverride none
Require all granted
</Directory>
Can anyone help me please? Thanks in advance

Routing error in laravel

I'm trying to build a web app in laravel 5.2 on windows platform with wamp server installation.
I'm trying to call a dashboard page by following routes:
Route::get('nitsadmin/dashboard', function () {
return view('nitsadmin.dashboard');
});
Following is the route list:
where my file structure is as below:
My virtual host configuration in httd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "c:\wamp\www\nitsedit\public"
ServerName nitseditor.dev
</VirtualHost>
Apache alias:
Alias /nitseditor.dev "C:/wamp/www/NitsEdit/public"
<Directory "C:/wamp/www/NitsEdit/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Don't know where I'm getting problem but I'm getting following error:
You have wrong web server configuration, just point web server to a public directory in Lararel project root and restart web server.
You're using the wrong URL, ditch the "nitsedit\public" part:
http://nitseditor.dev/nitsadmin/dashboard
Apache is already pointing the user to the public folder.
Just commented out Include conf/extra/httpd-vhosts.conf in the file httpd.conf present in folder wamp/bin/apache/apache2.4.9/conf and it worked.

How to set Aliases or VirtualHost to run a laravel project on Apache2

I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.
This is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /laravelproject /var/www/laravelproject/public
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error
Not Found
The requested URL /laravelproject/login was not found on this server.
Apache/2.4.10 (Ubuntu) Server at '' Port 80
Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.
How can i set up a virtualhost or an alias to run it with all the routes working?
You could also try enabling apache mod-rewrite if not enabled yet.
sudo a2enmod rewrite
sudo systemctl restart apache2
You'll need to make sure the /var/www/laravelproject/public directory is set to AllowOverride All (which I believe you have taken care of by setting /var/www to All). Then make sure the .htaccess file in your public directory is correctly set up: https://github.com/laravel/laravel/blob/master/public/.htaccess
this is because Apache is looking for /public/login/index.html which is not a file. Laravel's .htaccess redirects these requests appropriately, but it has to be in your public folder and Apache has to AllowOverride
edit:
<Directory /var/www/laravelproject/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

Apache RewriteEngine is not working with virtual host setup

I have a basic virtual host setup enabled on my machine, and it works fine when I just type in the server name. However, when I include "RewriteEngine On" it kills it. Yes, I do have the rewrite module installed, and yes, I have restarted apache. I'm not actually attempting any rewrite rules yet, because just the act of turning the thing on is enough to make it stop working. Any clue as to what's going on? Seems like if the module is included, this ought to work. What am I forgetting? Here's what I've got in my virtual host file
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "C:/www/mysite/public/"
ServerName mysite
RewriteEngine on
<Directory "C:/www/mysite/public/"
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
When I remove the "RewriteEngine on" line, everything works. When I put it back in, it breaks. I could understand if I had some weird rule in there, but simply turning it on shouldn't break anything.
Perhaps mod_rewrite isn't enabled in your setup? You can try to put the RewriteEngine On line inside an test like so
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
I assume you an Ubuntu-like system.
Go to /etc/apache2/sites-available/your_site.conf
Open your_site.conf using your favorite text editor.
Add/Update the Directory section as below
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Save it and restart apache.

The 'official' way to deploy multiple Rail 3.1 Apps with Passenger

I'm currently trying to get a couple of small Rails apps running on a server, normally I've used Heroku but I decided to DIY it this time for practise, and everything that is suggested on the Internet doesn't work.
I've tried pretty much all of the resources I can find on both SO and the full Phusion guide, the closest I can come is "The page you were looking for doesn't exist." The app itself runs fine when I run it with script/rails server, initalizing a new rails app to a different sub_dir runs fine, but it'll only let me use index.html, nothing else. So it looks like some kind of routing issue, but when I tried the "scope do" it falls over on "scope".
What's the actual recommended and suggested way to have multiple rails sites on sub uris?
Apache2 Configuration File
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.cybershrike.co.uk/
DocumentRoot /web/rails
<Directory /web/rails>
Allow from all
</Directory>
RailsBaseURI /test
<Directory /web/rails/test>
Options -MultiViews
</Directory>
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.cybershrike.co.uk/
DocumentRoot /web/rails
<Directory /web/rails>
Allow from all
</Directory>
RailsBaseURI /kinu
RailsEnv development
SetEnv RAILS_RELATIVE_URL_ROOT "/kinu"
PassengerAppRoot /web/rails/kinu
<Directory /web/rails/kinu/public>
Options MultiViews Indexes FollowSymLinks
</Directory>
</VirtualHost>
Have you tried the proposed default passenger option?
RailsBaseURI /kinu
RailsEnv development
<Directory /web/rails/kinu/public>
Options -MultiViews
</Directory>
</VirtualHost>
Also you have to ensure, that file-permission allow the apache-server (ususally wwwuser) to access all files recursively including /web ?
And, just to cover all bases here: did you restart apache?

Resources