Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am trying to run the apache on my Ubuntu gives me following error #515

Closed
pankajingle opened this issue Jan 22, 2020 · 20 comments
Closed

Comments

@pankajingle
Copy link

I am using python 3.4.3

[Wed Jan 22 09:51:06.124109 2020] [:error] [pid 34690:tid 139875130636160] mod_wsgi (pid=34690): Target WSGI script '/home/encoded/encoded/parts/production-indexer/wsgi' cannot be loaded as Python module.
[Wed Jan 22 09:51:06.124168 2020] [:error] [pid 34690:tid 139875130636160] mod_wsgi (pid=34690): Exception occurred processing WSGI script '/home/encoded/encoded/parts/production-indexer/wsgi'.
[Wed Jan 22 09:51:06.124194 2020] [:error] [pid 34690:tid 139875130636160] Traceback (most recent call last):
[Wed Jan 22 09:51:06.124314 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/parts/production-indexer/wsgi", line 115, in
[Wed Jan 22 09:51:06.124321 2020] [:error] [pid 34690:tid 139875130636160] application = loadapp("config:" + configfile, name="indexer")
[Wed Jan 22 09:51:06.124504 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
[Wed Jan 22 09:51:06.124511 2020] [:error] [pid 34690:tid 139875130636160] return loadobj(APP, uri, name=name, **kw)
[Wed Jan 22 09:51:06.124531 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
[Wed Jan 22 09:51:06.124553 2020] [:error] [pid 34690:tid 139875130636160] return context.create()
[Wed Jan 22 09:51:06.124570 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 710, in create
[Wed Jan 22 09:51:06.124574 2020] [:error] [pid 34690:tid 139875130636160] return self.object_type.invoke(self)
[Wed Jan 22 09:51:06.124587 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 144, in invoke
[Wed Jan 22 09:51:06.124591 2020] [:error] [pid 34690:tid 139875130636160] **context.local_conf)
[Wed Jan 22 09:51:06.124607 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/util.py", line 55, in fix_call
[Wed Jan 22 09:51:06.124611 2020] [:error] [pid 34690:tid 139875130636160] val = callable(*args, **kw)
[Wed Jan 22 09:51:06.124744 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/develop/snovault/src/snovault/elasticsearch/es_index_listener.py", line 218, in composite
[Wed Jan 22 09:51:06.124750 2020] [:error] [pid 34690:tid 139875130636160] app = loader.get_app(app_name, global_conf=global_conf)
[Wed Jan 22 09:51:06.124769 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 350, in get_app
[Wed Jan 22 09:51:06.124773 2020] [:error] [pid 34690:tid 139875130636160] name=name, global_conf=global_conf).create()
[Wed Jan 22 09:51:06.124786 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 710, in create
[Wed Jan 22 09:51:06.124790 2020] [:error] [pid 34690:tid 139875130636160] return self.object_type.invoke(self)
[Wed Jan 22 09:51:06.124803 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 146, in invoke
[Wed Jan 22 09:51:06.124807 2020] [:error] [pid 34690:tid 139875130636160] return fix_call(context.object, context.global_conf, **context.local_conf)
[Wed Jan 22 09:51:06.124829 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/PasteDeploy-1.5.2-py3.4.egg/paste/deploy/util.py", line 55, in fix_call
[Wed Jan 22 09:51:06.124833 2020] [:error] [pid 34690:tid 139875130636160] val = callable(*args, **kw)
[Wed Jan 22 09:51:06.124847 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/src/encoded/init.py", line 217, in main
[Wed Jan 22 09:51:06.124851 2020] [:error] [pid 34690:tid 139875130636160] config.include('snovault')
[Wed Jan 22 09:51:06.124864 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/pyramid-1.6a2-py3.4.egg/pyramid/config/init.py", line 798, in include
[Wed Jan 22 09:51:06.124867 2020] [:error] [pid 34690:tid 139875130636160] c(configurator)
[Wed Jan 22 09:51:06.124947 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/develop/snovault/src/snovault/init.py", line 60, in includeme
[Wed Jan 22 09:51:06.124953 2020] [:error] [pid 34690:tid 139875130636160] config.include('.storage')
[Wed Jan 22 09:51:06.124970 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/pyramid-1.6a2-py3.4.egg/pyramid/config/init.py", line 798, in include
[Wed Jan 22 09:51:06.124973 2020] [:error] [pid 34690:tid 139875130636160] c(configurator)
[Wed Jan 22 09:51:06.125140 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/develop/snovault/src/snovault/storage.py", line 54, in includeme
[Wed Jan 22 09:51:06.125146 2020] [:error] [pid 34690:tid 139875130636160] store_profile_name=registry.settings.get('blob_store_profile_name')
[Wed Jan 22 09:51:06.125164 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/develop/snovault/src/snovault/storage.py", line 303, in init
[Wed Jan 22 09:51:06.125168 2020] [:error] [pid 34690:tid 139875130636160] self.store_conn = boto3.Session(profile_name=store_profile_name).client('s3')
[Wed Jan 22 09:51:06.125307 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/boto3-1.7.30-py3.4.egg/boto3/session.py", line 80, in init
[Wed Jan 22 09:51:06.125313 2020] [:error] [pid 34690:tid 139875130636160] self._setup_loader()
[Wed Jan 22 09:51:06.125329 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/boto3-1.7.30-py3.4.egg/boto3/session.py", line 120, in _setup_loader
[Wed Jan 22 09:51:06.125333 2020] [:error] [pid 34690:tid 139875130636160] self._loader = self._session.get_component('data_loader')
[Wed Jan 22 09:51:06.125528 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 726, in get_component
[Wed Jan 22 09:51:06.125534 2020] [:error] [pid 34690:tid 139875130636160] return self._components.get_component(name)
[Wed Jan 22 09:51:06.125551 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 922, in get_component
[Wed Jan 22 09:51:06.125555 2020] [:error] [pid 34690:tid 139875130636160] self._components[name] = factory()
[Wed Jan 22 09:51:06.125568 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 184, in
[Wed Jan 22 09:51:06.125571 2020] [:error] [pid 34690:tid 139875130636160] lambda: create_loader(self.get_config_variable('data_path')))
[Wed Jan 22 09:51:06.125584 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 279, in get_config_variable
[Wed Jan 22 09:51:06.125587 2020] [:error] [pid 34690:tid 139875130636160] elif self._found_in_config_file(methods, var_config):
[Wed Jan 22 09:51:06.125599 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 306, in _found_in_config_file
[Wed Jan 22 09:51:06.125609 2020] [:error] [pid 34690:tid 139875130636160] return var_config[0] in self.get_scoped_config()
[Wed Jan 22 09:51:06.125622 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/eggs/botocore-1.10.30-py3.4.egg/botocore/session.py", line 383, in get_scoped_config
[Wed Jan 22 09:51:06.125626 2020] [:error] [pid 34690:tid 139875130636160] raise ProfileNotFound(profile=profile_name)
[Wed Jan 22 09:51:06.125640 2020] [:error] [pid 34690:tid 139875130636160] botocore.exceptions.ProfileNotFound: The config profile (encoded-files-upload) could not be found

@GrahamDumpleton
Copy link
Owner

Most likely you are trying to read a config file using a relative path, or through a ~ home directory reference. You cannot do that as the working directory of the process will not be where your code is, nor will it be running as your user but the Apache user. See for a start:

but also check other sections of that documentation, as could also be a permissions issue since code will run as Apache user.

@pankajingle
Copy link
Author

I have all the code placed in /home/encoded/encoded is my default directory and i am starting apache as root. Whats your suggestion towards to resolve this issue.

@GrahamDumpleton
Copy link
Owner

I already told you what the likely problem is and that documentation link explains what you need to do.

You are using a relative path to read a file. You cannot do that and expect it to work. The problem code showed by the error traceback is:

[Wed Jan 22 09:51:06.124947 2020] [:error] [pid 34690:tid 139875130636160] File "/home/encoded/encoded/develop/snovault/src/snovault/init.py", line 60, in includeme
[Wed Jan 22 09:51:06.124953 2020] [:error] [pid 34690:tid 139875130636160] config.include('.storage')

The path .storage is a relative path. You need to calculate the location of that file as an absolute path somehow and pass that in the call.

@pankajingle
Copy link
Author

@GrahamDumpleton
Thanks I am able to resolve the issue but facing other mod_wsgi issue when i try to restart the apache server

  • Restarting web server apache2 [fail]
  • The apache2 configtest failed.
    Output of config test was:
    AH00526: Syntax error on line 6 of /etc/apache2/sites-enabled/encoded.conf:
    Invalid process count for WSGI daemon process.
    Action 'configtest' failed.

@GrahamDumpleton
Copy link
Owner

You have some how mucked up your Apache config file. What is in encoded.conf? Ensure you haven't introduced wrong sort of quotes, or some strange unicode non visible character, eg., strange space.

@pankajingle
Copy link
Author

pankajingle commented Jan 30, 2020

Now i am getting
Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

encoded.conf

KeepAliveTimeout 75

# The socket directory must be readable by the daemon process user
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess encoded user=encoded group=encoded processes=1 threads=1 display-name=encoded-app
# No need for embedded interpreters
WSGIRestrictEmbedded On
# Pass the authorization header so basic auth works
WSGIPassAuthorization On

# Indexer. Configure first to avoid catchall '/'
WSGIDaemonProcess encoded-indexer user=encoded group=encoded processes=1 threads=1 display-name=encoded-indexer
WSGIScriptAlias /_indexer /home/encoded/encoded/parts/production-indexer/wsgi process-group=encoded-indexer application-group=%{GLOBAL}

# visindexer. Configure first to avoid catchall '/'
WSGIDaemonProcess encoded-visindexer user=encoded group=encoded processes=1 threads=1 display-name=encoded-visindexer
WSGIScriptAlias /_visindexer /home/encoded/encoded/parts/production-visindexer/wsgi process-group=encoded-indexer application-group=%{GLOBAL}


# https://github.com/GrahamDumpleton/mod_wsgi/issues/2
SetEnvIf Request_Method HEAD X_REQUEST_METHOD=HEAD

ForensicLog ${APACHE_LOG_DIR}/forensic_log.log
LogFormat "%{forensic-id}n %v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %{X-Stats}o&server_time=%D" vhost_combined_stats
<Directory /home/encoded/encoded/parts/production-indexer>
    Order deny,allow
    Allow from all
    <IfModule access_compat_module>
        Require all granted
    </IfModule>
</Directory>

<Directory /home/encoded/encoded/parts/production-visindexer>
    Order deny,allow
    Allow from all
    <IfModule access_compat_module>
        Require all granted
    </IfModule>
</Directory>


# Specifying process-group and application-group here ensures processes are started on httpd start
WSGIScriptAlias / /home/encoded/encoded/parts/production/wsgi process-group=encoded application-group=%{GLOBAL}

<Directory /home/encoded/encoded/parts/production>
    Order deny,allow
    Allow from all
    <IfModule access_compat_module>
        Require all granted
    </IfModule>
    # Limit upload size to 500000 MB (375000MB before base64 encoding)
    LimitRequestBody 524288000000
    # Apache adds -gzip to outgoing ETag in mod_deflate, remove inbound.
    # https://issues.apache.org/bugzilla/show_bug.cgi?id=39727
    RequestHeader edit If-Match    -gzip\"$    \"
    RequestHeader edit If-None-Match    -gzip\"$    \"

    # CORS support
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "GET, HEAD"
    Header always set Access-Control-Allow-Headers "Accept, Origin, Range, X-Requested-With"
    Header always set Access-Control-Expose-Headers: "Content-Length, Content-Range, Content-Type"

    # CORS preflight
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^ - [redirect=200,last]
</Directory>

# Serve static resources directly from Apache
Alias /static /home/encoded/encoded/src/encoded/static
Alias /favicon.ico /home/encoded/encoded/src/encoded/static/img/favicon.ico

<Directory /home/encoded/encoded/src/encoded/static>
    Order deny,allow
    Allow from all
    <IfModule access_compat_module>
        Require all granted
    </IfModule>
</Directory>

# Compress JSON responses.
AddOutputFilterByType DEFLATE application/javascript application/json text/css text/html text/javascript

# Source map type (to enable compression)
<FilesMatch \.js\.map$>
    ForceType application/json
</FilesMatch>

RewriteEngine On

# Exclude robots from all but production site
RewriteCond %{HTTP_HOST} =127.0.0.1
#RewriteCond %{HTTP_HOST} =www.encodeproject.org
RewriteRule ^/robots\.txt$  /static/robots.txt  [last,passthrough]
RewriteRule ^/robots\.txt$  /static/dev-robots.txt  [last,passthrough]

# Google site verification
RewriteRule ^/google[0-9a-f]+.html$  /static$0  [last,passthrough]

# Proxy modencode comparative page
#<Location /comparative>
#   ProxyPass    http://cake.encodedcc.org/comparative
#   ProxyPassReverse  http://cake.encodedcc.org/comparative
#</Location>

# Proxy internal redirects for file downloads
#SSLProxyEngine On
#RewriteCond %{ENV:REDIRECT_STATUS} .
#RewriteRule ^/_proxy/(.+)$  $1  [proxy]

# Forbid PUT/PATCH/POST to plain http
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$
RewriteCond %{HTTP_HOST} ^(127\.0\.0\.1)$
#RewriteCond %{HTTP_HOST} ^(www\.encodeproject\.org|test\.encodedcc\.org)$
RewriteRule ^ - [forbidden]

# Forbid basic auth to plain http
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteCond %{HTTP:Authorization} .
RewriteCond %{HTTP_HOST} ^(127\.0\.0\.1)$
#RewriteCond %{HTTP_HOST} ^(www\.encodeproject\.org|test\.encodedcc\.org)$
RewriteRule ^ - [forbidden]

ErrorDocument 403 "Forbidden. HTTPS required for authenticated access."

# Redirect no-www to https://www.encodeproject.org
RewriteCond %{HTTP_HOST} =127.0.0.1
#RewriteCond %{HTTP_HOST} =encodeproject.org
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
RewriteCond %{HTTP:Authorization} !.
RewriteRule ^ https://www.encodeproject.org%{REQUEST_URI} [redirect=permanent,last,qsappend]

# Redirect to https
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteCond %{HTTP_HOST} ^(www\.encodeproject\.org|test\.encodedcc\.org)$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [redirect=permanent,last,qsappend]

# Forbid PUT/PATCH/POST
#RewriteEngine On
#RewriteCond %{REQUEST_METHOD} ^(PUT|POST|PATCH)
#RewriteRule .* - [F]

# Forbid POST/PATCH/PUT but allow login
#<IfModule mod_rewrite.c>
# RewriteCond %{REQUEST_METHOD} ^(POST|PUT|PATCH)
# RewriteCond %{REQUEST_URI} !/login [NC]
# RewriteRule .* -[F]
#</IfModule>

###################
# Portal redirects

# Old metadata endpoint. Use https to prevent secondary 301 that clears request body.
#RewriteRule "^/metadata/(.*)/metadata\.tsv$" "https://%{SERVER_NAME}/metadata/?$1" [R=307,L,NE]

# Old batch_download endpoint.
RewriteCond %{QUERY_STRING} ^$
RewriteRule "^/batch_download/(.*)$" "/batch_download/?$1" [R,L,NE]

# Normalize index.html etc.
RewriteRule ^/ENCODE$    $0/    [nocase]
RewriteRule ^/encode/(.*)$    /ENCODE/$1
RewriteRule ^/ENCODE/FAQ$    $0/
RewriteRule ^(/ENCODE/.+)\.html$    $1
RewriteRule ^(/ENCODE(/|/.+/))index$    $1

# Redirect
RewriteRule ^/ENCODE/$    /?    [last,redirect=permanent]
RewriteRule ^/ENCODE/search$    /search/?type=experiment    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataSummary$    /search/?type=experiment    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeDataMatrixMouse$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Mus\ musculus    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeDataMatrixHuman$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Homo\ sapiens    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeChipMatrixHuman$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Homo\ sapiens&assay_term_name=ChIP-seq    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeDataSummaryHuman$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Homo\ sapiens    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeChipMatrixMouse$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Mus\ musculus&assay_term_name=ChIP-seq    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataMatrix/encodeDataSummaryMouse$    /search/?type=experiment&replicates.library.biosample.donor.organism.scientific_name=Mus\ musculus    [last,redirect=permanent]
RewriteRule ^/ENCODE/terms$    /about/data-use-policy/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/cellTypes$    /search/?type=biosample&organism.scientific_name=Homo\ sapiens    [last,redirect=permanent]
RewriteRule ^/ENCODE/cellTypesMouse$    /search/?type=biosample&organism.scientific_name=Mus\ musculus    [last,redirect=permanent]
RewriteRule ^/ENCODE/antibodies$    /search/?type=antibody_approval    [last,redirect=permanent]
RewriteRule ^/ENCODE/softwareTools$    /software/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/experiment_guidelines$    /about/experiment-guidelines/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/platform_characterization$    /data-standards/platform-characterization/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/qualityMetrics$    /data-standards/2012-quality-metrics/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/contributors$    /about/contributors/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/analysis$    /about/2012-integrative-analysis/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/pubsOther$    /publications/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/pubsEncode$    /publications/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/fileFormats$    /help/file-formats/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/contacts$    /help/contacts/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/FAQ/$    /tutorials/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/usageResources$    /tutorials/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/releaseLog$    /about/contributors/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/pilot$    /about/contributors/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/downloads$    /help/getting-started/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/downloadsMouse$    /help/getting-started/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/otherTerms$    /help/getting-started/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/integrativeAnalysis/VM$    http://encodedcc.stanford.edu/ftp/encodevm/?    [last,redirect=permanent]
RewriteRule ^/ENCODE/dataStandards$    /data-standards/?    [last,redirect=permanent]
RewriteCond %{REQUEST_METHOD}    =GET
RewriteRule ^/encyclopedia/visualize    http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&hgt.customText=http://bib.umassmed.edu/~iyers/encode_elements/display/tracks.txt    [last,redirect=permanent]

# Fallback
RewriteRule ^/ENCODE/.*$    -    [gone]

# Redirect to genome browser
RewriteRule ^/cgi-bin/hgTracks$    http://genome.ucsc.edu/cgi-bin/hgTracks    [last,redirect=permanent]
RewriteRule ^/cgi-bin/hgTables$    http://genome.ucsc.edu/cgi-bin/hgTables    [last,redirect=permanent]
RewriteRule ^/cgi-bin/hgTrackUi$    http://genome.ucsc.edu/cgi-bin/hgTrackUi    [last,redirect=permanent]
RewriteRule ^/cgi-bin/hgHubConnect$    http://genome.ucsc.edu/cgi-bin/hgHubConnect    [last,redirect=permanent]

default-ssl.conf

<IfModule mod_ssl.c>
	<VirtualHost _default_:443>
		ServerAdmin webmaster@localhost

		DocumentRoot /var/www/html

		# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
		# error, crit, alert, emerg.
		# It is also possible to configure the loglevel for particular
		# modules, e.g.
		#LogLevel info ssl:warn

		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined

		# For most configuration files from conf-available/, which are
		# enabled or disabled at a global level, it is possible to
		# include a line for only one particular virtual host. For example the
		# following line enables the CGI configuration for this host only
		# after it has been globally disabled with "a2disconf".
		#Include conf-available/serve-cgi-bin.conf

		#   SSL Engine Switch:
		#   Enable/Disable SSL for this virtual host.
		SSLEngine off

		#   A self-signed (snakeoil) certificate can be created by installing
		#   the ssl-cert package. See
		#   /usr/share/doc/apache2/README.Debian.gz for more info.
		#   If both key and certificate are stored in the same file, only the
		#   SSLCertificateFile directive is needed.
		SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
		SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

		#   Server Certificate Chain:
		#   Point SSLCertificateChainFile at a file containing the
		#   concatenation of PEM encoded CA certificates which form the
		#   certificate chain for the server certificate. Alternatively
		#   the referenced file can be the same as SSLCertificateFile
		#   when the CA certificates are directly appended to the server
		#   certificate for convinience.
		#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

		#   Certificate Authority (CA):
		#   Set the CA certificate verification path where to find CA
		#   certificates for client authentication or alternatively one
		#   huge file containing all of them (file must be PEM encoded)
		#   Note: Inside SSLCACertificatePath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCACertificatePath /etc/ssl/certs/
		#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

		#   Certificate Revocation Lists (CRL):
		#   Set the CA revocation path where to find CA CRLs for client
		#   authentication or alternatively one huge file containing all
		#   of them (file must be PEM encoded)
		#   Note: Inside SSLCARevocationPath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCARevocationPath /etc/apache2/ssl.crl/
		#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

		#   Client Authentication (Type):
		#   Client certificate verification type and depth.  Types are
		#   none, optional, require and optional_no_ca.  Depth is a
		#   number which specifies how deeply to verify the certificate
		#   issuer chain before deciding the certificate is not valid.
		#SSLVerifyClient require
		#SSLVerifyDepth  10

		#   SSL Engine Options:
		#   Set various options for the SSL engine.
		#   o FakeBasicAuth:
		#	 Translate the client X.509 into a Basic Authorisation.  This means that
		#	 the standard Auth/DBMAuth methods can be used for access control.  The
		#	 user name is the `one line' version of the client's X.509 certificate.
		#	 Note that no password is obtained from the user. Every entry in the user
		#	 file needs this password: `xxj31ZMTZzkVA'.
		#   o ExportCertData:
		#	 This exports two additional environment variables: SSL_CLIENT_CERT and
		#	 SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
		#	 server (always existing) and the client (only existing when client
		#	 authentication is used). This can be used to import the certificates
		#	 into CGI scripts.
		#   o StdEnvVars:
		#	 This exports the standard SSL/TLS related `SSL_*' environment variables.
		#	 Per default this exportation is switched off for performance reasons,
		#	 because the extraction step is an expensive operation and is usually
		#	 useless for serving static content. So one usually enables the
		#	 exportation for CGI and SSI requests only.
		#   o OptRenegotiate:
		#	 This enables optimized SSL connection renegotiation handling when SSL
		#	 directives are used in per-directory context.
		#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
		<FilesMatch "\.(cgi|shtml|phtml|php)$">
				SSLOptions +StdEnvVars
		</FilesMatch>
		<Directory /usr/lib/cgi-bin>
				SSLOptions +StdEnvVars
		</Directory>

		#   SSL Protocol Adjustments:
		#   The safe and default but still SSL/TLS standard compliant shutdown
		#   approach is that mod_ssl sends the close notify alert but doesn't wait for
		#   the close notify alert from client. When you need a different shutdown
		#   approach you can use one of the following variables:
		#   o ssl-unclean-shutdown:
		#	 This forces an unclean shutdown when the connection is closed, i.e. no
		#	 SSL close notify alert is send or allowed to received.  This violates
		#	 the SSL/TLS standard but is needed for some brain-dead browsers. Use
		#	 this when you receive I/O errors because of the standard approach where
		#	 mod_ssl sends the close notify alert.
		#   o ssl-accurate-shutdown:
		#	 This forces an accurate shutdown when the connection is closed, i.e. a
		#	 SSL close notify alert is send and mod_ssl waits for the close notify
		#	 alert of the client. This is 100% SSL/TLS standard compliant, but in
		#	 practice often causes hanging connections with brain-dead browsers. Use
		#	 this only for browsers where you know that their SSL implementation
		#	 works correctly.
		#   Notice: Most problems of broken clients are also related to the HTTP
		#   keep-alive facility, so you usually additionally want to disable
		#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
		#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
		#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
		#   "force-response-1.0" for this.
		BrowserMatch "MSIE [2-6]" \
				nokeepalive ssl-unclean-shutdown \
				downgrade-1.0 force-response-1.0
		# MSIE 7 and newer should be able to use keepalive
		BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

	</VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

000-default.conf

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

The above files are my configuration files in /etc/spache2/sites-available.

Please guide me

@GrahamDumpleton
Copy link
Owner

Since you don't appear to be using Python virtual environments, that error suggests the user encoded doesn't have access to the Python installation mod_wsgi has been compiled for.

Are you setting WSGIPythonHome anywhere else in the Apache configuration, such as where the LoadModule line is for wsgi_module. If you are and have set it to wring directory for a Python installation or virtual environment, you will also have that problem.

Using a Python virtual environment with WSGIPythonHome, which is created against a Python installation which is a different version to what mod_wsgi was compiled for, can also cause it.

@pankajingle
Copy link
Author

path : /etc/apache2/mods-available/wsgi.load
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

@GrahamDumpleton
Copy link
Owner

Then you have a permission issue.

What Python versions do you have on your system?

What Python version/installation is your mod_wsgi module compiled against?

Where is the Python version that mod_wsgi was compiled against located in the file system?

Are you using SELinux or AppArmor?

@pankajingle
Copy link
Author

pankajingle commented Jan 31, 2020

Installed python 2.7

Fatal Python error: Py_Initialize: Unable to get the locale encoding
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportErrorImportError: : No module named 'encodings'No module named 'encodings'

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
[Fri Jan 31 10:08:07.901029 2020] [core:notice] [pid 100647:tid 140631882758016] AH00051: child pid 102132 exit signal Aborted (6), possible coredump in /etc/apache2
[Fri Jan 31 10:08:07.901626 2020] [core:notice] [pid 100647:tid 140631882758016] AH00051: child pid 102133 exit signal Aborted (6), possible coredump in /etc/apache2
[Fri Jan 31 10:08:07.902083 2020] [core:notice] [pid 100647:tid 140631882758016] AH00051: child pid 102134 exit signal Aborted (6), possible coredump in /etc/apache2
[Fri Jan 31 10:08:07.902428 2020] [core:notice] [pid 100647:tid 140631882758016] AH00051: child pid 102135 exit signal Aborted (6), possible coredump in /etc/apache2
[Fri Jan 31 10:08:07.902762 2020] [core:notice] [pid 100647:tid 140631882758016] AH00051: child pid 102136 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
ImportError: No module named 'encodings'

@GrahamDumpleton
Copy link
Owner

Similar reason. When you have these problems with site or encodings module being imported, it is because mod_wsgi was compiled with different Python installation than the virtual environment, or the shared library being found, or is a permissions issue.

This is why I asked you those questions, but you didn't really answer them. Can you provide a full answer to each of the questions, otherwise can't really debug it.

BTW, why are you using such an ancient Apache and mod_wsgi version.

@pankajingle
Copy link
Author

Python Version: 2.7
mod_wsgi-4.6.5

@GrahamDumpleton
Copy link
Owner

That isn't answering the questions fully.

  • What Python versions do you have on your system?
  • What Python version/installation is your mod_wsgi module compiled against?
  • Where is the Python version that mod_wsgi was compiled against located in the file system?

You say Python 2.7, but do you only have the system Python in /usr/bin, or do you have an alternate Python 2.7 installed somewhere else?

Is the mod_wsgi the system package? The log you deleted said you had mod_wsgi/3.4, but now you are saying you have mod_wsgi 4.6.5. Something isn't right with your understanding if it logs a different version. Did you ever try and install mod_wsgi from source code but not remove the system package for mod_wsgi?

@pankajingle
Copy link
Author

I have installed python 2.7
and i installed mod_wsgi 4.6.5

/usr/lib/apache2/modules# ldd mod_wsgi.so
linux-vdso.so.1 => (0x00007ffd2d37f000)
libpython3.4m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0 (0x00007f72de16a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f72ddf4c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f72ddb83000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f72dd959000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f72dd740000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f72dd53c000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f72dd339000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f72dd033000)
/lib64/ld-linux-x86-64.so.2 (0x00007f72de9da000)

@GrahamDumpleton
Copy link
Owner

Your mod_wsgi module is compiled for Python 3.4, not Python 2.7. If you have actually removed Python 3.4, this may be why it is failing. If mod_wsgi is a system package, uninstall it. Then, or otherwise, build mod_wsgi again from fresh source code using Python 2.7, if that is the Python version you want to use.

@pankajingle
Copy link
Author

pankajingle commented Jan 31, 2020

For our application we want to use paython 3.4

I have installed mod_wsgi 4.6.5 and configure with Paython 3

Used following commands:

  1. ./configure --with-python=/usr/bin/python3
  2. make && make install
  3. Updated the path in wsgi.load file
    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
  4. apache2 -t gives following output
    [Fri Jan 31 11:28:09.095269 2020] [core:warn] [pid 29873] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
    [Fri Jan 31 11:28:09.095342 2020] [core:warn] [pid 29873] AH00111: Config variable ${APACHE_PID_FILE} is not defined
    [Fri Jan 31 11:28:09.095372 2020] [core:warn] [pid 29873] AH00111: Config variable ${APACHE_RUN_USER} is not defined
    [Fri Jan 31 11:28:09.095392 2020] [core:warn] [pid 29873] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
    [Fri Jan 31 11:28:09.095405 2020] [core:warn] [pid 29873] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
    [Fri Jan 31 11:28:09.102415 2020] [core:warn] [pid 29873:tid 139667751745408] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
    [Fri Jan 31 11:28:09.102712 2020] [core:warn] [pid 29873:tid 139667751745408] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
    [Fri Jan 31 11:28:09.102773 2020] [core:warn] [pid 29873:tid 139667751745408] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
    AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
    Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

@GrahamDumpleton
Copy link
Owner

GrahamDumpleton commented Feb 2, 2020

We get back to a question I asked before but you didn't answer.

Are you using SELinux or AppArmor?

The only thing I can suggest now is that SELinux is configured to block Apache from access stuff.

Also ensure that you have done a complete stop/start of Apache, not just a reload, because in some case a reload, rather than a restart, will not throw out an older Python shared library loaded into Apache's memory.

@pankajingle
Copy link
Author

What Python versions do you have on your system? - 2.7 and 3.4
What Python version/installation is your mod_wsgi module compiled against? - 3.4
Where is the Python version that mod_wsgi was compiled against located in the file system? 3.4

Are you using SELinux or AppArmor? - SELinux

@GrahamDumpleton
Copy link
Owner

Did you sort this out, including pursuing whether SELinux was causing the issue as suggested? I would expect it to be more basic than that though, and still somehow mixing mod_wsgi compiled for one Python version with a virtual environment or installation based on a different version. Possibly you have multiple mod_wsgi.so files and have tried to include more than one. Only the first will be used.

@GrahamDumpleton
Copy link
Owner

Closing as no further response and assumed information provided was sufficient to solve any issue or gave up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants