How to deploy basic php site on Openshift after pushing code? - php

I am trying to use Openshift for the first time to host a php site(PHP 5.4 cartridge) I am working on for a school project. I followed the directions here to push my existing repo to my gear, and can see that the code is on the gear by ssh-ing into the gear. What do I have to do now to host the website? I initially thought that I would just be able to see the index.php in my repo, but when I go to the provided url it is just a blank page. I think I may need to use the deploy action hook to cp the git repo somewhere, but not sure where. Any help would be appreciated.

With the PHP 5.4 cartridge the application root is the root of your application directory. Let me try and explain a bit further. If you create an application named "myphpapp" with the following command:
$> rhc app create myphpapp php-5.4
After the application is created, the git repository will be cloned to the directory you ran the create command. Change to that directory:
$> cd myphpapp
This is your application www root directory and is where you need to place files. For example, create a new test.php file like this:
$> echo "some php code" >> test.php
Add the file to your local git repository and then commit and push to your openshift server:
$> git add test.php
$> git commit -am "Adding a new file"
$> git push
When you run the git push command, the changes will be pushed to the remote git repository on the openshift server. Once the code is pushed, a hook on the server will see that a new file has been added to the repo and then deploy it to the www root on the openshift server. Once the deploy has finished, you can access the file by pointing to:
http://yourApp-yourDomain.rhcloud.com/test.php
Hope that helps.
--
gs

I did not read the documentation clearly enough. The root for the app is yourApp/php. So your repository has to have a php subdirectory inside of it, and that will be the app root. There is no need to copy your code from the repository to the root. As you have the correct structure, when you push your code the website will be live.

Related

How to configure Laravel application on localhost?

I'm new to Laravel framework. I have installed and developed a small application. I've got source code from Github for an application which I want to integrate and run on my localhost. Please guide me any link or material where I get proper instructions to start working on this website. Give me details about which file to be edited so that atleast I can access on my localhost.
Github link : https://github.com/fakharkhan/laravel-school-erp
If you don't want to use homestead (which is somewhat complex for beginners to setup) follow this:
steps to setup laravel app from github repo
first of all you need to install git and composer.
open command prompt (terminal) in your document root folder.
clone the repository by executing git clone https://github.com/fakharkhan/laravel-school-erp.git
change directory in terminal to newly cloned project by using cd laravel-school-erp in your case.
run composer install to install project dependencies.
rename .env.example to .env file.
open .env file and enter the database connection information.
run laravel migrations (import database) by executing php artisan migrate from terminal.
visit the url by adding /public to it.
Optional
Setup virtual host by editing httpd-vhosts.conf file (so you can avoid typing /public in the url) and adding following to it
<VirtualHost example.dev:80>
DocumentRoot "C:/xampp/htdocs/laravel/public"
ServerName example.dev
</VirtualHost>
then edit your host file and add following to it:
127.0.0.1 example.dev
You can replace example.dev with whatever URL you like.
You can use Laravel Homestead
https://laravel.com/docs/5.4/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.
You should give a look on Laravel's documentation.
This the best way to understand Laravel.
If you just get the source code you'll need to do some things :
Copy .env.example and rename it .env
Edit .env file to fit on your needs like database informations
Run composer install to install dependencies
Run php artisan key:generate
Assuming you are using xampp on Windows as localhost. Now go to path/to/xampp/htdocs then open git terminal by right click on Git Bash Here
Now run following commands:
1. git clone https://github.com/fakharkhan/laravel-school-erp
2. cd laravel-school-erp
3. composer install
4. cp .env.example .env
5. php artisan key:generate
For database connection: make a database and set (DB_DATABASE, DB_USERNAME, DB_PASSWORD) values to .env file (which is in your project root).
And finally browse: localhost/laravel-school-erp/public

Git upload project full site

I am new for using Github. I want upload my full site in new Repository in Github.com. But Github just can upload not more than 100file, and I'm download codeigniter-3 it's have 253file (original without my new file).
Can I upload my project in to Github?
This is likely a limitation of the drag and drop interface. I'd suggest to get familiar with the command line client instead. It's much more convenient than using the web interface and you'll need it anyway if you want to do serious work on that project from your dev machine.
First clone your project to a local directory:
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
Then from your project directory, add all the files:
$ git add .
$ git commit -m "initial commit"
$ git push origin master
Alternatively, consider using https://desktop.github.com/
Reference:
https://help.github.com/articles/cloning-a-repository/
https://help.github.com/articles/adding-a-file-to-a-repository-from-the-command-line/
GitHub upload file step by step follow.
Now first create account on github.
https://github.com/login
create repository in your GitHub account.
setup git directory on your project directory by GIT Clone.
after git clone setup .GIT directory on your project with config.
Example: ##Config git repository##
git clone https://github.com/username/repository
##upload project on GIT##
git add /your-folder
git commit -m 'your first commit'
git push -u origin master
after push successfully upload your project.

How to deal with GIT for an existing website?

I lost my notepad with details how to deal with a GIT.
On my webserver I have the following things:
- htdocs/git/project/.git
and the project is under:
- htdocs/project/
The local copy is under:
- Applications/MAMP/htdocs/project
How can I create a GIT to push all local changes to the project on the server?
On your local machine (presuming Git is installed) simply navigate to the folder in Git Bash and initialise a repo:
git init
Then set the remote to be the same as on your webserver. First find where this is by logging onto your webserver at the path where the .git folder lives and type:
git remote -v
This produces a git#yougithost.com:namespace/scheme.git type link. Capture that and then back on your local machine go to the folder again and type:
git remote add origin git#yougithost.com:namespace/scheme.git
Now both folders can talk to the same project (again this presumes that you have the ability to authenticate yourself against the remote repo).
From here you simply complete your vchanges locally, commit them and push to origin:
git commit -am "Updated files"
git push -u origin master
Then on your remote box simply...:
git pull origin master
Whammo, you'll have a copy.
Hope that helps get you started..

Yii2 App not displaying on Heroku domain

I installed a Yii2 "basic" app on a Cloud9 workspace using composer. It runs fine as you can see here https://portfolio-php--dfmmalaw.c9.io/basic/web/index.php
Problem is I am getting below error when trying to view after deploying to Heroku URL.
"Forbidden You don't have permission to access / on this server."
The below screenshot is my Cloud9 workspace
http://prntscr.com/8rrkn0
I even tried adding basic/web/index.php to the Heroku URL but I just get a blank page. What am I doing wrong?
After getting help from Herokai, David Zuelke, I decided to create a how-to on the subject of "Creating Yii2 App in Cloud9 → Pushing to Github → Deploying to Heroku". Please see below (google doc link at top if easier to read):
https://docs.google.com/document/d/15teHaGWUWSNW_VwdV3-7bVpQHNRv2G0Z8GPFbIB-ogs/edit
1) Create Yii2 “basic” app:
290795 $ composer create-project --prefer-dist yiisoft/yii2-app-basic basic
2) Move into “basic” directory
290795 $ cd basic/
3) Initialize local repo for “basic” directory
basic $ git init
4) Add and commit Yii project
basic $ git add .
basic $ git commit -m "basic Yii project"
5) Add procfile that will point to index.php (entry script) in “web” directory
basic $ echo "web: vendor/bin/heroku-php-apache2 web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "Procfile for Heroku"
6) Comment out debugging stuff (I do this manually instead of from command line)
basic $ vim web/index.php # remove dev/debug env stuff (not my way)
basic $ git add web/index.php
basic $ git commit -m "remove dev/debug env"
7) This updates the dependency from v1.0.3 to v1.1 (absolute necessity)
basic $ composer require fxp/composer-asset-plugin
basic $ git add composer.json composer.lock
basic $ git commit -m "use fxp/composer-asset-plugin in project"
8) Create Heroku app and push to it. (I instead create and push to Github repo)
basic $ heroku create
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
9) Add logging to Heroku for Yii app (no logging for Yii out of the box)
basic $ echo "web: vendor/bin/heroku-php-apache2 -l runtime/logs/app.log web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "tail runtime/logs/app.log"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
10) This allows the “Contact” page to work (not sure why)
basic $ composer require ext-gd:* --ignore-platform-reqs
basic $ git add composer.json composer.lock
basic $ git commit -m "require GD for contact CAPTCHA"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
The easiest way is to check your apache logs. I do not have experience with Heroku but I am sure they do offer access to them. Just take a look in there and you will see what the problem is. A white page usually means that is was a catastrophic error.
Another thing to look at is if you have used short php tags. You should not and that usually is a setting more relaxed on your computer but more strict on hosting servers. But again look at the logs, they will tell you this too.
This is for the advanced template so not for you:
I guess you did not run 'php init' like the documentation tells you. The init command is not just for the first time you get the application, but for every time you set it up on a new server too. it creates index.php and other config files that you will need for sure. Just follow again the yii2 install instructions
http://www.yiiframework.com/doc-2.0/guide-start-installation.html

Directory Permission Problems When I Deploy PHP Script on Openshift

I am deploy a cf image host 1.6.5 on Openshift using Git. Some of the directories do not have write permission when I running installer script.
The cf image host 1.6.1 installer script will generate a setting file in a directory called "inc".
I have done git push for the zip file of cf image host 1.6.5(says cf_image_1.6.5.zip) onto Openshift using git,and unziped this file to app-root/repo/php directory. The installer script can run okay. If I unzip file at local machine, git add and git commit and git push,the setting file can not be generated in the directory inc. If I manually change permission to 777, it is okay.
But I check the file using ls -la, both two methods' the owner is myself.
How do I deploy the process work when git push? Which user of the remote machine is deploying these scripts?
Try something along this (adjust permissions)
git update-index --chmod=+w -- $(git ls-files folder/with/wrong/permissions/*)
and add, commit and push.
Deploy should happen under your default openshift user. (See uder Webinterface->App: Userpart of the ssh-git url displayed there.

Categories