Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MahmoudAdelAli's avatar

should i use public or artisan serve in production ?

hello , i have a app and i always when i upload the project i open it with /public/etc .... using htaccess i make it look like www.example.com without /public , but when i use any project from github the public directory have many problems like

The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/crm/crm/Laravel-Smarthr/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: file_put_contents(/var/www/html/crm/crm/Laravel-Smarthr/storage/framework/sessions/Czfh5l7sWAIZaT8O6K5Djaz3L75SdOaFaPo4jIgw): Failed to open stream: Permission denied Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} 

but when i run php artisan serve it's work correctly , so what i should do ?

0 likes
6 replies
Sergiu17's avatar

looks like you don't have permission to write to storage folder, update permission with

sudo chmod -R 755 storage

answer for question form the title. You can't use artisan serve for production.

You should configure your root document to be /public

2 likes
MahmoudAdelAli's avatar

@Sergiu17 after i use

sudo chmod -R ugo+rw storage

the error are goes , but the dashboard is notfound 404 :D - but in serve it works

MahmoudAdelAli's avatar

@Sergiu17

php artisan route:list

so the result

+--------+-----------+---------------------------------------+----------------------------+----------------------------------------------------------------------+----------------------------------------------------------------+
| Domain | Method    | URI                                   | Name                       | Action                                                               | Middleware                                                     |
+--------+-----------+---------------------------------------+----------------------------+----------------------------------------------------------------------+----------------------------------------------------------------+
|        | GET|HEAD  | /                                     |                            | Closure                                                              | web                                                            |
|        | GET|HEAD  | _debugbar/assets/javascript           | debugbar.assets.js         | Barryvdh\Debugbar\Controllers\AssetController@js                     | Barryvdh\Debugbar\Middleware\DebugbarEnabled                   |
|        |           |                                       |                            |                                                                      | Closure                                                        |
|        | GET|HEAD  | _debugbar/assets/stylesheets          | debugbar.assets.css        | Barryvdh\Debugbar\Controllers\AssetController@css                    | Barryvdh\Debugbar\Middleware\DebugbarEnabled                   |
|        |           |                                       |                            |                                                                      | Closure                                                        |
|        | DELETE    | _debugbar/cache/{key}/{tags?}         | debugbar.cache.delete      | Barryvdh\Debugbar\Controllers\CacheController@delete                 | Barryvdh\Debugbar\Middleware\DebugbarEnabled                   |
|        |           |                                       |                            |                                                                      | Closure                                                        |
|        | GET|HEAD  | _debugbar/clockwork/{id}              | debugbar.clockwork         | Barryvdh\Debugbar\Controllers\OpenHandlerController@clockwork        | Barryvdh\Debugbar\Middleware\DebugbarEnabled                   |
|        |           |                                       |                            |                                                                      | Closure                                                        |
|        | GET|HEAD  | _debugbar/open                        | debugbar.openhandler       | Barryvdh\Debugbar\Controllers\OpenHandlerController@handle           | Barryvdh\Debugbar\Middleware\DebugbarEnabled                   |
|        |           |                                       |                            |                                                                      | Closure                                                        |
|        | GET|HEAD  | _dusk/login/{userId}/{guard?}         | dusk.login                 | Laravel\Dusk\Http\Controllers\UserController@login                   | web                                                            |
|        | GET|HEAD  | _dusk/logout/{guard?}                 | dusk.logout                | Laravel\Dusk\Http\Controllers\UserController@logout                  | web                                                            |
|        | GET|HEAD  | _dusk/user/{guard?}                   | dusk.user                  | Laravel\Dusk\Http\Controllers\UserController@user                    | web                                                            |
|        | GET|HEAD  | activity                              | activity                   | App\Http\Controllers\Admin\ActivityController@index                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | api/user                              |                            | Closure                                                              | api                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate:api                           |
|        | POST      | apply                                 | apply-job                  | App\Http\Controllers\Frontend\JobApplicationController@store         | web                                                            |
|        | GET|HEAD  | asset                                 | assets                     | App\Http\Controllers\Admin\AssetController@index                     | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | asset                                 |                            | App\Http\Controllers\Admin\AssetController@store                     | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | asset                                 |                            | App\Http\Controllers\Admin\AssetController@update                    | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | asset                                 |                            | App\Http\Controllers\Admin\AssetController@destroy                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | backup                                | laravel-backup-panel.index | Illuminate\Routing\ViewController                                    | web                                                            |
|        |           |                                       |                            |                                                                      | PavelMironchik\LaravelBackupPanel\Http\Middleware\Authenticate |
|        | GET|HEAD  | backups                               | backups                    | App\Http\Controllers\Admin\BackupsController@index                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | change-password                       | change-password            | App\Http\Controllers\Admin\ChangePasswordController@index            | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | change-password                       |                            | App\Http\Controllers\Admin\ChangePasswordController@update           | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | clear-activity                        | clear-all                  | App\Http\Controllers\Admin\ActivityController@markAsRead             | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | clients                               | clients                    | App\Http\Controllers\Admin\ClientController@index                    | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | clients                               | client.add                 | App\Http\Controllers\Admin\ClientController@store                    | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | clients                               | client.update              | App\Http\Controllers\Admin\ClientController@update                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | clients                               | client.destroy             | App\Http\Controllers\Admin\ClientController@destroy                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | clients-list                          | clients-list               | App\Http\Controllers\Admin\ClientController@lists                    | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | contacts                              | contacts                   | App\Http\Controllers\Admin\ContactController@index                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | contacts                              |                            | App\Http\Controllers\Admin\ContactController@store                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | contacts                              |                            | App\Http\Controllers\Admin\ContactController@update                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | contacts                              | contact.destroy            | App\Http\Controllers\Admin\ContactController@destroy                 | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | dashboard                             | dashboard                  | App\Http\Controllers\Admin\DashboardController@index                 | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | departments                           | departments                | App\Http\Controllers\Admin\DepartmentController@index                | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | departments                           |                            | App\Http\Controllers\Admin\DepartmentController@store                | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | departments                           |                            | App\Http\Controllers\Admin\DepartmentController@update               | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | departments                           | department.destroy         | App\Http\Controllers\Admin\DepartmentController@destroy              | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | designations                          | designations               | App\Http\Controllers\Admin\DesignationController@index               | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | designations                          |                            | App\Http\Controllers\Admin\DesignationController@update              | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | designations                          |                            | App\Http\Controllers\Admin\DesignationController@store               | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | designations                          | designation.destroy        | App\Http\Controllers\Admin\DesignationController@destroy             | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | download-cv                           | download-cv                | App\Http\Controllers\Admin\JobController@downloadCv                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | employee-leave                        | employee-leave             | App\Http\Controllers\Admin\EmployeeLeaveController@index             | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | employee-leave                        |                            | App\Http\Controllers\Admin\EmployeeLeaveController@store             | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | employee-leave                        |                            | App\Http\Controllers\Admin\EmployeeLeaveController@update            | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | employee-leave                        | leave.destroy              | App\Http\Controllers\Admin\EmployeeLeaveController@destroy           | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | employees                             | employees                  | App\Http\Controllers\Admin\EmployeeController@index                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | employees                             | employee.add               | App\Http\Controllers\Admin\EmployeeController@store                  | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | employees                             | employee.update            | App\Http\Controllers\Admin\EmployeeController@update                 | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | DELETE    | employees                             | employee.destroy           | App\Http\Controllers\Admin\EmployeeController@destroy                | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | employees-list                        | employees-list             | App\Http\Controllers\Admin\EmployeeController@list                   | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | GET|HEAD  | employees/attendance                  | employees.attendance       | App\Http\Controllers\Admin\EmployeeAttendanceController@index        | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | POST      | employees/attendance                  |                            | App\Http\Controllers\Admin\EmployeeAttendanceController@store        | web                                                            |
|        |           |                                       |                            |                                                                      | App\Http\Middleware\Authenticate                               |
|        | PUT       | employees/attendance                  |                            | App\Http\Controllers\Admin\EmployeeAttendanceController@update       | web                                                 

there's no domain

martinbean's avatar
Level 80

@mahmoudadelali When you run php artisan serve, the first line it prints to the console is:

Starting Laravel development server: http://127.0.0.1:8000

This should indicate that no, it’s not suitable for production use.

Instead, as @sergiu17 mentions, you should configure your Apache or nginx site properly. You should set the document root to be your application’s public directory. Otherwise you risk exposing sensitive files like your .env file and configuration files.

1 like
MahmoudAdelAli's avatar

@martinbean thank you i was forgot the Apache config with

<Directory "/var/www/html/crm/crm/Laravel-Smarthr/public/">
        Options Indexes FollowSymLinks MultiViews
        Require all granted
        Allow from all
        Allowoverride All
</Directory>

and i get my answer is never use serve to production

1 like
Snapey's avatar

@MahmoudAdelAli In addition to the above you need to set Document Root

DocumentRoot /var/www/html/crm/crm/Laravel-Smarthr/public/

<Directory "/var/www/html/crm/crm/Laravel-Smarthr/public/">
        Options Indexes FollowSymLinks MultiViews
        Require all granted
        Allow from all
        Allowoverride All
</Directory>
1 like

Please or to participate in this conversation.