My website is ready to be deployed and I am trying to set it up online.
Some informations:
The host is OVH.
It doesn't allow SSH, I have to send my files with FTP. No command line either.
I want to be able to set up the website in a subdirectory: /www/test for now (my current website is still in /www).
The problem:
When I open the URL my-website.com/test, a Symfony exception tells me No route found for "GET /test/", which clearly means that Symfony doesn't know it is in a sub-directory.
How can I tell it?
EDIT:
I just realized it worked when I access my-website.com/test/web.
Here I wrote exactly about that: https://www.refactory-project.com/install-symfony-app-in-a-subfolder-of-an-existing-site/
Upload the application part
Start by uploading the application folders at the same level of your site root:
[ftproot]
-- public_html
---- ...
---- ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- web
------ app.php
------ app_dev.php
------ ...
---- composer.json
---- composer.lock
Move the web part
Move the content of the "web" folder into the desired subfolder, i.e. "myapp".
[ftproot]
-- public_html
---- ...
---- ...
---- myapp
------ app.php
------ app_dev.php
------ ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- composer.json
---- composer.lock
Let the web know where is the application
Edit files app.php and app_dev.php and insert the new application location.
require_once __DIR__ . '/../../symfonyapp/app/bootstrap.php.cache';
require_once __DIR__ . '/../../symfonyapp/app/AppKernel.php';
Let the application know how the web folder is called
Edit file composer.json with the new web folder name
{
...
"extra": {
...
"symfony-web-dir": "../public_html/myapp"
}
}
You're sort of setting yourself up for hardship if you are deploying a Symfony app to a host that does not allow SSH - for instance if you want to rebuild your cache you will have to manually nuke your app/cache/* dirs?
To answer your question directly, if your Symfony project is in /www/test/ then Symfony's web directory is /www/test/web so you need to use a url like:
http://foo.com/test/web
For completeness, try accessing the explicit url - /test/app.php and /test/app_dev.php respectively. If you receive a Symfony error page in either case you know you are on the right path at least.
Edit #1
Something to point out: your project and configuration files and may be readable with this deployment scenario - which is not ideal - so you might want to check this and take some actions to secure this directory if possible. I appreciate that this is probably a test deployment so it might not be a big deal, but it's always good to keep mindful of security :)
Edit #2
Okay YMMV with this, I am no .htaccess expert but you could deploy your symfony app to /www/symfony/ and rewrite the /test URI to show /symfony/web/ instead; e.g:
RewriteEngine On
# rewrite all `/test/*` uris to `symfony/web`
RewriteRule ^test(.*)$ symfony/web/$1 [L,QSA]
# direct access to /symfony dir is a 404
RewriteRule !^symfony/web/$1 - [R=404]
This should serve all applicable uri requests (to /test and /symfony/web itself) to Symfony, while restricting direct access to the symfony core files.
Haven't tested this, so how this will play with Symfony's own .htaccess is not something I can answer off the top of my head.
How about using .htaccessfile to achieve your goal. As far as I understand your problem your symfony app works IF you access it via web folder for example foo.com/test/web
try using the following code in your .htaccess file which will sit at the root of your test directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
</IfModule>
please replace the domain.com with your domain name.
Related
I am sure there are many things not done yet to eliminate the technical frustrations that i am currently experiencing with Bitnami Wordpress Multisite 4.6-1 running on AWS. I am taking this opportunity to highlight the issue i am facing on stackoverflow community to get some help, learn, grow and most importantly be able to help as well. This is my first Question here and i am afraid that i am unable to post more 2 links here because i am not allowed to.
To Begin with, There seem to be Permissions Issues on Wordpress Multisite running on Aws EC2 which was setup and configured through Bitnami. Sadly documentation and Articles on Bitnami Wiki are not updated for the latest version of Wordpress Multisite and i am not comfortable using Bitnami Osx Application to manage Wordpress because i am not using Bitnami Cloud Hosting but AWS Ec2.
AWS EC2 Configuration Details:
Instance Type: T2 Micro
Elastic IP: Yes
Security Groups: Grants access to Bitnami WordPress
IAM User: 2 Users, Enabled with Following Policy.
1. AdministratorAccess
2. AmazonEC2ContainerServiceFullAccess
3. AmazonVPCFullAccess
Wordpress Network: Able to Install Themes & Plugins on Network and Problems are listed below.
Wordpress Site Running on Network: Able to Activate Network Plugins/ Themes. Able Import xml data on Site with minor issues as the Theme Installed on the network is Outdated.
Terminal: Able to establish SSH connection using pem key. browse, create files and delete any newly created files using bash commands however issue is with deleting unwanted Plugins / Theme by removing using same commands even through i did run chmod 777 multiple times to ensure read, write and execute is enabled but there is no Success.
Wordpress Issues:
Unable to Update Plugins through Dashboard weather Paid/Unpaid. Please check the screenshots.
Plugin Update - Failed.
Unable to Uninstall any outdated theme weather Active / Inactive on Sites. - Failed]2
Troubleshooting Steps 1:
Network Setup - Implemented through Terminal using VIM command :
1 - Added the following to wp-config.php file in /opt/bitnami/apps/wordpress/htdocs/ above the line reading /* That’s all, stop editing! Happy blogging.
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'ec2-x-x-x-x.compute-1.amazonaws.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1); */:
]
2- Added the following to .htaccess file in /opt/bitnami/apps/wordpress/htdocs/, replacing other WordPress rules:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
Result: NO Success.
Troubleshooting Steps 2:
SSH Connection to Instance : Succes
Create New Files: Yes
Delete Newly Files: Yes (using rm filename)
Delete Empty Dir: Yes (Using rmdir)
Delete Outdated Theme Dir: Permission Denied (rm: cannot remove 'startit': Is a directory)
Note: I did run CHMOD 777 at the beginning of SSH session again.
Result : NO Success.
Troubleshooting Step 3
FTP FileZilla: Connected through filezilla using PEM key.
Able to Upload new folders and files.
Unable to delete unwanted folders ;
Error: Permission Denied.
Result : NO Success.
Please know that i very new to all that i mentioned above and i am sure there are many troubleshooting steps that i have to follow. Your help will be highly appreciated.
I used a cloud server with BITNAMI, and just hated it. Not for me. Its a bare system. No cpanel, WHM, or anything exciting. Just an empty linux OS. We had spent a week getting it up. Finally decided to can it.
use command line:
What we did to fix the permission issues is CMD into your server as ROOT!
make sure you are root, if you are not root make sure you SUDO -SU.
File folders have to be "0755"
Files have to be "0644"
setting all files, and folders correctly made a world of difference.
I'm building my first Symfony site that will eventually be hosted on a shared server/cPanel site.
I'd like to have my Symfony/web content separate from the server files, though the way Symfony is structured, all the Symfony files are outside the public_html folder. But with a cPanel setup, there's already a lot of files and folders outside the public_html folder (mail, logs, .bashrc, .cpanel, www alias... and a dozen others).
I worry that it feels messy if I put Symfony mixed in with all these files and there could be a conflict. I would rather it be in a directory by itself. The best idea I've had so far is to make a subdomain to host Symfony where I can manually choose the web folder, and then just do redirects to the subdomain.
What do others do?
This is how I decided to do it, and it seems like it will work pretty well. I just use the regular cPanel public_html as the document root, upload the whole Symfony contents to that directory, but then add an .htaccess file with the contents:
RewriteEngine on
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
And that protects the main Symfony contents from public access while at the same time putting it all in a directory by itself. It seems to work so far. If anyone has a better idea, I'm open to it!
I want to create http://localhost/Symfony/temp/.
In temp will be a basic index.html and some images. If I create the folder right now and put the index.html file in /temp/ I get a 404.
How do I get a normal response from http://localhost/Symfony/temp/index.html?
Requests going to temp/ are being caught by Symfony's default .htaccess. You'll have to add following:
# allow access to temp
RewriteRule ^temp.* - [QSA,L]
If you want it to work even with app_dev.php just change it to ^[app_dev.php/]*temp.*.
But I'm more interested why do you want to do that in root directory and not in static files directory (eg. web/static/temp). You wouldn't need to mess around with .htaccess and you'd be able to link to such images with asset(...).
Here's the solution I eventually came up with.
All I did was create a .htaccess file in /temp/ and inserted:
allow from all
Since I was getting a 404 error and all the other symfony folders had a .htaccess with
deny from all
I reversed engineered an answer.
Hope this helps someone else.
I'm completely new to Symfony 2 and i can't really understand the folder structure and organization of a project. I know what a bundle is, but what is unclear to me is:
what's the main directory (the directory to be copied on the web server for deployment)
where assets (css, javascript) should be placed
if (and how) environment should be changed when publishing my website
I've already read the book on Symfony website and i can't find those answers.
The web root of a Symfony2 app is the 'web' directory, but when you push to production the entire symfony2 project should be pushed not just the web root.
From the symfony2 book
app/: This directory contains the application configuration;
src/: All the project PHP code is stored under this directory;
vendor/: Any vendor libraries are placed here by convention;
web/: This is the web root directory and contains any publicly accessible files;
The assets should be kept in the bundles 'Resources/public/[css/js/images]' folders. From here you would have to copy or symlink those directories into the web root to make them accessible. Symfony2 comes with a command line utility located in the 'app' directory. app/console assets:install web --symlink command executed from the command line of your symfony2 project root will install all of the bundle's assets for you.
To change environments and you are using Apache you would use a .htaccess file and mod_rewrite to select which environment you would want to use
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
using /app.php puts me into production mode and using /app_dev.php would put me in development mode.
The main directory contains the app folder.
The assets should be
placed in the bundles folder they're related to. This folder is named
"public".
Read this. All you need to do is remove the app_dev.php file.
I've recently installed Wordpress and can't seem to get the website to display friendly URLs no matter what settings I use inside the Dashboard or in an .htaccess file. I've tried numerous versions of Wordpress and still can't achieve what I need, despite succeeding on hosts other than Concentric/XO, any idea why?
Update: I released a plugin that does all of this for you. However, you still need to follow the steps for the .htaccess file. Have a look here: http://wordpress.org/extend/plugins/permalink-fix-disable-canonical-redirects-pack/
Follow these steps before you attempt to install WordPress for the first time. If you have already installed it, start over.
To get Permalinks working you need to create a .htaccess file, WordPress can't do this automatically on this host. Here is what the basic .htaccess file should look like:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Make sure you create this file using an editor that allows for unix formatting (like PSPad, or VIM, Textmate, etc.), using notepad will give you a parsing error - it has something to do with invisible end of file characters(CLRF). Make sure the last rule has a hard return after it, it's required. .htaccess files are cached for up to 15 minutes so you may have to wait for it to kick in.
Next you'll need to edit your wp-settings.php file so open that up in your editor. Add the following code right above the closing ?> php tag:
if(isset($_REQUEST['q'])) {
$_SERVER['REQUEST_URI'] = "/" . $_REQUEST["q"];
}else{
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
} else {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . "?" .
$_SERVER['QUERY_STRING'];
}
}
If someone can write that block of code more cleanly feel free, I'm not an expert PHP programmer.
Once that block of code is in place you can proceed to run the install.
Now that WordPress is installed you'll have to do one more thing before you can start blogging:
Create a new file called: disable-canonical-redirects.php and upload it to the wp-content/plugins directory.
Drop this block of code into that file:
<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/
remove_filter('template_redirect', 'redirect_canonical');
?>
Now you need to enable that plugin, go to the Admin login page:
example.com/wp-login
Enable the plugin you created. That's it, you're on a horse.
Ask them whether they have mod_rewrite enabled.
To find out yourself, try adding a .htaccess file containing gibberish first:
sadölkasdfksdakföasldfg
if putting that onto the webspace, and then trying to access any page on it results in a 500 error, htaccess files get parsed.
Then try adding a "real" .htaccess file:
RewriteEngine On
if that works without a 500, then URL rewriting should be turned on.