I'm trying to roll out a pyramid app to a production site.
As of now, I've created the env file where the app is placed in out of the public_html, something like below:
[~/env] $
So I've typed
$ ../bin/pserve production.ini,
However, when I access www.mydomain.com, it is still showing the index.html. How should I resolve this?
I'm using a CentOS 64bit + Apache + mod_wsgi.
Settings are as followed:
Apache/2.2.24 (Unix)
mod_ssl/2.2.24
OpenSSL/1.0.0-fips
mod_wsgi/3.3
Python/2.6.6
mod_auth_passthrough/2.1
mod_bwlimited/1.4
FrontPage/5.0.2.2635 configured -- resuming normal operations
In my production.ini file, it is as followed
[app:main]
use = egg:ECommerce
reload_templates = false
debug_authorization = false
debug_notfound = false
debug_routematch = false
debug_templates = false
default_locale_name = en
mongodb.url = mongodb://my.ip.address
mongodb.db_name = mycart_demo
[filter:weberror]
use = egg:WebError#error_catcher
debug = false
;error_log =
;show_exceptions_in_wsgi_errors = true
;smtp_server = localhost
;error_email = janitor#example.com
;smtp_username = janitor
;smtp_password = "janitor's password"
;from_address = paste#localhost
;error_subject_prefix = "Pyramid Error"
;smtp_use_tls =
;error_message =
#[pipeline:main]
#pipeline =
# weberror
# ECommerce
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 8080
# Begin logging configuration
[loggers]
keys = root, ecommerce
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
[logger_ecommerce]
level = WARN
handlers =
qualname = ecommerce
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
# End logging configuration
I've managed to roll out on a production site, however, now, it's showing a 500 internal server error...
In the apache error_log, it's showing:
[Sun Apr 07 23:17:47 2013] [alert] [client <ip_address>]
/home/vretnet9/public_html/.htaccess: WSGIScriptAlias not allowed here
So I went ahead to take a look at .htaccess
.htaccess
Options +ExecCGI
AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi
WSGIScriptAlias ECommerce /home/vretnet9/modwsgi/env/pyramid.wsgi
WSGIDaemonProcess root processes=5 threads=1 display-name=%{GROUP}
WSGIProcessGroup root
WSGIApplicationGroup %{GLOBAL}
I don't know if it should actually be calling the .htaccess or if the scriptalias should be the same as the one in my .conf which is located in
/usr/local/apache/conf/userdata/std/1/$user/$domain/modwsgi.conf
the contents of modwsgi.conf is as followed:
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid user=vretnet9 group=vretnet9 threads=4 \
python-path=/home/vretnet9/modwsgi/env/lib/python3.3/site-packages
WSGIScriptAlias /ECommerce /home/vretnet9/modwsgi/env/pyramid.wsgi
<Directory /home/vretnet9/modwsgi/env>
WSGIProcessGroup pyramid
Order allow,deny
Allow from all
</Directory>
EDIT
In the apache error_log, the following is being recorded:
[Mon Apr 08 02:17:22 2013] [error] Traceback (most recent call last):
[Mon Apr 08 02:17:22 2013] [error] File
"/home/vretnet9/modwsgi/env/pyramid.wsgi", line 5, in <module>
[Mon Apr 08 02:17:22 2013] [error] from pyramid.paster import get_app,
setup_logging
[Mon Apr 08 02:17:22 2013] [error] File "/home/vretnet9/modwsgi/env/
lib/python3.3/site-packages/pyramid/paster.py", line 1, in <module>
[Mon Apr 08 02:17:22 2013] [error] import os
[Mon Apr 08 02:17:22 2013] [error] ImportError: No module named os
EDIT #2
This is my result when running in shell:
[~/modwsgi/env]# python
Python 3.3.0 (default, Mar 27 2013, 09:31:49)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print (os.getcwd())
/home/vretnet9/modwsgi/env
That is not how you will put a pyramid project into production using mod_wsgi + Apache. I recommend reading The official documentation
When you run ../bin/pserve production.ini it starts a paste HTTP server at port 8080 (defined in production.ini)
Ideally you will want to install pyramid in a fresh virtualenvironment and then configure mod_wsgi to use that instance of python. You will have to add a .wsgi script to your project and configure mod_wsgi to run that script on Apache startup.
EDIT
The ScriptAlias (and all related parts) should be in your modwsgi.conf (Make sure you import modwsgi.conf in your actual apache conf).
In that file you should define your PYTHONPATH and PYTHONHOME( esp. If you have a virtualenv) and the rest of the stuff you have already defined (WSGIApplicationGroup, WSGIScriptAlias etc.)
IMPORTANT - Make sure your apache user (apache) has read-execute permissions to the .wsgi script all the way. This means even your /home directory should be accessible to apache.
I would recommend creatijg a seaparate directory (say /opt/proj) for hosting the app and another (say /opt/env for the environment).
Here's how my pyramid.conf looks. I have Python 2.6 and keep my project (only the static things like css,images,js, and the .wsgi script) at /opt/save_project. My virtualenv is /opt/pyra
WSGIPythonHome /opt/pyra
WSGIPythonPath /opt/pyra/lib/python2.6
<VirtualHost 31.1.1.22:8005>
DocumentRoot /opt/save_project
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIProcessGroup %{GLOBAL}
WSGIDaemonProcess pyramid user=apache group=apache \
python-path=/opt/pyra/lib/python2.6
WSGIScriptAlias / /opt/save_project/pyramid.wsgi
# Get the static and favicon.ico pages working by properly aliasing them
Alias /favicon.ico /opt/save_project/static/images/favicon.ico
Alias /static /opt/save_project/static
<Directory /opt/save_project>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
You may see mod_wsgi docs for more information
Related
I am trying to run my .net Core web api application on Centos 7 + Plesk server. My application will be running in the subdomain. I set up a subdomain from the Plesk panel and transferred my files. After, I followed the article below step by step, it is not a very explanatory or helpful article.
https://learn.microsoft.com/tr-tr/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
First of all, this path does not exist /etc/nginx/sites-available/default. So with the help of other articles, I created the file api.mysite.com.conf in the etc/nginx/conf.d folder.
To configure Nginx as a reverse proxy to forward HTTP requests to your
ASP.NET Core app, modify /etc/nginx/sites-available/default. Open it
in a text editor, and replace the contents with the following snippet.
server {
listen 80;
server_name api.mysite.com *.mysite.com;
location / {
.... same as in docs.
}
}
Secondly, I created the service file by following the document. "/usr/bin/dotnet" This directory does not exist at this step, the document is not surprising again.
I solved this step by typing "/usr/share/dotnet/dotnet" instead of "/usr/bin/dotnet".
sudo nano /etc/systemd/system/kestrel-webapi.service
[Unit]
Description=Example .NET Web API App running on Centos 7
[Service]
WorkingDirectory=/var/www/vhosts/mysite.com/api.mysite.com
ExecStart=/usr/share/dotnet/dotnet /var/www/vhosts/mysite.com/api.mysite.com
After creating the service, I ran it without any problems.
The next step was Apache configuration.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
Configuration files for Apache are located within the
/etc/httpd/conf.d/ directory. Any file with the .conf extension is
processed in alphabetical order in addition to the module
configuration files in /etc/httpd/conf.modules.d/, which contains any
configuration files necessary to load modules.
I'm creating a configuration file in the "/etc/httpd/conf.d" file.
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=${REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.mysite.com
ServerAlias *.mysite.com
ErrorLog ${APACHE_LOG_DIR}webapi-error.log
CustomLog ${APACHE_LOG_DIR}webapi-access.log common
</VirtualHost>
After making this configuration, I got an error while running the following commands in order.
sudo service httpd configtest
sudo systemctl restart httpd
[Fri May 28 19:35:02.344213 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${REQUEST_SCHEME} is not defined
[Fri May 28 19:35:02.344814 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri May 28 19:35:02.344853 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
Syntax OK
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897163 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${REQUEST_SCHEME} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897775 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897825 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 28 19:39:16 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
May 28 19:39:16 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service failed.
Before doing these operations, when I opened api.mysite.com through the browser, the plesk panel welcome page was displayed. I solved this problem by writing the following code, now I am getting 403 forbidden error.
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_backup
How do I solve the above two problems? How can I redirect to my web api application when I connect to api.mysite.com?
I've been struggling with this for 3 days and I can't find the right articles on the internet, is there anyone who can help me?
I solved the problem.
When we create a domain in the plesk panel, apache creates its own configuration file, so all I have to do is change the Additional apache directives settings from within Apache & nginx under the Hosting & DNS settings of the relevant domain from the plesk panel.
Plesk --> Websites & Domains --> <> --> Hosting & DNS --> Apache & nginx
Additional directives for HTTP
Header set Access-Control-Allow-Origin "http://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
Additional directives for HTTPS
Header set Access-Control-Allow-Origin "https://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
If you have a cors problem, you can add lines starting with header set.
After doing all these, your application will run if it is ready in your service file.
I have modified the file:
/etc/apache2/sites-available/elcor.com.conf
adding:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster#elcor.com
ServerName elcor.com
ServerAlias www.elcor.com
ProxyPass / http://localhost:8080/home.html
ProxyPassReverse / http://localhost:8080/html
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/elcor.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/elcor.com/log/error.log
CustomLog /var/www/html/elcor.com/log/access.log combined
</VirtualHost>
in order to access a SpringBoot app I have in the same server, but when I acees the site, this is what I see:
When I start Apache I have this error:
-- The job identifier is 483.
Dec 01 14:16:08 localhost apachectl[1099]: AH00526: Syntax error on line 9 of /etc/apache2/sites-enabled/elcor.com.conf:
Dec 01 14:16:08 localhost apachectl[1099]: Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration
Dec 01 14:16:08 localhost apachectl[1086]: Action 'start' failed.
Dec 01 14:16:08 localhost apachectl[1086]: The Apache error log may have more information.
Dec 01 14:16:08 localhost systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
could it be the case you did not enable mod_proxy on your system?
you can do that via "a2enmod proxy_http" on your ubuntu system
I have developed web application using codeigniter on xampp server.
and want to deploy it on LAMP server. I have migrated database and app successfully but facing some problem.
When request web page using browser its not show anything not even error.
I have enabled selinux,
have root account and testing using root account
virtual host file config in /etc/httpd/conf.modules.d/hotelking.conf
<VirtualHost *:80>
ServerName www.hotelking.com
ServerAlias hotelking.com
DocumentRoot /var/www/hotelking/app/
Customlog "logs/www.hotelking.com.log" combined
ErrorLog "log/www.hotelking.com.error_log"
<Directory /var/www/hotelking/app/>
Require all granted
</Directory>
And error log have following error
[Wed Jan 06 03:20:14.515526 2016] [:error] [pid 6912] [client 127.0.0.1:40964] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
[Wed Jan 06 03:20:21.773841 2016] [:error] [pid 6908] [client 127.0.0.1:40965] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
I CHECKED IT HAS MY_controller at give location
i have some problems to setup my mod_rewrite for my Joomla-Site.
Im using Apache 2.2.22 on Debian.
Website is on Directory: /home/web/beta/
What i did:
1) Commands:
sudo a2enmod rewrite
sudo mkdir -p /var/run/apache2
sudo chown -R www-data /var/run/apache2
sudo a2enmod actions
sudo /etc/init.d/apache2 force-reload
2) Then i setup following file: /etc/apache2/sites-enabled/000-default
<Directory /home/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
3) The htaccess file at path /home/web/beta/.htaccess i set:
RewriteEngine On
(I took the .htaccess from this site: http://www.joomla-security.de/downloads.html)
Ok, now the Problem.
As long as i set the AllowOverride to FileInfo i get following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#localhost and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log. Apache/2.2.22 (Debian) Server at XXXXXXX.com Port 80
What i did wrong?
Can you help me please?
EDIT: Error Log:
[Wed Nov 11 19:21:56 2015] [notice] caught SIGTERM, shutting down
[Wed Nov 11 19:21:57 2015] [notice] Apache/2.2.22 (Debian) PHP/5.4.45-0+deb7u2 configured -- resuming normal operations
[Wed Nov 11 19:21:57 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:58 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:59 2015] [alert] [client XX.XX.XX.144] /home/web/beta/.htaccess: Options not allowed here
It seems, from the errors you've posted, that you are trying to use the Options directive in .htaccess. To do that, you need to add Options to the AllowOverride directive in 000-default (cf. https://httpd.apache.org/docs/2.2/mod/core.html#options).
So change:
AllowOverride FileInfo
to
AllowOverride FileInfo Options
in 000-default.
Edit:
And if the above doesn't work, try changing it to:
AllowOverride All
And if that doesn't work then it could mean that other configuration files are getting loaded after 000-default and overwrite some of the directives.
I have some issues with setting an clustered environment for weblogic and Apache. The structure is like this: 1 webserver that proxies requests to a clustered environment of 3 weblogic servers.
Everytime i send the request to the apache server , the request gets unhandled. I figured out a part of the problem , but that is something that is not intended in production. whenever i add DynamicServerList On the requests fail. When i switch it to off it works, but that means whenever a server fails , apache will still send requests to that server and user experience would be 0.
EDIT 1: I am using weblogic 12c and apache2.4 for Centos 7
EDIT 2: There is no firewall nor selinux active
Here is my config file for weblogic plugin:
<VirtualHost *:8080>
ServerAdmin postmaster#webserver2
ServerName webserver2
DocumentRoot /var/www/webserver2/htdocs
ErrorLog /var/log/httpd//webserver-error_log
CustomLog /var/log/httpd/webserver-access_log forwarded
<Directory />
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<Location />
SetHandler weblogic-handler
</Location>
<IfModule mod_weblogic.c>
WeblogicCluster 192.168.166.70:8001,192.168.166.71:8001,192.168.166.69:8001
ConnectTimeoutSecs 15
ConnectRetrySecs 10
WLIOTimeoutSecs 600
DynamicServerList ON
Idempotent ON
FileCaching ON
KeepAliveSecs 60
KeepAliveEnabled ON
DebugConfigInfo ON
</IfModule>
</VirtualHost>
And the errors I get are the following:
[Mon Sep 14 09:54:58.480616 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
parseJVMID: could not resolve hostname '-1062689209'. Returning NULL
from parseJVMID
[Mon Sep 14 09:54:58.480681 2015] [weblogic:error]
[pid 15343:tid 140547949991680] [client 172.18.132.50:57991]
<1534314422136982> initJVMID: parseClusterServerList failure
[Mon Sep
14 09:55:28.481215 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
request [/clusterjsp/HaJsp.jsp] did NOT process
successfully..................