Running my symfony project on my host - php

I have build a symfony project and uploaded it to my hosting. I want to make it public. I though I just have to use bin/console server:run via SSH, but this isn't the case in production. How do I start my project? When I go to my domain I just get:
Forbidden
You don't have permission to access / on this server.
Even though I have controller with route for "/".

It's not such a good idea to use the internal PHP Webserver to run your project in production. Configure Apache or Nginx for your project and you can't start it because your port is used by the apache Webserver which gives you the Forbidden error.
http://symfony.com/doc/current/setup/web_server_configuration.html

Related

Working Laravel in CPanel but not in localhost without Artisan

I've installed in my remote server, via Softaculous, Laravel 8.
In order to access directly to the APP, just like when running php artisan serve in my local machine, in CPanel i defined the document root to the folder Laravel\public.
Everything works exactly as it should! I type the address (ex: myDomain.com) and the App runs perfectly...
However i don't want to being always typing php artisan serve while developing, so i tried to replicate the cpanel struture in my local machine.
To achive thar, i've created a virtualhost in XAMPP httpd-vhosts.conf pointing to the folder Laravel\public, and created the host file in windows system, like always.
When accessing the location in my local machine the first page renders perfectly, but as soon as i make a request for a new view, by example:
Route::get('/posts', function () {
return view('posts.index');
});
I get a "Not Found The requested URL was not found on this server" error! I'm sure is not a coding error because the same code runs flawlessly in remote server.
Which technique is used by cpanel to allow laravel to work directly from \public folder without necessity to initiate anything and how to replicate that in local development machine?
Well...
After much reading, backs and forwards, i believe this behavior depends on the way Apache its served by XAMPP.
So, the solution i adopted was change my local development tool to LARAGON.
Everything worked just fine with a lot of new features that don´t exist in XAMPP.

Why does Symfony ask a valid token when I start a local server?

I have a symfony 5.1 application under development on my laptop.
This command failed:
symfony console server:start
Your token has been revoked, please login again
Then, the prompt purposes me to login, but I cannot always login, because I'm behind a firewall that rejects external access for some security reasons.
I tried :
to uninstall the local certificate authority,
to launch server without TLS,
to launch server with the command symfony serve -d (I got the same error message)
to launch application with different version of PHP (by using .php-version file)
It's perhaps because I tested a demo symfony cloud which is expired. So, I tried to remove all elements about cloud.
Without success...
As soon as I am offline, the server can be started.
As soon as I'm connected on other network I can login, but I want to launch this local server when I'm on our enterprise network. (And I'm tired to disconnect from network)
I had a problem like this. It helped me - symfony account:logout
Here I found the answer - https://github.com/symfony/cli/issues/281
edit by Alexandre: I only had to logout from cloud. Because of the firewall rules, symfony detected that Internet was available and try to get a new token, but fails because of firewall rules.
Now I only have to disconnect from cloud when I am connect on enterprise network:
symfony account:logout
If I got this right, you want to start your server only locally right?
symfony serve -d
The -d flag starts the server in the background. You might want to install the certificate in order to serve https:// with the following command: symfony server:ca:install. Both commands are issued inside the root directory of your project.
Once you're done, go into the root directory where you started your server and type in this command to stop the server: symfony server:stop
This should give you a local web server with your symfony project.
FYI: In case you have installed several PHP-Versions you might need to pick a specific one by saving a .php-version file to your root directory:
For any 7.x version:
echo 7 > .php-version
For 7.2 version:
echo 7.2 > .php-version

How to give on local to other pc access to your project in valet?

When I make a project in laravel I can give access with php artisan serve but if a make a normal project and make host with valet link the PHP artisan don't work because it's not a laravel project. How can i give access to local with valet ? For example i have project.dev and make 192.168.1.5:80 like in laravel.
You can use the valet park or valet link commands to be able to access your application locally.
For a local network, you will need to make sure your port is accessible if your're behind a firewall. You may need to setup port forwarding, as well, if NAT is involved.
Are you trying to make the project accessible to others on the internet? For this, you can use ngrok.
https://ngrok.com/
”I want to expose a local server behind a NAT or firewall to the internet.”

How run Symfony project without virtual host?

I have my own server how can I run symfony project without creating virtual host.
Do I really need VirtualHost for symfony development?
It all depends on personal preference, if you want to open project with virtual host you can configure it, if not keep like this
localhost/project_folder/web/app_dev.php.
Your symfony app will run with the above URL. I have hosted so many apps on Cloudways and I ran my apps with the URL like this
phpstack-21306-71265-234521.cloudwaysapps.com/fos/web/admin
so I don't need to setup a virtual host either on live server.

How to deploy symfony 2 app

I am new to symphony2 and I need to know how can I make my application run without the server:run commmand. What do I need to do to be able to make it run inside the root folder of my nginx server on port 80?
There are several steps you need to do.
1. Install Apache or similar web server on your hosting server.
2. Create a virtual host which points to the directory where your Symfony app is.
3. Allow proper permissions to folders.
4. Run your web server from specific console command.
Refer following two URLs for more details:
http://symfony.com/doc/current/cookbook/deployment/tools.html
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-symfony-application-to-production-on-ubuntu-14-04

Categories