Laravel - How to change app domain into to the test? - laravel

I have used app domain on my laravel projects till today, but today mozilla starts open app domains with `https..
So I edited my laravel.app.conf file and changed Servername as laravel.test then restart my apache2
sudo service apache2 restart
But this time local website doesn't open, it says server not found.. Did I something wrong ? Or am I need to do something else ?
Edit: Also I changed /etc/hosts file too

I just restart pc and now it works (But I restarted apache ?)

Related

Laravel deployment to apache with php-fpm restart

I'm quite new to laravel and the concept of CI/CD. But I have invested the last 24 hours to get something up and running. Actually I'm using gitlab.com as repo. There I have configured the CI/CD functionality.
The deployments should be done to SRV1 which has configured its corresponding user with a cert. The SRV1 should then clone the necessary files from the gitlab repo by using deployer. The gitlab repo also has the public key from SRV1 user. This chain is working quite good.
The problem is, that after deploying I need to restart php-fpm so that it can reinitialize its symlinks and updates its absolute path cache.
I saw various methodes to overcome this with setting some cgi settings in php-fpm. But these didn't work for me since they all are using nginx, while I'm using apache.
Is there any other way to tell php-fpm with apache to reinitialize its paths or reload after changes?
The method to add the deployer user to the sudoers list and to call service restart php-fpm looks quite hacky to me...
Thanks
UPDATE1:
Actually I found this : https://github.com/lorisleiva/laravel-deployer/blob/master/docs/how-to-reload-fpm.md
It looks like, that deployer has some technique to do this. But this requires the deployer user to have acces to php-fpm reload. Looks a bit unsafe to me.
I didn't found any other solutions. there are some for nginx to tell nginx to always re-evaluate the real path. Obviously for Apache it should be "followSymLink" but it was not working.
Actually I created a bash script which is running under root. this script always check for changes in the "current" symlink every 10 seconds. if there was a change -> reload php-fpm. Not nice, of course quite ugly, but should work.
Still open for other proposals.
I solved this issue on my server by adding a php file that clear APCU & OPCACHE :
<?php
if (in_array(#$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']))
{
apcu_clear_cache();
apcu_clear_cache('user');
apcu_clear_cache('opcode');
opcache_reset();
echo "Cache cleared";
}
else
{
die("You can't clear cache");
}
then you have to call it with curl after you updated your symlink :
/usr/bin/curl --silent https://domain.ext/clear_apc_cache.php
I use Gitlab CI/CD it works now for me

How to remove "public/index.php" on server?

I m newly working on laravel.
I created laravel project named as "blog" on localhost and for removing public/index.php, I followed following process :
cut and pasted .htaccess from public/ folder to root i.e. blog
Renamed the server.php to index.php
Then I created a test api in api.php route and echoed "Hello World".
Now when I go to project path from my localhost server like:
localhost/Blog/api/test then its work properly.
But when I run same on a server like 192.101.111.555,like :
192.101.111.555/Blog/api/test then it showing NOT FOUND.
I am not getting how can I resolve this. And why its working fine on localhost but not working on server ?
You rename server.php but not recommend. This file copy then rename
Yes, if you have done those settings you will not be able to properly access on the localhost by running php artisan serve. So for this, you can install xampp and do the virtual host settings. Check more info at
How to enable Virtual Host on Xampp for Laravel?.
On the benefit of this is that you don't have to run the php artisan serve command again and again.

Laravel ReST API URL 404 not found on AWS EC2 in Apache + mySQL environment - The request URL was not found on this server

This question is on AWS Laravel Implementation on Apache + mySQL AWS EC2 instance.
After copying the working Laravel folder from xampp/htdocs/my_project_name, migration to create tables in mySQL database and seeder are working.
However, I could not connect to my APIs using Postman. (404 not found)
I following these solution links
laravel the requested url was not found on this server
https://laracasts.com/discuss/channels/general-discussion/laravel-5-the-requested-url-was-not-found-on-this-server
I managed to modify the httpd.conf. However, I could not find file .htaccess
(
where .htacces i can find? Sorry for stupid question, but i can't find :) – MilanNz Mar 11 '15 at 12:30
#MilanNz The .htaccess can be found in the public directory of your application. However the code from this answer goes inside a vhost file. The location of that depends on your server. (e.g. for apache2 and unix it's usually at /etc/apache2/sites-available)
)
Also, I was not able to reboot my Apache using "service apache2 restart".
So I "sudo reboot"ed the EC2 instance and reconnected using Postman, the API urls were still not found.
There is a possibility that my URL is wrong. So I attach it here:
The URL used is http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/my_project_name/public/api/resultCRUD/list
The working xampp URL is http://localhost/my_project_name/public/api/resultCRUD/list
The Laravel project folder is located at /var/www/html/my_project_name on AWS EC2.
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpinfo.php and
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpMyAdmin/ are working.
Any help is greatly appreciated. Thanks!
It's finally working.
The reason I was stuck is because most of the answers are for ubuntu while I am using RedHat.
For RedHat EC2 instance, need first change the content of /etc/httpd/conf/httpd.conf following https://pinecode.io/article/setting-up-laravel-56-on-aws-linux,
In this step, I actually changed all "AllowOverride None"s to "AllowOverride All" instead of only line 151 of httpd.conf.
Then need to restart httpd using sudo service httpd restart
following https://gistpages.com/posts/enable_mod_rewrite_in_apache2_on_red_hat_linux
Then it is working all fine.
I didn't restart my apache service after saving changes to httpd.conf when I was asking this question.

Lumen not working out of the box

Just installed Lumen framework.
hit the link http://localhost/lumen/public/ in my browser and got this following error, anyone got any idea about it?
Traced it back to the app.php file in bootstrap folder.
if You want to access lumen project without "php artisan serve"
$app->run(); replace with
$request = Illuminate\Http\Request::capture();
$app->run($request);
from this path yourlumenproject/public/index.php
Open your terminal in the root folder run the following command php artisan serve.
Lumen development server started on http://localhost:8000/
if you want to serve your app in local development you can do this :
php -S localhost:8000 -t public/
and it will serve in localhost in port 8000. hope this help.
Note : I'm using Laravel Framework version Lumen (5.2.4) (Laravel Components 5.2.*)
At the moment Lumen only runs in the domain root.
(I've submitted a PR that fixes this but it has yet to be merged)
You have to create a Virtual Host on your local webserver and point the document root of that to the public directory. After that you can access your app with something like: http://lumen.dev.
Guide for Virtual Hosts with nginx
Guide for Virtual Hosts with Apache
A simple alternative to setting this up manually is Laravel Homestead. It is an official Vagrant box made for Laravel, that allows you to easily get your development environment up and running.

Xdebug + XAMPP + Netbeans = fail. Cannot get debugger to work in Netbeans

I've read other questions regarding this topic. The listed solutions haven't worked.
Installed:
XAMPP 1.7.7
Netbeans 7.1.1
XDebug 2.1.4
phpinfo() shows that Xdebug is installed with all the correct parameters:
zend_extension = C:\xampp\php\ext\php_xdebug-2.1.4-5.3-vc9.dll
xdebug.remote_enable = on
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000
However, when I start a Netbeans debug session, it cycles for awhile with no effect. When I stop it, I get the Info box informing me that "No connection from xdebug was detected with in nn seconds. The reasons could be that xdebug is not installed or not properly configured. (their emphasis).
As far as I can tell, I configured everything correctly, restarted the Apache server and it still doesn't work. I'm at a total loss on how to proceed. Any help is appreciated.
Can you believe it!? After spending literally HOURS researching this problem, I finally found the cause which I can only classify as a bug. Now, how do I report a bug? That's the next question.
Here's a summary:
create PHP project and setup NetBeans project site root to subfolder.
(In order to not register for Apache new test site for any new task I
put every new task into subfolder under my local test domain, e.g.
http://test.my/project3/ ). NetBeans will not start debugging session
automatically in this case. You will see a ‘waiting for connection’
message from the image below. Do not worry. Left it as it is. Go to
your browser. I use FireFox 4. And call the script you wish to debug
with additional parameter, e.g.
http://test.my/project3/index.php?XDEBUG_SESSION_START=netbeans-xdebug
When you return to NetBeans you will see that connection with xdebug
is established successfully. To stop XDebug session manually call any
script from the same subdirectory with this parameter
?XDEBUG_SESSION_STOP_NO_EXEC=netbeans-xdebug
The complete solution can be found on my newest hero's blog NetBeans 7.0 for PHP Waiting for Connection to XDebug
Edit: Know what I just discovered? I removed index.php as the index file of my run configuration. Works like a charm without having to manually insert the xdebug section of the url.
I just ran into this with Netbeans 8 and while your answer worked around my problem I think I found the solution that will fix it forever.
Project Properties => Run Configuration => Advanced ...
Ensure that the following entry is selected
Debug URL: 'Default: YOUR URL'
Mine was set to "Do Not Open Web Browser" .....
Now it works as it used to work many months ago :)
I am a .Net programmer and very new to PHP. Recently I was trying to host an open source PHP application on my machine(Windows). After the Struggle for 5-6 days I will list the steps which worked for me.
I uninstalled every previous installations of XAMPP and NetBeans and proceeded with fresh installations.
This might not be the solution for everyone but it worked for me and I hope it helps someone.
install XAMPP
install netbeans for PHP.
Open IIS and stop it. It is running on port 80 by default.(I am running XAMPP on port 80 i.e. default, Running on other port might need additional configuration settings)
Open XAMPP control panel and start Apache. If port 80 is free no problem should arise.
Open localhost in browser in should display XAMPP home page.
open phpinfo() link on the left pane and copy all the contents on page. Go to: http://xdebug.org/wizard.php and paste all the content in TextBox and click Analyze my phpinfo output. It will diplay you the Xdebug file suitable for your configuration.
Download the given Xdebug dll and copy it in C:\xampp\php\ext (Xampp being the default Xampp installation directory)
Goto XAMPP control panel, click on Config button in front of Apache and select php.in,
Find line similar or exacly like,
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
(Semicolon means it is commented)
Remove the semicolon and replace the path with the path of dll you just copied like:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.3.2-5.4-vc9.dll"
Similarly find lines
;xdebug.remote_enable = 0 ;xdebug.remote_handler = "dbgp"
remove semicolons in front of both lines and make remote_enable = 1
xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp"
Restart Apache server.
Copy your website code under C:/XAMPP/htdocs/(your_website)/ that means your index.php should be at C:/XAMPP/htdocs/(your_website)/index.php
Open Netbeans select New project -> PHP -> PHP project from existing source and select the folder you just copied in htdocs folder. Set it to run on Local web server.
Set a breakpoint on first line of index.php and debug.
That's it.
Additional settings were suggested on various different posts but above mentioned steps worked perfectly for me.
I think what you might be missing is
xdebug.idekey=netbeans-xdebug
this is the settings I use in my php.ini
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.remote_autostart=false
Read the installation of XAMPP 1.7.7 & Netbeans 7.1 with edditing
the php.ini file as suggested:
http://netbeans.org/kb/docs/php/configure-php-environment-windows.html
Create your PHP project in the local XAMPP directory, c:\xammp\htdocs\*yourproject*
Debug the index.php, you will see that your browser will start with additional parameters:
http://*yourproject*/index.php?XDEBUG_SESSION_START=netbeans-xdebug
Go to your Netbeans, your debugger will be started.

Resources