Google official documentation is available here:
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP
But it doesn't provide sufficient information about the following step:
"4 - Build and install the PHP interpreter and App Engine PHP extension. Specify the path to php-cgi and gae_runtime_module.so when running the development server."
I'm using a new Virtualbox machine with Ubuntu 15.10 and PhpStorm to test GAE.
Could someone please provide clear instructions about step 4? What do I need to do to install the php interpreter and the App Engine php extension?
P.s. I've already searched with google but I only found old/confusing tutorials
That GAE PHP extension seems like a quite new thing. Don't remember using it on the SDK in Ubuntu 14.04.
You need to build PHP and that extension from source. You should grab the latest PHP5.5 branch from their source repo (http://php.net/git.php) and build it. That linked page contains instructions on building PHP but the procedure is similar to the following:
$ git clone <php-src>
$ cd ./php-src/
$ git checkout PHP-5.5
$ ./buildconf
$ ./configure --prefix="/opt/php55"
$ sudo make && sudo make install
And remember to pick the modules and packages you want to compile with PHP5.5 to be used in the SDK. I think Google had an official list of modules and extensions they use inside GAE PHP and inside the SDK PHP. The prefix argument tells the compiler where to install the resulting application.
Then you need to get that source for the PHP extension and build it
$ git clone https://github.com/GoogleCloudPlatform/appengine-php-extension
$ cd appengine-php-extension
$ phpize # remember to use the phpize from the just built PHP5.5 binaries
$ ./configure
$ sudo make && sudo make install
(That Git repository contains detailed building instructions so you should probably refer to them when building.)
Enable the resulting .so for the PHP5.5 you just built using the PHP configuration files.
After that you need to install the PHP SDK and configure it to use the newly built PHP binary
$ dev_appserver.py <...> --php_executable_path=/opt/php55/bin/php-cgi
The SDK will let you know if the built PHP binaries are incompatible with the SDK version you use. I remember compiling the PHP from source around 5 times before it worked without any warnings.
But essentially they are telling you to compile PHP from source, then compile their extension from source and then use the built PHP+extension with the downloaded SDK. These instructions are from the top of my head so you may need to adjust the commands and procedures.
The process can be simplified by using Docker, here is an image you can use: https://hub.docker.com/r/mhariri/docker-google-appengine-php/
To run your app, you just need docker installed, and then run the following command in your app directory:
docker run -it -v $(pwd):/app --rm --net=host mhariri/docker-google-appengine-php
Related
I cloned https://github.com/couchbase/libcouchbase and checkout to version 2.5.8. After that I compiled it as in the documentation from the git page
$ git clone git://github.com/couchbase/libcouchbase.git
$ cd libcouchbase && mkdir build && cd build
$ ../cmake/configure
$ make
$ sudo make install
Afterwords, I installed couchbase from pip:
sudo pip3 install couchbase
But when I do:
python3 -c 'import couchbase'
I've got
import couchbase._libcouchbase as C
ImportError: libcouchbase.so.2: cannot open shared object file: No such file or directory
I made a link in /usr/lib/libcouchbase.so.2 to /usr/local/lib/libcouchbase.so.2
sudo ln -s /usr/local/lib/libcouchbase.so.2 /usr/lib/libcouchbase.so.2
but now I get
import couchbase._libcouchbase as C
ImportError: /usr/local/lib/python3.4/dist-packages/couchbase/_libcouchbase.cpython-34m.so: undefined symbol: lcb_n1x_list
Linux version:
cat /etc/issue
Ubuntu 14.04.2 LTS \n \l
Any idea?
You're encountering this error because your version of libcouchbase is not recent enough to correspond to your version of the Couchbase Python SDK. The current version of the Couchbase Python SDK (2.0.9) requires libcouchbase>=2.6.0.
You have two options to handle this:
Use an older version of the Couchbase Python SDK
Update to the newer version of libcouchbase
Using an older version of the Python SDK is easily done with pip:
$ sudo pip3 install couchbase==2.0.8
Installing a newer version of libcouchbase would be similar to the procedure you've already taken, except you would of course need to checkout version 2.6.0.
That being said, it is generally recommended to use the official builds distributed on the Couchbase website. You can either download tars from the libcouchbase downloads page or add the official Couchbase repositories and apt-get install libcouchbase.
I would like to customise a (Python) Standard Runtime Managed VM.
In theory, this should be possible by adding some extra commands to the VM Dockerfile.
Google's documentation states that a VM Dockerfile is automatically generated when the App is first deployed;
If you are using a standard runtime, the SDK will create a Dockerfile for you the first time you run the gcloud preview app deploy commands. The file will exist in a predetermined location:
If you are developing in Java, the Dockerfile appears in the root of the compiled Web Application Archive directory (WAR)
If you are developing in Python or Go, the Dockerfile appears in the root of your application directory.
And that extra commands can indeed be added;
You can add more docker commands to this file, while continuing to run and deploy your app with the standard runtime declaration.
However in practice the Dockerfile is automatically deleted immediately after deployment competes, preventing any customisation.
Has anyone managed to add Dockerfile commands to a Managed VM with a Standard Runtime? Any help would be gratefully appreciated.
I tried the same thing and did not succeed. There is however an equivalent way of doing this that I fell back to.
You can create a custom runtime that mimics the standard runtime.
You can do this because Google provides the Docker base images for all the standard runtimes. Mimicking a standard runtime is therefore simply a matter of selecting the right base image in the Dockerfile of the custom runtime. For the standard Python App Engine VM the Dockerfile is:
FROM gcr.io/google_appengine/python-compat
ADD . /app
Now that you have recreated the standard runtime as a custom runtime, you can modify the Dockerfile to make any customizations you need.
Important Note
The development server does not support custom Dockerfiles (you will get an error about --custom-entrypoint), so you have to move your test environment to App Engine servers if you are doing this. I think this is true regardless of whether you are using a standard runtime and customizing the Dockerfile or using a custom runtime. See this answer.
A note about the development server not working with custom runtimes - dev_appserver.py doesn't deal with Docker or Dockerfiles, which is why it complains about needing you to specify --custom_entrypoint. However as a workaround you can manually set up the dependencies locally. Here's an example using 'appengine-vm-fortunespeak' which uses a custom runtime based on python-compat:
$ git clone https://github.com/GoogleCloudPlatform/appengine-vm-fortunespeak-python.git
$ cd appengine-vm-fortunespeak-python
# Local dependencies from Dockerfile must be installed manually
$ sudo pip install -r requirements.txt
$ sudo apt-get update && install -y fortunes libespeak-dev
# We also need gunicorn since its used by python-compat to serve the app
$ sudo apt-get install gunicorn
# This is straight from dev_appserver.py --help
$ dev_appserver.py app.yaml --custom_entrypoint="gunicorn -b localhost:{port} main:app"
Note that if you are using any of the non -compat images, you can run your app directly using Docker since they don't need to emulate the legacy App Engine API, for example using 'getting-started-python' which uses the python runtime:
$ git clone https://github.com/GoogleCloudPlatform/getting-started-python.git
$ cd 6-pubsub
# (Configure the app according to the tutorial ...)
$ docker build .
$ docker images # (note the IMAGE_ID)
$ docker run -p 127.0.0.1:8080:8080 -t IMAGE_ID
Try the above with any -compat images and you will have problems - for example on python-compat you'll see initialization errors in runtime/google/appengine/tools/vmboot.py. It needs to be run on a real Managed VM instance.
I depolyed an app with gcloud preview app deploy.
Is there a way to download it to an other local machine?
How can I get the files? I tried it via ssh with no success (can't access the docker dir)
UPDATE:
I found this:
gcloud preview app modules download default --version 1 --output-dir=my_dir
but it's not loading files
Log
Downloading module [default] to [my_dir/default]
Fetching file list from server...
|- Downloading [0] files... -|
I am coming to Google App Engine after two years, I see that they have made lots of improvements and added tons of features. But sadly, their documentation sometimes leaves much to be desired.
I used to download my code of the uploaded version with the appcfg.pyusing the following command.
appcfg.py download_app -A <app_id> -V <version> <output-dir>
But of course now that they have culminated everything in the gcloud shell where appcfg.py is not accessible.
However, the following method helped me to download the deployed code:
Go the console and in to the Google App Engine.
Select the project you want to work with.
Once the project's dashboard opens, Click on the top right to
open the built in console window.
Which should load the cloud shell at the bottom, now if you check appcfg.py is available to you to use in this VM.
Hence, use appcfg.py download_app -A <app_id> -V <version> <output-dir> to download the code.
Now once you have the code in the desired folder, in order to download it on your local machine - You can open the docker code editor
Now here I assumed if I rightclicked and exported the desired
folder it would work,
but instead it gave me the following error message.
{"Error":"'concurrency' must be a number but it is [object Undefined]","Message":"'concurrency' must be a number but it is [object Undefined]"}
So, I thought maybe it would play along nicely if the the folder
was an archive. Go back to the cloud shell and using whatever
utility you fancy make an archive of the folder
zip -r mycode.zip mycode
Go to the docker code editor, export and download.
Now. Of course there might many more ways do it (hopefully) but this is what made sense to me after returning to Google App Engine after 2 years.
Currently, the best way to do this is to pull the files out of Docker.
Put instance into self-managed mode, so that you can ssh into it:
$ gcloud preview app modules set-managed-by default --version 1 --self
Find the name of the instance:
$ gcloud compute instances list | grep gae-default-1
Copy it out of the Docker container, change the permissions, and copy it back to your local machine:
$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 'sudo docker cp gaeapp:/app /tmp'
$ gcloud compute ssh --zone=us-central1-f gae-default-1-1234 "chown -R $USER /tmp/app"
$ gcloud compute copy-files --zone=us-central1-f gae-default-1-1234:/tmp/app /tmp/
$ ls /tmp/app
Dockerfile
[...]
IMHO, the best option today (Aug 2018) is:
Under the main menu, under Products, go to Tools -> Cloud Build -> Build history.
There, click the ID of the build you want.
Then, in the opened window (Build details), click the source link, the download of your compressed code begins.
As simple as that.
HTH.
As of Feb 2021, you can install appengine-sdk using pip
pip install appengine-sdk
Once installed, appcfg can be used to download the app code.
python -m appcfg download_app -A app_id [ -V version ] out-dir
Nothing works. Finally I found the source code this way. Simply go to google cloud storage. choose buckets starting with us.artifacts...., select containers > images > download the latest one (look by created date). unzip after downloaded file. it will have all the deployed source code of app engine.
My project use Django, and I need run the Django's ORM in Compute Engine, for this I want sync in one repository both Compute Engine and App Engine with my development server.
When I try:
gcloud init <proyect>
From the Compute Engine, the log is:
ERROR: Unable to initialize project [tcontur2], cleaning up [***].
ERROR: (gcloud.init) Your git version 1.7.10 is older than the minimum version 1.8.1.
Please install a newer version of git.
I try
apt-get update
apt-get upgrade
And nothing.
I too try:
git clone https://source.developers.google.com/myproyect
But the authenication fails. What is the username and password? It is not my gmail user account.
Is possible sync the Compute Engine with the code in App Engine? or only is possible with another repository? This option suppose other payment to Github, I dont want spend more.
I reproduced your issue from my fresh Debian instance and I was able to solve it. I downloaded the new git version from: http://code.google.com/p/git-core/downloads/detail?name=git-1.9.0.tar.gz
Also I needed to install some packages that you may have already installed but just in case I'll let you know which are them.
These are the steps I've taken:
sudo apt-get install libssl-dev libcurl4-openssl-dev libexpat-dev gettext
wget http://git-core.googlecode.com/files/git-1.9.0.tar.gz
tar -xvzf git-1.9.0.tar.gz
cd git-1.9.0
sudo make prefix=/usr all
sudo make prefix=/usr install
After that you can check your git version with:
git --version
Now, if the output of the last command displays "git version 1.9.0", you should be able to create the repository with the command:
gclod init <project>
So I'm trying to use uwsgi behind apache2, but I am doing so on a CentOS 6 machine. (I'm use to Debian/Ubuntu based systems for context.)
I used pip install uwsgi and followed the directions for launching uwsgi with a Django application (via http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html).
I started to configure apache2 as per http://uwsgi-docs.readthedocs.org/en/latest/Apache.html, but it says nothing about where to get or how to build mod_uwsgi or mod_proxy_uwsgi. mod_uwsgi.so definitely isn't on the system anywhere. Any suggestions?
It's right at the top of the module's source:
To build:
apxs2 -i -c mod_proxy_uwsgi.c
Apxs2 is apache-2.2 specific, and it may be called apxs on some Unixes. For instance, on CentOS 6:
$ rpm -q -f `which apxs`
httpd-devel-2.2.15-28.el6.centos.x86_64