search
HomeBackend DevelopmentPHP Tutorialwindows8 configure homestead and laravel development environment

Prepare toolsGenerally speaking, configuring the development environment on Windows is a very difficult task. The emergence of vagrant is a benefit for our developers. It has greatly reduced the complexity of our configuration, but although it has been reduced, we still need to configure some manually. Without further ado, let’s get to the point. First, let’s talk about what is needed: 1. Windows has already installed git. If not, click here 2. You need to install php (only php is needed, nothing else is needed, and the openssl extension is enabled in php.ini). 3. Then you need composer, vagrant, virtualbox and a homestead. The above is all the software required to configure the environment. Now let’s configure the environment. Configuration processIn short, Homestead is a Linux virtual machine based on virtualbox that is officially pre-packaged by Laravel. A series of software is installed in this virtual machine, including Nginx, PHP 5.6, MySQL, Postgres, Redis, Memcached, sufficient for laravel development. This virtual machine can be easily started, destroyed, and rebuilt. It basically won't mess up your existing operating system. Let’s briefly talk about the installation process: Composer installationComposer is a dependency management tool for PHP, which can easily manage a series of extensions required in the laravel development process. It's a very important tool. Just open the installation package downloaded above and install it. If an error occurs, it is probably because ssl is not enabled in php. Re-enable it and the installation will be successful. Vagrant and VirtualBox installationBoth of these are also installed based on graphical interfaces, just install them directly. It should be noted that to use Virtualbox, you need to enable hardware virtual software support (VT-X) and enable it in the BIOS. Configuring the virtual machineThe required software has basically been installed. The next step is to configure the virtual machine. 1. Add homestead to virtualbox and run the following code in the terminal (path is the path where you placed homestead): shell vagrant box add laravel/homestead pathhomestead.box 2. Install the homestead command line tool: shell composer global require "laravel/homestead=~2.0" Usually there will be an SSL error here. This is caused by our special national conditions. You know, the solution is to use domestic mirrors and follow the method here in composer. Add the domestic image to json and execute the above code again to successfully complete the installation.
  • Initialize homestead shell homestead init After execution, C:Users.homestead is generated, and the homestead configuration file is inside.

  • Modify Homestead.yaml

    ```shell

    <code>ip: "192.168.10.10"
    memory: 2048
    cpus: 2
    
    authorize: ~/.ssh/id_rsa.pub
    
    keys:
        - ~/.ssh/id_rsa
    
    folders:
        - map: ~/LaravelWorkspace
          to: /home/vagrant/Code
    
    sites:
        - map: homestead.app
          to: /home/vagrant/Code/laravel/public
              hhvm: true
    
    databases:
        - homestead
    
    variables:
        - key: APP_ENV
          value: local
    </code>

    ``` LaravelWorkspace is a code sharing area, and the modifications made here can be immediately reflected in the virtual machine. Others include site and database configurations. For specific details, you can go to laravel's official website for detailed introduction. Then the above ssh key must be generated through gitbash, as follows:

    shell ssh-keygen -t rsa -C "your@email.com" That site needs to add the following configuration to the C:WindowsSystem32driversetchosts file in Windows : shell 192.168.10.10 homestead.app

  • Start the virtual machine

    shell homestead up After executing the above code for a while, you should be able to see the virtual machine being started, and then use http://homestead.app :8000 or 192.168.10.10 to visit the homepage of your laravel project.

  • Homestead ssh problem Originally the environment has been configured in the previous step, but on Windows, the command line capabilities are really limited and there is no way to support development needs, because the Windows command line does not support ssh access. This is really painful. Of course, you can also use other ssh tools to access the virtual machine (the username and password are both vagrant). Here I recommend a more powerful tool for you, which is Chrome's secure shell. Have you ever seen the terminal on the web page? You can use this to access ssh very conveniently, and our development needs are basically met here.

    The above introduces the configuration of homestead and laravel development environment in Windows 8, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

    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
    What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

    ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

    Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

    The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

    PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

    PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

    PHP Email Security: Best Practices for Sending EmailsPHP Email Security: Best Practices for Sending EmailsMay 08, 2025 am 12:16 AM

    ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

    How do you optimize PHP applications for performance?How do you optimize PHP applications for performance?May 08, 2025 am 12:08 AM

    TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

    What is dependency injection in PHP?What is dependency injection in PHP?May 07, 2025 pm 03:09 PM

    DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

    Best PHP Performance Optimization TechniquesBest PHP Performance Optimization TechniquesMay 07, 2025 pm 03:05 PM

    PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

    PHP Performance Optimization: Using Opcode CachingPHP Performance Optimization: Using Opcode CachingMay 07, 2025 pm 02:49 PM

    OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad

    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

    WebStorm Mac version

    WebStorm Mac version

    Useful JavaScript development tools

    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.

    VSCode Windows 64-bit Download

    VSCode Windows 64-bit Download

    A free and powerful IDE editor launched by Microsoft

    SublimeText3 Linux new version

    SublimeText3 Linux new version

    SublimeText3 Linux latest version

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment