images and css not displaying in Symfony on Xampp Server - symfony

I have downloaded the Symfony project and added the database.
But when I am going to web folder then on the home page. Images and CSS not displaying.
It is showing like below,
http://localhost/uploads/logos/image.jpg
** but my project is on a folder name like /folder/ **
All the images and css have broken links.

How did you run the web server? Try this,
Symfony v2.* = php app/console s:r
Symfony v3.* = php bin/console s:r
If you want to Xampp Server, you should change the root directory;
project_directory/web

In this matter virtual host is the best solution.
<VirtualHost *:80>
ServerName project.local
ServerAlias www.project.local
DocumentRoot "C:\xampp\htdocs\project\web"
<Directory "C:\xampp\htdocs\project\web">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

Related

How to set Symfony3 environment in Apache

I am running Apache 2.4 on my development machine so I can test code locally. How do I tell Symfony 3.4 to use the 'dev' environment instead of the 'prod' environment?
I've tried browsing to http://localhost/app_dev.php but that just redirects to http://localhost/. It looks like the front controller is set in .htaccess but if I modify that file, then my production server will be using the wrong front controller.
I've read the docs on the following pages and it talks about how to create new environments but not how to set the default environment.
https://symfony.com/doc/3.4/configuration/environments.html
https://symfony.com/doc/3.4/setup/web_server_configuration.html
I'm running Apache 2.4 on Windows 10 and here is my vhost configuration
<VirtualHost *:80>
ServerName example.local
DocumentRoot "C:\Users\kento\PhpstormProjects\example\web"
<Directory "C:\Users\kento\PhpstormProjects\example\web">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex app_dev.php
</Directory>
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
</VirtualHost>
example.local points to 127.0.0.1 in my hosts file. I set DirectoryIndex to app_dev.php but that seems to be overridden by the .htaccess file.
You've already set the vhost to use app_dev.php, but then you allow a .htaccess to override with the AllowOverride All. Change that to AllowOverride None and the .htaccess will be ignored.
There may be some config from there you would be able to merge into the vhost.
I tend to prefer all the configuration in the virtual host, and not have any use of a .htaccess file, for a small speed boost - especially in production.

wordpress site working locally but not from the domain

My wordpress site is working locally in my wamp server, this is hosted on an ec2 instance and domain is maintained in Route 53\cloudfare. The domain is working when i checked it using mxtoolbox. The site was working and live till the time i changed my host file in the server. I removed the host file entries accidentally thinking it is a dev site, however i restored it but still the site is not working and i am getting only the "TOO MANY REDIRECTS" error. The following is the current windows host file details
#
127.0.0.1 localhost
::1 localhost
127.0.0.1 mydomain.com
::1 mydomain.com
I restarted the server and WAMP multiple times but it is not working.
The following is my virtualhost configuration
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
#
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "c:/wamp/www/sitefolder"
<Directory "c:/wamp/www/sitefolder/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot "c:/wamp/www/sitefolder"
<Directory "c:/wamp/www/sitefolder/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>`
Clean your cache and browser history first, then try doing it below:
Open your wordpress admin panel --> Settings--> General --> Make sure it points to the correct domain. --> Save
Or go to the wp-config.php file (Try this if the first method fails / can't be accessed)
add:
define('WP_HOME','http://YourDomain.com');
define('WP_SITEURL','http://YourDomain.com');
or
Try to remove or rename default .htaccess
or
Try to disable the plugin (renaming the plugin folder in the "wp-content/plugin/plugin-folder-name" will non-active that plugin. This might solve the problem if the constraints are due to the plugin)
That's a number of ways when I resolve the ERR_TOO_MANY_REDIRECTS problem. Goodluck

WAMP server - How to host more Wordpress websites?

I want to host more WP sites on WAMP server at the same time.
How to do that?
I would recommend you to download XAMPP. Basically WordPress is built on PHP and XAMPP has support for PHP. First download it and configure it then go to the installation directory and go to xampp>htdocs> then make a new folder 'project' and then unzip the WordPress files in that folder. After that read the manual provided ant xampp's website and follow it. Basically you can build your WordPress website on Xampp.
EDIT
Oh sorry for not understanding the question properly.
Now do this.
step 1: host the different websites in htdocs/ folder in xampp. You can host many websites as you want.
step 2: Then go to xampp/apache/conf/httpd.conf and uncomment the line which says this. For uncomment delete the '#' character.
Include conf/extra/httpd-vhosts.conf
step 3: Go to xampp/apache/conf/extra/httpd-vhosts.conf
Create the setup like this
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerName xampp
#ServerAlias
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site1"
ServerName site1.com
ServerAlias www.site1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site2"
ServerName site2.com
ServerAlias www.site2.com
</VirtualHost>
YES. You can make sub-folders in www and make different WP websites. But be careful with the database configuration. Installing WP does nothing but coping some PHP files to that specific folder. All the data is saved in database and inside that specific folder itself (E.g. config php files).

MAMP multiple virtualhosts not working

Somehow my virtualhosts won't work and give me The requested URL / was not found on this server. I have tried multiple things, but can't get it to work. My MAMP root folder is set to the Projects folder
I have the following folder structure:
-Projects
-website1
-websites
-public
-system
-website2
What I want is website1 to work on a different URL than website 2. What I have:
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/websites/system/%-3"
ServerAlias *.system.test
</VirtualHost>
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/websites/public/%-3"
ServerAlias *.public.test
</VirtualHost>
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/website1"
ServerAlias test.nl
</VirtualHost>
the hosts file:
127.0.0.1 website2.system.test
127.0.0.1 test.nl
I have also tried:
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/%-3"
ServerAlias *.test.nl
</VirtualHost>
Nothing seems to work to get website1 (wordpress website) working under test.nl any ideas? The reason why I have that folder structure is because "websites" is for work and the root for private projects. BTW whenever I put website1 in the system folder and add : website1.public.test to the hosts file it works, however when I put it in the public folder it doesnt, it looks like the only virtualhost read is the top one?
I finally found a fix: Apache 2 only serves first virtual host

how to move Symfony project to an other folder?

I have started a project on Symfony2 and now I would like to change the place where I installed it in my files.
here where it is now:
Application/MAMP/htdocs/symfony/
What is I move the symfony file to
user/myWebSiteProject/...
by the way my composer is in:
user/myWebsitePorject/bin/composer/composer.phar
---------------------------------------------/path/composer.json
Can I do it just like it... move it just like any folder. or should I take into account some things...?
You can move the whole folder without any major issues. What you will need to do is to change any VirtualHosts you may have setup, You will need to update the DocumentRoot property.
You would normally find the file to update on a mac at: /etc/apache2/extra/httpd-vhosts.conf depending on how your system is configured.
I'm presuming that your using Apache, Your VirtualHost should look something like this:
<VirtualHost *:80>
ServerName local.symfony
DocumentRoot "/user/myWebSiteProject/web"
<Directory "/user/myWebSiteProject/web">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "/private/var/log/apache2/local.symfony-error_log"
CustomLog "/private/var/log/apache2/local.symfony-access_log" common
</VirtualHost>
This guide should help with the configuration.

Resources