PHP Laravel Framework Usage Issues summary and solution ____php

Source: Internet
Author: User

Laravel as one of the most popular PHP MVC frameworks on the market, there are many developers who use Laravel. Recently contacted the Laravel framework, but also encountered some problems, here experience and the solution to record the following, I hope to encounter the same problem developers to help. problem One: Apache server does not start in multiple environments

Using a PHP integrated installation environment such as WAMP or XAMPP, you encounter an Apache server that cannot be started, with the following error prompts:

19:30:45 [Apache] attempting to start Apache app ...
19:30:45 [Apache] status change detected:running
19:30:50 [Apache] status change detected:stopped
19:30:50 [Apa Che] error:apache shutdown unexpectedly.
19:30:50 [Apache] This is due to a blocked port, missing dependencies,
19:30:50 [Apache] improper privileges, a CR Ash, or a shutdown by another method.
19:30:50 [Apache] Press the Logs button to view error Logs and check
19:30:50 [Apache] the Windows Event Viewer for mo Re Clues
19:30:50 [Apache] If You are need, copy and post this is
19:30:50 [Apache] entire log window on the FO Rums

From the above error hint can be seen is the problem caused by port occupancy, from the apache/conf/httpd.conf profile to view the listening port, the default is 80 port, that is, the browser default port.

Windows System solutions:

Step one: Open the command prompt and use the command Netstat-ano to view the port occupancy.
Command: Netstat-ano|findstr "80" to view the occupancy of the specified port 80.

From the diagram we can see that the 80-port state is lisening with a process pid of 118856.

Step two: Knowing the process number, you can find the corresponding process by looking at the Task Manager service, or by using the command tasklist to list the processes for confirmation.
Command: Tasklist|findstr "118856"

Httpd.exe is the Apache related program, because I installed the machine at the same time Wamp, so the httpd.exe process is actually WAMP Apache process, which occupies 80 ports, so the XAMPP Apache service can not be restarted.

Step three: After you locate the process that occupies the Apache port, use the command to terminate the process.
Command: taskkill/f/t/im httpd.exe
Forces the termination of a process with an image name of Httpd.exe and any child processes that are started by this.
or use the command: Taskkill/pid 118856
Terminate the process with the PID number.

Turn on the XAMPP Control Panel restart the Apache service and start the success as shown in:

Linux system, you can use the following command (here with nginx examples)

To view port occupancy:

NETSTAT-ANP | grep 80



View the installation directory for the process number corresponding process

Ps–ef|grep 33308

To view the port usage of the Nginx process

Ps–aux|grep Nginx


Ps–aux|grep 42355

After the process number is determined, use the KILL command to terminate the process. Command format: Kill [signal or option] PID (s)

Kill–l can view all signal lists

Sigterm-This signal requests a process to stop running. This signal can be ignored. Processes can be shut down for a period of time, and the normal shutdown of a program typically takes a while to save progress and release resources. In other words, it is not forced to stop.

SIGKILL-This signal forces the process to stop running immediately. The program cannot ignore this signal, and the unsaved progress will be lost.

The default signal (when not specified) is sigterm. When it does not work, you can use the following command to force a kill off a process:



Kill-9 PID

(Here "-9" stands for the Sigkill signal)

Terminate multiple processes at the same time:

Kill-9 PID1 PID2 PID3

The termination command for the above Nginx process is:

Kill-9 42355.

In addition to the way the query kills the process after the port is occupied, you can add and modify the listening port so that you do not terminate the process of the associated port and do not affect the normal use of the existing program process. The configuration files that Apache needs to modify are as follows:

Default 80 port, modifying configuration file/apache/conf/httpd.conf
HTTPS default 443 port, modifying configuration file/apache/conf/extra/httpd-ssl.conf

Nginx's port number modification, the setting is simpler, here needless to say more. Issue Two: The page appears cyclic redirection

First of all to ensure that the relevant file configuration is not a problem, there are still circular redirection prompts. Look at the configuration file first.
Configuration file/apache/conf/extra/httpd-vhosts.conf Configuration content:

Namevirtualhost *:80

<virtualhost *:80>
   documentroot "F:/xampp/htdocs"
ServerName localhost </VirtualHost>

<virtualhost *:80>
    DocumentRoot "F:/xampp/htdocs/"
    ErrorLog "logs/" "
    customlog" Logs/ "Common
</ Virtualhost>

Then the local host file set the corresponding relationship, configuration completed. Then access the domain name, the following error image:

Starting with the entry file public/index.php, the step-by-step tracker is found to be due to permissions issues. Specific questions to locate the file location:
F:\xampp\htdocs\\vendor\laravel\framework\src\Illuminate\Foundation\ providerrepository.php

Code block:

     * Write The service manifest file to disk.
     * *
     @param  array  $manifest
     * @return Array
    /Public Function writemanifest ($manifest)
        $path = $this->manifestpath. " /services.json ';

        $this->files->put ($path, Json_encode ($manifest, Json_pretty_print));

        return $manifest;

The file directory does not exist or the folder does not have writable permissions, which causes the Writemanifest method write configuration to fail, thus throwing an exception error (App/controllers/errorcontroller), The exception-handling method in my project is to jump to/error?code=201.


Check that the App\storage\meta\services.json directory exists and check the Write permissions for the directory. If you want to guarantee write permissions first in a Linux environment, make sure SELinux is allowed to write in this directory. Action steps are as follows:
1) Change the owner of the App/storage directory

Chown Apache:apache App/storage

2) Change App/storage directory permissions

Chmod-r 775 App/storage

3) Prohibit SELinux restrictions on App/storage directory permissions

Su-c "Chcon-r-h-t httpd_sys_script_rw_t [fullpath]/app/storage"]


Setsebool-p httpd_unified 1
question three: Error in exception handler or failed to open stream:permission denied in Storage/meta/services.json

The problem is due to a lack of permissions on the file directory. Some servers may disallow permissions on some directories for security reasons. Solutions can be referred to:

Chgrp-r www-data app/storage (chgrp-r Apache App/storage)

Or with Chown.

Chown-r: Www-data app/storage

On Mac, the above commands did not work. However, this command did:

(Replace _www with your Apache server name if necessary)

Or with chmod.

Chmod-r 775 App/storage

Changing the server owner (usually Apache or www-data, depending on the operating system and different names) is more secure than opening the file to the user, generally 775 of the permissions are sufficient.

From the Laravel web site:

Laravel may require one set of permissions to is configured:folders within app/storage require write access by the Web SE RVer.

Finally, one thing to be particularly aware of is installing the newer version of the PHP installation package as much as possible . Laravel 5.0 requirements for the PHP version are >=5.4,laravel 5.1 requiring PHP version >=5.5.9. PHP 5.4 is the last version to support Windows XP and Windows 2003. It has been confirmed that Windows XP is no longer supported from PHP5.5, and you may have to upgrade WINDOWS7/8.

Reference articles:

Services.json failed to open Stream:permission denied in Laravel 4
Error in exception handler. -Laravel
Quickly install and run Laravel 5.x on Windows
4 effective Methods to Disable SELinux temporarily or permanently
Disable SELinux for only apache/httpd in Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: