I have been using laravel framework version 10 for in-house web application development, which will run on intranet not internet.
I downloaded and installed xampp having php version 8.1.17, i downloaded and install composer with selecting php.exe of php version 8.1.17 installed at "C:/xampp/php"
after that i have downloaded laravel 10 project using composer at path "C:/xampp/htdocs/project".
I have valid ssl certificate for my intranet domain for example abc.example.com, now at "C:/xampp/apache/extra/httpd-vhosts.conf", i have placed following code to configure ssl certificate
<VirtualHost abc.example.com:444>
DocumentRoot "C:/xampp/htdocs/project"
ServerName abc.example.com:444
SSLEngine on
SSLCertificateFile "conf/ssl.crt/22112022.cer"
SSLCertificateKeyFile "conf/ssl.crt/22112022-rsa.key"
SSLProtocol all -SSLv3
<Directory "C:/xampp/htdocs/project">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Now i am running my laravel project with command "php artisan serve --host=abc.example.com --port=444"
when i am accessing my application using url "https://abc.example.com:444/", it is showing directory listing of my project at "C:/xampp/htdocs/project", Please check image below :
My laravel project is not executing, instead directory listing is displaying, ssl is resolving as expected. can anyone guide me with this ? i am new to laravel but not xampp.
After trying for many days with apache,i was reaching no where, so i tried with nginx, and it is working as expected, below is my nginx configuration :
server {
listen 443 ssl;
#server_name localhost;
server_name exmaple.com;
client_max_body_size 11M;
#more_clear_headers Server;
server_tokens off;
ssl_certificate 22112022.cer;
ssl_certificate_key 22112022-rsa.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
error_page 404 /html/404.html;
location = /404.html {
root /nginx-1.24.0/html;
internal;
}
error_page 405 500 502 503 504 /500.html;
location = /500.html {
root /nginx-1.24.0/html;
internal;
}
root "D:/xampp/htdocs/project/public";
index index.php;
if ($request_method ~ ^(OPTIONS)$ )
{
return 405;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
}
here you can see, i have set laravel project public folder path as root, with nginx you need to use fastcgi for php, before starting nginx you need to start fastcgi, for that create bat file as per below
@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=D:\xampp\php8.1.17;%PATH%;
SET PHP_FCGI_MAX_REQUESTS=0;
start D:\xampp\php8.1.17\php-cgi.exe -b 127.0.0.1:9000 -c D:\xampp\php8.1.17\php.ini
pause;
Make sure port you are using for fastcgi is free and don't used by any other service, same port need to configure in nginx.conf fastcgi_pass.
run batch file and then start nginx with command start nginx and browse url https://example.com you will see it is working as expected.