Despite all my attemps, I am unable to deploy my symfony2 application with capifony in dev environment.
I have tried the following in my .rb file:
set :clear_controllers, false
This allows me to not delete the app_dev.php and yes, that way I can access the dev environment but only by manually putting this file in the address bar
These other parameters have no effect on wether the app_dev.php is used by default :
set :composer_options, "--dev --verbose --prefer-dist --optimize-autoloader --no-progress"
set :symfony_env, "dev"
And in my apache2 conf file, I have put this
DirectoryIndex app_dev.php
What other hidden parameter to I need to use in order for the page to automatically display the dev environment when accessing the root directory ?
Related
I have setup Mapbender on Ubuntu 20.04 on a VirutalBox machine. PostgreSQL, PostGIS and Geoserver are all installed on the VM. I created a map application and added a search router function (followed the instructions in the documentation). The search is working like a charm in the dev environment but in the prod, it is not. In the dev environment, it is giving a result and hovering the mouse over the result highlights the feature and clicking on the result moves and zooms the map to the feature.
In the prod environment, nothing seems to happen when typing the search string and pressing search. The devtools report an internal server error 500, which is not very helpful. Although, in Firefox, the devtools show Referrer policy "strict-origin-when-cross-origin" in red.
I have already modified the Postgres configuration files to Listeners = * and host 0.0.0.0 to make sure it is not a database access problem.
Host Machine: Windows 10 Pro 20H2
Guest Machine: Ubuntu 20.04
Mapbender 3.2.6
Database Postgresql 12.8 with Postgis 3.0
WMS Served through Geoserver
PHP7.2
While I am not sure I provided all the information to properly diagnose the problem, any indication on what to do to investigate this issue and solve it are appreciated.
Update:
I modified php.ini to enable error logging by setting the following switches:
error_reporting = E_ALL
display_errors = Off
log_errors = On
ignore_repeated_errors = On
ignore_repeated_source = Off
error_log = /var/log/apache2/php_errors.log
But no errors are being logged so far and php_errors.log file is not being created. Even creating the file is not having any effect on the logging. Am not sure what I am missing. I want to reiterate though that the search is working in the dev environment so can't see how it can be an authentication issue. I am trying the search in the prod environment on a browser from within the VM, so using localhost to access the application.
On dev tools I get the following:
jquery.min.js:formatted:4210 POST`
http://localhost/mapbender1/application/bh_admin/element/337/0-ed10fcc5-57e7-1f83-8a76-c32030225b85/search 500 (Internal Server Error)
send # jquery.min.js:formatted:4210
ajax # jquery.min.js:formatted:3992
n.<computed> # jquery.min.js:formatted:4044
getJSON # jquery.min.js:formatted:4033
_search # js:14187
(anonymous) # jquery-ui.min.js:6
(anonymous) # js:13976
dispatch # jquery.min.js:formatted:2119
r.handle # jquery.min.js:formatted:1998
When clicking on jquery.min.js:4210, the following line is highlighted in the file:
g.send(b.hasContent && b.data || null),
Update 2
Following #IonBazan suggestion, I found the prod.log file, albeit in a different folder, and the error indicates that the database service cannot be found. The log file was in:
var/www/mapbender1/app/logs
And this is the message in the log file:
request.CRITICAL: Uncaught PHP Exception
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
"You have requested a non-existent service
"doctrine.dbal.mobh_data_connection". Did you mean this:
"doctrine.dbal.default_connection"?" at
/var/www/mapbender1/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php
line 348 {"exception":"[object]
(Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException(code:
0): You have requested a non-existent service
"doctrine.dbal.mobh_data_connection". Did you mean this:
"doctrine.dbal.default_connection"? at
/var/www/mapbender1/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:348)"}
[]
As I have mentioned before, the dev app is capable of accessing the service. This means, I suppose, that the DB connection parameters are correct in the parameters.yml and config.yml files. So I have a feeling there might be some cached item that needs updating, especially that Mapbender documentation mentions this:
The cache-mechanism of the development-environment behaves
differently: Not all files are cached, thus code changes are directly
visible. Therefore the usage of the app_dev.php is always slower than
the production-environment.
And
The directory app/cache contains the cache-files. It contains
directories for each environment (prod and dev). But the mechanism of
the dev-cache, as described before, behaves differently.
If changes of the Mapbender interface or the code are made, the
cache-directory (app/cache) has to be cleared to see the changes in
the application.
So this turned out to be a folder permission issue. The reason why the dev environment was working was because the dev caches less components than the prod, which makes changes made to configuration files like parameters.yml and config.yml reflected in the dev and not in the prod. At some point during the setup and configuration process, the ownership of the cache/prod folder went to root which left the www-data user without the proper access rights to the folder. So bottom line, the prod cache was not being updated which made the database connection service invisible to the prod environment, although the parameters.yml and config.yml had the correct settings.
So what I did was the following, noting that there are steps I performed which might have been unnecessary, but at this stage I will not be looking into finding out which step was not needed.
First step, stop the running services (Apache and PHP server):
sudo app/console server:stop
sudo service apache2 stop
Clear the prod cache:
sudo app/console cache:clear --env=prod --no-debug
I also used the cache:clear command with the no-warmup switch which essentially leaves you with an almost empty cache folder. I issued this command since the previous one left some files in the folder.
sudo app/console cache:clear --env=prod --no-warmup
Install the assets:
sudo app/console assets:install web --env=prod
Give www-data user the proper folder permissions:
sudo chown -R www-data:www-data /var/www/mapbender/app/cache
sudo chmod -R ug+w /var/www/mapbender/app/cache
Start Apache and PHP server:
sudo service apache2 start
sudo app/console server:start
Note that app/console needs to be executed from the folder /var/www/mapbender
Like I mentioned earlier, there might be unnecessary steps but this is more or less what I did and now the app is working as expected.
Disclaimer: I am not a developer and the information presented here was assembled from more than one source, including the Mapbender documentation.
I have MAMP installed on my Mac with MacOS HighSierra 10.13.4.
I have ran composer create-project roots/bedrockin my /Applications/MAMP/htdocsfolder.
I have started up my servers via the MAMP UI. When I surf to http://localhost:8888/MAMPI get the MAMP startpage so everything seems to be working fine.
When I go to http://localhost:8888/bedrock I get a list of my files and dirs in my bedrock folder:
Index of /bedrock
Parent Directory
.env
.env.example
.gitignore
CHANGELOG.md
...
This is what my .env file looks like:
DB_NAME=adatabase
DB_USER=auser
DB_PASSWORD=apassword
# Optional variables
# DB_HOST=localhost
# DB_PREFIX=wp_
WP_ENV=development
WP_HOME=http://localhost:8888/bedrock
WP_SITEURL=${WP_HOME}/wp
I am wondering what I am doing wrong since I don't see the WordPress installation page.
It looks like apache, by dint of MAMP's default config, isn't serving from the correct directory for a bedrock project.
According to the bedrock docs, you should:
Set your site vhost document root to /path/to/site/web/ (/path/to/site/current/web/ if using deploys)
So, you'll need to modify your MAMP config to serve this project not from /Applications/MAMP/htdocs/bedrock, but from /Applications/MAMP/htdocs/bedrock/web.
You will need to click Set Web & MySQL ports to 80 & 3306 via MAMP > Preferences > Ports.
Then http://localhost/bedrock
Please let me know if this works :)
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/
I'm trying to run cockpit cms which comes with a dockerfile on a dokku server. The deploy is OK however I can't accces the site. I get a 403 in the browser and in the logs it says:
AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
I assume I need to set $_SERVER['DOCUMENT_ROOT'] somewhere?!?
Where do I set this and to which path do I set it?
Can I set this as an ENV? Is it /home/dokku/appname?
Thanks for your help!
P.S.: I'm new to both dokku and cockpit cms.
I ran into the same issue and noticed that var/www/html folder was empty after entering in my dokku apps container. Copying files fixed 403 errors but create an issue on install to create database files in storagefolder.
So, i just added these lines in Dockerfile :
...
# Dokku fix
COPY . /var/www/html
RUN chmod -R 777 /var/www/html/storage
VOLUME /var/www/html
...
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]