ArcGIS cannot run on Apache 2.4 + CGI

1361
12
11-14-2017 03:28 AM
NghiepNeoLab
New Contributor

Hi everybody,

I try to use Arcpy on Apache 2.4 and CGI that is basic example. But I can't, It always display error message like "Not signed into Portal".

Although I signed in
I signed in

And then, I check about Licensing
Authorize ArcGIS Pro to work offline

So, ArcGIS configuration is ok.

Now I show you see what Apache configuration

- httpd.conf, I have enabled LoadModule cgi_module modules/mod_cgi.so

- ViltualHost, 

Apache Virtualhost configuration

=> I checked, VirtualHost works well without use Arcpy.

Apache Service is running
Apache 2.4 is running

Python example script

Python script withou arcpy

The result

It works well without arcpy

But When I import Arcpy in my Python script, It has the problem.

The bellowing is apache-cgi-example.py content

#!C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe
# coding: utf-8
print("Content-type: text/html\n\n")
print("")
print("<h2>ArcGIS runs on Apache 2.4 + CGI</h2>")

import sys, os
import bottle

import cgitb
cgitb.enable()

realpath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(realpath)

print("<p><b>Project path</b>: {}</p>".format(str(realpath)))

app = bottle.default_app()
app.config.load_config("%s\\app.conf" % realpath)

try:
    print("<p><b>Output path</b>: {}</p>".format(str(app.config['app.output_path'])))

    import arcpy

    # Arcpy can overwrite output
    arcpy.env.overwriteOutput = True

    # set workspace dir
    arcpy.env.workspace = app.config['app.output_path']

    # initiation for volume calculation
    arcpy.CheckOutExtension("3D")
    arcpy.CheckOutExtension("spatial")

except Exception as error:
    print("<p><b>Cannot import Arcpy. Error</b>: {}</p>".format(str(error)))

The problem is "Not signed into Portal"

The page content is 

The problem

Can your please help me?

Thank many help!

Note:

- It has the same problem on IIS environment

- I am using ArcGIS Pro version 1.3 (Python version 3.4.4) 64bit

- I am using Apache 2.4.23  64bit

0 Kudos
12 Replies
NghiepNeoLab
New Contributor

 , 2 videos are evidence explain more about what happened. Almost I write to explain on each step. We should not care sound. anyways forget 2 videos. Actually 1st video can help you understand what the problem here.

Yeah, I am sorry about my English, It is very bad. so sorry

I will explain again.

For example: index.py has content below

#!C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe
# coding: utf-8
print("Content-type: text/html\n\n")
print("")
import arcpy

If I run index.py in Windows command prompt, It is ok. No message like "Not signed into Portal"

If I run index.py in Apache service, It doesn't work and display "Not signed into Portal" message.

So you asked me, Did you have evidence that it works elsewhere?

The video below is evidence and it will explain more what the problem I have.

Do you know my mean?

0 Kudos
DanPatterson_Retired
MVP Emeritus

I can't help since I see nothing obvious... As suggested, pass this on to Tech Support since no one else has chimed into the discussion, including several ESRI staff members

0 Kudos
NghiepNeoLab
New Contributor

ok, Thank a lot Dan_Patterson

0 Kudos