how to deploy a custom skeleton application in Bluemix php - php

In Bluemix if I create an application starting from php template then the DocumentRoot is set to:
/htdocs.
I actually would like to have a dir structure like this:
/htdocs
/public_html
index.php
/myCode
myPhpClass.php
with httpd.conf DocumentRoot="${HOME}/htdocs/public_html".
So I tried to push this community buildpack https://github.com/cloudfoundry/php-buildpack.git from my local myAppName dir:
/var
/www
/myAppName
/public_html
index.php
/myCode
myOhoClass.php
/.bp-config
options.json
using cf:
[... myAppName]# cf push -s cflinuxfs2 -m 128M -b https://github.com/cloudfoundry/php-buildpack.git myAppName
where options.json file:
{
"WEBDIR": "htdocs/public_html"
}
but what I ended to get in Bluemix is:
/htdocs
/public_html
/public_html
index.php
/myCode
myPhpClass.php
Is there a way to have a custom directory structure for an apache httpd/php application in Bluemix?

Your .bp-config/options.json file is a little wrong. It should be the following.
{
"WEBDIR": "public_html"
}
I just tried things myself with a PHP app and it worked fine.
cf push php-test-jbs -b https://github.com/cloudfoundry/php-buildpack.git -s cflinuxfs2
Additionally to deploy the sample click the following.
or goto the Github project to check out a full sample.

Related

Unable to get the environment variable using PHP hosted in amazon linux

I set up the environment path in amazon linux vi /etc/environment as ENV_TYPE=DEV. Environment variable are set up in localhost but it not get the environment in web host.
In apache path /var/www/html I create a index.php with below code:
<?php
echo "env ".getenv('ENV_TYPE');
exit;
?>
I already tried the below commands for setup,
vi etc/environment --> ENV_TYPE=DEV
OUTPUT from my host is " **env **" only but expected Output is "env DEV"
the issue is env only execute in this code , ENV_TYPE not fetched from environment variable!!!
output image
i expected output image is
set the Local environment in the path file /etc/environmet
export ENV_TYPE=DEV
then, save and Create a .htaccess file in the apache path /var/www/html and add the line in .htaccess file.
SetEnv ENV_TYPE "DEV"
Allow the .ht file permission in apache conf (httpd.conf) file
Finally, it's automatically taken the Environment Variable as Dev

Deploying Symfony 4 to Heroku

I have set up a new symfony 4 project that I am trying to deploy on heroku. I have the app set up and running successfully locally. I bascially followed the instructions from the heroku tutorial here. However, this tutorial is only written for symfony versions 2 and 3.
I had set up a symfony 3 app in the past successfully, I had to create a Procfile to direct the heroku server to the web/ directory, as per the instructions in the "Best Practices" section. In this S4 installation I don't see a web/ folder, so I didn't create a Procfile. Heroku uses a default command in this case.
I have created 2 config vars in heroku config: APP_ENV, SYMPHONY_ENV both are set to prod. I deploy the app the heroku, it all deployed successfully, but when I try to access the page, I just get a 403 Forbidden. In the logs I get this, which is maybe the correct functionality since I didn't write any code yet:
[autoindex:error] [pid 116:tid 139699079337728] [client
10.5.228.216:17171] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and
server-generated directory index forbidden by Options directive
I don't see an app folder, but I do see a folder called public with an index file inside.
Does anyone have experience deploying the new version of Symfony 4 to Heroku, if so any tips would be greatly appreciated. Thanks!
On Symfony 4 the web folder was replaced by public. You still need to create the Procfile file and add this line:
web: vendor/bin/heroku-php-apache2 public/
In my case I defined a Procfile with the following content :
web: $(composer config bin-dir)/heroku-php-apache2 public/
But it was not enough, I had to install apache-pack with composer :
composer require apache-pack (using symfony flex) or composer require symfony/apache-pack
(I found the solution on the heroku-buildpack-php repository)
The best solution is to create a Procfile in the root of your repository,
with the following content:
web: $(composer config bin-dir)/heroku-php-apache2 public/

YII 2 application on VirtualHost in fedora 26 OS - The directory is not writable by the Web process

I develop a small system using YII2 PHP framework on my local host.
folder path "/var/www/html/MY_SITE"
with "yii php serve" command it work fine for this url - localhost:8080
Then I configured a virtual host with documentRoot "/var/www/html/MY_SITE/web" and host name like "www.my.site.lk"
and configure my host file.
restart httpd service.
then go to url www.my.site.lk.
but site not working.
YII application error.
Invalid Configuration – yii\base\InvalidConfigException
The directory is not writable by the Web process: /var/www/html/RLF_CMS/web/assets
in /var/www/html/RLF_CMS/vendor/yiisoft/yii2/web/AssetManager.php
but still woke this url (localhost:8080).
Please help me...
Give write permision chmod -R 777 to folder runtime and web/assets

How to host multiple Laravel sites/applications in a web root

I have 2 Laravel 4 applications.
I want one of them to be served from within a folder that is inside the other's root folder.
For example, let's say Application A is deployed to /var/www/ folder, and I want Application B to be deployed to /var/www/B/.
When just naively putting it there, I get an error NotFoundHttpException from Application A's RouteCollection.php.
Any idea how this can be achieved?
Thanks in advance!
I supose you're using apache2. There is a file in /etc his name is hosts, you can configure a virtual domain to access diferent directories like:
127.0.0.1 project1.com
127.0.0.1 project2.com
The you have to configure the virtualhost. You have to go to /etc/apache2/sites-avaible and copy the default config file 000-default.conf
cd /etc/apache2/sites-available
sudo cp 000-default.conf 001-laravel1.conf
sudo nano 001-laravel1.conf
Inside of the edit of the document you only have to change two things:
ServerName (you have to put your virtual domain) -> project1.com
DocumentRoot (you have to put your directory of your proyect) -> /var/www/A
And the last thing is create a symbolic link to this archive in the directory /etc/apache2/sites-enabled
cd /etc/apache2/sites-enabled
ln -s 001-laravel1.conf ../sites-available/001-laravel1.conf

How to run Laravel without Artisan?

I have PHP with Apache2 and I want to run Laravel Framework without Artisan but I can't! Does anyone know how to run Laravel without Artisan?
I've solved the problem. The problem was in my htaccess and in mod_rewrite (Apache2). Now I can connect to my application only by typing localhost/public..
If anyone wants to make the application public, the more easy and fastest way is:
Rename the "server.php" file in root directory, in "index.php"
Move your .htaccess from public folder to root directory
Make your directory accessible to Apache2 (set correct file/folder permissions).
Thanks to all users for help! :)
Important Edit
Consider using Apache Virtual Hosts (pointing the virtual host to the /public Laravel folder) instead of renaming server.php to index.php because by doing this you will need to prefix "public/" when you use the Laravel's asset() function in your views.
When working with other devs, who are using a different configuration, this might be a big problem because they will be able to see the assets while you will not (or viceversa).
I am using xampp in mac
inside htdocs / run following command:
$ laravel new myblog
After successfully creation run following and do following:
sudo chmod -R o+w storage/
Change server.php to index.php (# root directory)
copy .htaccess from public to root directory
(optional) in resources / app.blade.php → Change to
<link href="{{ asset('public/css/app.css') }}" rel="stylesheet">
run following
http://localhost/myblog/
Easy solution without any code alterations
Point your domain to public/ folder of laravel project.
Enjoy!
~OR~
Create .htaccess in project folder and add below code. This code will rewrite domain to public/ folder of your laravel project
RewriteEngine on
RewriteRule ^(.*)?$ ./public/$1
Hope this is helpful.
Laravel framework is such a pain in the ass for startup PHP guys who are not much oriented about what the hell composer is, and where .phar files are coming from and what are they, and why "Artisan" is trying to ruin your PHP life.
Most people are looking for a PHP framework where all you have to do is download, extract and code.
Nevertheless to make things work, you just need to install Laravel through Composer:
composer global require "laravel/installer=~1.1"
Anyway, you can download Composer from http://getcomposer.org/
After you install Laravel through Composer, navigate to your local server's directory. You might want to use "CD" (Change directory) to do this. (I'm speaking of CLI, whether you're in BASH(Linux) or CMD(Windows))
Then create your very first Laravel project by typing this in command line:
laravel new mywebsite1
Replace "mywebsite1" with your first project name.
And there you go, you're ready to hit the Laravel road.
In my case, I'm still using Windows XP in such development and shifts back to Ubuntu Trusty whenever I feel like I want to smell Linux scent.
So Composer installs "Laravel installer" in:
%userprofile%\Application Data\Composer\vendor\bin
So I make a backup copy of this directory so the next time I use Laravel on other unit with no internet connection, I just have to extract it, and run:
laravel new [myprojectname]
within the same directory and copies the resulting folder to my XAMPP's htdocs or WAMP's www folder.
Anyway I'm just sharing my approach for those with no 24/7 internet connection at home :p
After all it's still best for everyone to read the documentation on how to properly install Laravel: http://laravel.com/docs/5.0/installation
For Windows Users Its very easy to change and run laravel projects on your normal project urls :
1. "server.php" to "index.php" .
2. copy ".htaccess" from public to root directory.
there you go with your normal URL .
localhost/project_name
Artisan is simply a command line interface. It is made to do things like create and run migrations and automate building certain objects within your Application, etc. Essentially, it's only made to help facilitate creating and working on your Application, not run it.
If you are having issues actually getting the Application to run, it is likely a problem with either your PHP or Apache, not Artisan.
Just Follow 3 Step ;
Change File Name : change serve.php to index.php inside your Project name folder.
Move .htaccess file Bring ".htaccess" file to main root [inside your Project name folder ].
Restart your local server. Your are just 1 click away . Restart all services of xampp or wamp
Enjoy
For an aternative maybe you can run it under a virtual host. All you need is just create a new virtual host with your project/public directory as a DocumentRoot.
In my case, I am using XAMPP under Mac OS. These are the steps on how to achieve that:
Enable virtual host config
Ensure virtual host config was enabled, else you can enable it through this file: /Applications/XAMPP/xamppfiles/etc/httpd.conf
$ sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
Remove the hash "#" of this following line
# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Add a new virtual host
$ sudo nano /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
The add a new virtual host (e.g: newproject.dev)
# Virtual host of newproject.dev
<VirtualHost *:80>
ServerName newproject.dev
DocumentRoot "/Users/your-username/newproject/public"
<Directory "/Users/your-username/newproject/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Note: /Users/your-username/newproject/public is the location of your project.
Update your hosts
$ sudo nano /etc/hosts
Add this following setting:
# Host of newproject.dev
127.0.0.1 newproject.dev
Restart your Apache, go to your browser and your project should be available on http://newproject.dev
I got mine to work by adding the following block to my apache vhost conf file
<VirtualHost *:8003>
ServerName myproject
DocumentRoot "/path/to/myproject/public"
</VirtualHost>
and running sudo chown -R daemon storage from my project root
Well , the easy way is
1) create a new folder"Project" and copy all files except public folder content to project folder
2) copy all files of public folder to root
and you can run laravel without artisan.If you rename server.php and copy .htaccess , it may make trigger some error when you try to run auth artisan command.I experienced problem with auth command.
Laravel with Vue.JS
If you are using vue.js with Laravel and your app is not working without php artisan serve, you need to create a virtual host. This is a simple two-step process for windows.
Step 1: Update you hosts file at C:\Windows\System32\drivers\etc with,
127.0.0.1 dev.example #You can rename according to your app
Step 2: Update you vhosts file with,
I am using Apache which is installed in D:\ so my path for vhosts file is at
D:\xampp\apache\conf\extra
<VirtualHost *>
DocumentRoot "D:\xampp\htdocs\example\public" ##Your path
ServerName dev.example ##Your URL according to what you set in hosts file in step 1
<Directory "D:\xampp\htdocs\example\public"> ##Your path
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That's it, now you can just visit your app at http://dev.example/
Install and setup Laravel on your local (meaning your local machine).
Once done, copy all files to your hosting.
Create a .htaccess file on your Laravel's root directory. This is to access it without the "public" on the URL.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Categories