Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change /web to /public_html #40

Closed
ghost opened this issue Jan 19, 2017 · 10 comments
Closed

Change /web to /public_html #40

ghost opened this issue Jan 19, 2017 · 10 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 19, 2017

Issue by @t-me
January 19th, 2017, 21:15 GMT

Hello All,

I want to change the "/web" directory to "/public_html".

When i follow this link : symfony.com/override-the-web-directory

and do a composer update it looks fine. But when i go to install.php i get a error 500. in the log files i see this

[Thu Jan 19 21:06:15.625264 2017] [lsapi:error] [pid 234676] [client 82.75.164.96:0] [host t-me.nl] Backend fatal error: PHP Fatal error:  Uncaught InvalidArgumentException: The target directory "/home/debxxx/domains/t-me.nl/app/../web" does not exist. in /home/debxxx/domains/t-me.nl/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php:85\nStack trace:\n#0 /home/debxxx/domains/t-me.nl/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(262): Symfony\\Bundle\\FrameworkBundle\\Command\\AssetsInstallCommand->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\BufferedOutput))\n#1 /home/debxxx/domains/t-me.nl/vendor/contao/installation-bundle/src/Controller/InstallationController.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\BufferedOutput))\n#2 /home/debxxx/domains/t-me.nl/vendor/contao/installation-bundle/src/Controller/InstallationController.php(133): Contao\\InstallationBundle\\Controller\\InstallationController->runCommand(Object(Symfon in /home/debxxx/domains/t-me.nl/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php on line 85\n

The reason i want to change it is because i cant change public_html to web directory as root folder.

@leofeyer
Copy link
Member

leofeyer commented Jan 19, 2017

I doubt that this is possible in Contao 4.3. We have made quite some efforts to support a custom directory structure in version 4.4, but there are still a lot of hard corded references to /web, which we cannot change without knowing the path to the web folder in Symfony. And by design, Symfony does not know it (only Composer does).

@contao/developers /cc

@Toflar
Copy link
Member

Toflar commented Jan 19, 2017 via email

@fritzmg
Copy link
Contributor

fritzmg commented Jan 19, 2017

A customizable web folder is no unusual requirement though.

@leofeyer
Copy link
Member

The reason i want to change it is because i cant change public_html to web directory as root folder.

@t-me Actually you are supposed to put everything into the public_html folder and then route your domain in cPanel (or whatever hosting control panel there is) to the web subfolder.

A customizable web folder is no unusual requirement though.

Correct. That's why we are trying to support it in version 4.4. But it is not trivial (see above).

@t-me
Copy link

t-me commented Jan 20, 2017

@leofeyer Thanks for your comment on putting everything in the 'public_html'
I have DirectAdmin as control pannel but can not change the virtualhost file.

I found another solution it is not ideal but it does the trick.

Found it here...

Options -Indexes
# .htaccess primary domain to web redirect
# this file must be in the (public_html | web ) folder of your hosting account 
# make the changes to the file according to the instructions.

<IfModule mod_rewrite.c>
	# Do not change this line.
	RewriteEngine on

	# Uncomment the following lines to add "www." to the domain:
	# RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
	# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

	# Uncomment the following lines to Redirect to SSL
	# RewriteCond %{HTTPS} !=on
	# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]	

	# Change %host% to be your primary domain.
	RewriteCond %{HTTP_HOST} ^(www.)?%host%$

	# Change 'web' to be the folder you will use for your primary domain.
	RewriteCond %{REQUEST_URI} !^/web/

	#********************
	# NOT RRCOMMENDED   *
	#********************
	#
	# Uncomment those two lines if you want dirs and files to be accessible out of the
	# your primary domain dir.

	#RewriteCond %{REQUEST_FILENAME} !-f 
	#RewriteCond %{REQUEST_FILENAME} !-d

	# Change 'web' to be the folder you will use for your primary domain.
	RewriteRule ^(.*)$ /web/$1

	# Change %host% to be your primary domain again. 
	# Change 'web' to be the folder you will use for your primary domain 
	# followed by / then the main file for your site, index.php, index.html, etc.
	RewriteCond %{HTTP_HOST} ^(www.)?%host%$ 
	RewriteRule ^(/)?$ web/app.php [L]
</IfModule>

Hope this will help for other people having the same issue as i have.

Edited the .htaccess with "www" and "ssl" option

@leofeyer
Copy link
Member

I have found hard coded references to /web in at least the following files:

  • src/Resources/contao/library/Contao/Combiner.php
  • src/EventListener/InsecureInstallationListener.php
  • src/Resources/contao/library/Contao/Image.php
  • src/Resources/contao/library/Contao/Automator.php
  • src/Resources/contao/controllers/FrontendCron.php

The news and calendar bundles also write into the web/share folder, therefore we need to store the path to the web directory somewhere so we can access it in Contao. I understand that this is against the Symfony concept, but until all the resources above have been refactored, I don't think we have a choice.

@contao/developers /cc

@leofeyer
Copy link
Member

As discussed at the developer's meeting, the parameter shall be named contao.web_dir.

leofeyer added a commit to contao/core-bundle that referenced this issue Jan 23, 2017
@leofeyer
Copy link
Member

Added the parameter in contao/core-bundle@b307ac4 as basis for the upcoming pull requests.

@leofeyer
Copy link
Member

@t-me BTW, the easiest solution probably would have been a symlink from public_html to web.

@leofeyer
Copy link
Member

Fixed in contao/core-bundle@8a74bb1.

agoat pushed a commit to agoat/contao-core-bundle that referenced this issue Apr 10, 2017
* Make Symfony 3.2 the minimum requirement (see contao#630).

* Set the encryption key from the kernel secret by default (see contao#660).

* Stop using the deprecated QuestionHelper::setInputStream() method.

* Update Dropzone to version 4.

* Prefer the caret operator over the tilde operator in the composer.json file.

* Add the contao.root_dir parameter (see contao#662).

* Update the change log.

* Stop using the contao-components/all meta package.

* Update the README.md file.

* Deprecate the contao:version command (see contao#668).

* Update the installation path.

* Auto-select the active page in the quick navigation/link module (see contao/core#8587).

* Look up the form class and allow to choose the type (see contao/core#8527).

* Add PHP Toolbox support (see contao#565).

* Remove the arrow brackets in the book navigation template (see contao/core#8607).

* Add a bottom padding to the buttons layer.

* Add the contao.web_dir parameter (see contao/installation-bundle#40).

* Fix the tests.

* Match security firewall based on request scope (see contao#677).

* Fix an issue found by Scrutinizer.

* Use the contao.web_dir parameter in the Combiner (see contao#679).

* Fix the tests.

* Add stripRootDir() method to System class (see contao#683).

* Add the contao.image.target_dir parameter (see contao#684).

* The ContaoCoreExtension::overwriteImageTargetDir() is not deprecated.

* Support custom backend routes (see contao#512).

* Use the scope matcher instead of checking the request attribute (see contao#688).

* Replace every occurrence of $contaoFramework with $framework.

* Fix an issue found by Scrutinizer.

* Fix deprecations in unit tests (see contao#687).

* Added a DBAL field type for UUIDs (see contao#415).

* Support importing form field options from a CSV field (see contao#444).

* Fix the coding style and the unit tests.

* Add the Doctrine field type in the config.yml file.

doctrine:
    dbal:
        types:
            binary_string:
                class: "Contao\\CoreBundle\\Doctrine\\DBAL\\Types\\BinaryStringType"
                commented: true

* Add a basic unit test for the BackendCsvImportController class.

* Update the change log.

* Fix rebuilding the search index (see contao#689).

* Also handle „no origin“ and „empty origin“ in the CORS provider.

* Remove an unused use statement.

* Remove the security.yml file and update the README.md file.

* Improve the e-mail extraction in the text element (thanks to Martin Auswöger).

* Rename the Test namespace to Tests.

* Update the composer.json file.

* Update the .php_cs file.

* Raise the minimum PHP version to 5.6 (see contao#701).

* Support using objects in callback arrays (see contao#699).

* Use try-finally blocks to close all output buffers when downloading a file (see contao#714).

* Fix the coding style.

* Only prefix an all numeric alias when standardizing (see contao#707).

* Adjust the test namespaces.

* Allow to manually pass a value to any widget (see contao#674).

* Add a change log entry and fix the tests.

* Disable the picker buttons if the main window does not show a picker.

* Use the file manager instead of the file picker.

* Use the site structure instead of the page picker.

* Always show the selected nodes.

* Add the menu builder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants