search
HomePHP FrameworkLaravellaravel installation and php-fpm, nginx configuration self-starting

I have always used TP for my work. This time when I was building RabbitMQ, I thought of using larave to build it. During the building process, php-fpm and nginx were configured to start automatically. Extending from one installation of laravel to other points, this article will bring you a different experience.

This article mainly focuses on the following points Introduction to each aspect

  • Install composer
  • Install laravel
  • Configure php-fpm to start automatically
  • Configure nginx to start automatically

Implementation environment of this article

  • centos 7.3
  • All operations are performed in virtual machine simulation

1. Install composer

Execute the commandcurl -sS https://getcomposer.org/installer | php After you can see the picture below

laravel installation and php-fpm, nginx configuration self-startingMove php composer.phar to the bin directory mv composer.phar /usr/local/bin/composer and rename it to composer

Why should we put this in the usr/local/bin directory? Only in this way can we use composer globally

Enter the command to check the version and see if the installation is successful. Here you can see that the version we installed is 1.10, which proves that we have successfully installed composerlaravel installation and php-fpm, nginx configuration self-starting

## 2. Install laravel

Be sure to pay attention to the requirements for PHP for the version you need to install.

Kaka uses PHP7.2 herelaravel installation and php-fpm, nginx configuration self-startingLaravel is prepared to operate in a virtual machine, so there is no separate configuration of conf, and it is operated directly in the html directory. laravel installation and php-fpm, nginx configuration self-starting

Execute installation

composer create-project --prefer-dist laravel/laravel blog "5.8.*"Check the laravle version, here Kaka installed laravel5.8 PHP The environment requires 7.2. There is no need to upgrade PHP, so there is no need to choose a higher version of laravellaravel installation and php-fpm, nginx configuration self-startinglaravel installation and php-fpm, nginx configuration self-starting

3. Access test

Use ifconfig to find out the IP address of my virtual machine. Comrades who use virtual machines, when there is no fixed IP assigned to the virtual machine, check the IP address of the virtual machine every time when connecting to xsheel or ftp. This IP address may change after the virtual machine is shut down and turned on. There have been changeslaravel installation and php-fpm, nginx configuration self-startingThen you can access it through the host machinehttp://192.168.254.135/blog/public/index.phplaravel installation and php-fpm, nginx configuration self-starting

##4. Fault Tolerance

This content will not affect local operations, nor will it affect online servers.

It uses the same environment as Kaka. Since it is a virtual machine, php-fpm may not restart after shutting down and starting up, and the following error will appear.

Don’t panic when you encounter this error, take a look Is your php-fpm enabled?laravel installation and php-fpm, nginx configuration self-starting

Execute the command

systemctl start php-fpm

Wouldn’t it be very troublesome if you have to restart every time, then we will Configure php-fpm to start automatically at boot

5. Set fpm to start automatically

PHP is installed directly using yum

To set fpm to start automatically, you only need to execute

systemctl enable php-fpm

6. Set nginx to start automatically

Adjust according to your own nginx installation location, my installation location is /usr/local/nginx/

Executecd /lib/systemd/system/

Createvim nginx.serviceand write As follows

[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true 
   [Install] 
WantedBy=multi-user.target

Set up auto-start at bootsystemctl enable nginx

The above is the detailed content of laravel installation and php-fpm, nginx configuration self-starting. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Laravel's Impact: Simplifying Web DevelopmentLaravel's Impact: Simplifying Web DevelopmentApr 21, 2025 am 12:18 AM

Laravel stands out by simplifying the web development process and delivering powerful features. Its advantages include: 1) concise syntax and powerful ORM system, 2) efficient routing and authentication system, 3) rich third-party library support, allowing developers to focus on writing elegant code and improve development efficiency.

Laravel: Frontend or Backend? Clarifying the Framework's RoleLaravel: Frontend or Backend? Clarifying the Framework's RoleApr 21, 2025 am 12:17 AM

Laravelispredominantlyabackendframework,designedforserver-sidelogic,databasemanagement,andAPIdevelopment,thoughitalsosupportsfrontenddevelopmentwithBladetemplates.

Laravel vs. Python: Exploring Performance and ScalabilityLaravel vs. Python: Exploring Performance and ScalabilityApr 21, 2025 am 12:16 AM

Laravel and Python have their own advantages and disadvantages in terms of performance and scalability. Laravel improves performance through asynchronous processing and queueing systems, but due to PHP limitations, there may be bottlenecks when high concurrency is present; Python performs well with the asynchronous framework and a powerful library ecosystem, but is affected by GIL in a multi-threaded environment.

Laravel vs. Python (with Frameworks): A Comparative AnalysisLaravel vs. Python (with Frameworks): A Comparative AnalysisApr 21, 2025 am 12:15 AM

Laravel is suitable for projects that teams are familiar with PHP and require rich features, while Python frameworks depend on project requirements. 1.Laravel provides elegant syntax and rich features, suitable for projects that require rapid development and flexibility. 2. Django is suitable for complex applications because of its "battery inclusion" concept. 3.Flask is suitable for fast prototypes and small projects, providing great flexibility.

Frontend with Laravel: Exploring the PossibilitiesFrontend with Laravel: Exploring the PossibilitiesApr 20, 2025 am 12:19 AM

Laravel can be used for front-end development. 1) Use the Blade template engine to generate HTML. 2) Integrate Vite to manage front-end resources. 3) Build SPA, PWA or static website. 4) Combine routing, middleware and EloquentORM to create a complete web application.

PHP and Laravel: Building Server-Side ApplicationsPHP and Laravel: Building Server-Side ApplicationsApr 20, 2025 am 12:17 AM

PHP and Laravel can be used to build efficient server-side applications. 1.PHP is an open source scripting language suitable for web development. 2.Laravel provides routing, controller, EloquentORM, Blade template engine and other functions to simplify development. 3. Improve application performance and security through caching, code optimization and security measures. 4. Test and deployment strategies to ensure stable operation of applications.

Laravel vs. Python: The Learning Curves and Ease of UseLaravel vs. Python: The Learning Curves and Ease of UseApr 20, 2025 am 12:17 AM

Laravel and Python have their own advantages and disadvantages in terms of learning curve and ease of use. Laravel is suitable for rapid development of web applications. The learning curve is relatively flat, but it takes time to master advanced functions. Python's grammar is concise and the learning curve is flat, but dynamic type systems need to be cautious.

Laravel's Strengths: Backend DevelopmentLaravel's Strengths: Backend DevelopmentApr 20, 2025 am 12:16 AM

Laravel's advantages in back-end development include: 1) elegant syntax and EloquentORM simplify the development process; 2) rich ecosystem and active community support; 3) improved development efficiency and code quality. Laravel's design allows developers to develop more efficiently and improve code quality through its powerful features and tools.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.