Build a Local PHP Development Environment

PHP is a widely-used, free, server scripting language, and a powerful tool for making dynamic and interactive Web pages. I will show how to build a local PHP development environment

  1. Set up LNMP
    We use the integrated installation package for our development environment.
    Create a folder named source under /home, we will put all sources file in this folder.
    and start setup the lnmp

    mkdir /home/source

    cd /home/source
    

    wget -c http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz
    tar zxf lnmp1.3-full.tar.gz && cd lnmp1.3-full
    ./install.sh lnmp

    • given the mysql root password:jXS90VERcZqqE7XP
    • yes to install InnoDB
    • select the MySQKL 5.7.11
    • use PHP 7.0.7
    • use TCMalloc as memory allocator

      App Store

      App Store

      Now we finished the installation of LNMP.

  2. Create a domain on host machine

    a. Run notepad by administrator privilege

    b. Open hosts file: C:\Windows\System32\drivers\etc\hosts

    App Store

    c. Add a domain mapping to virtual machine. We will use this domain to access our website. The IP address of virtual machine is 192.168.183.132, and I take the domain “project1.abc.com” for first project.

    App Store

  3. LNMP operations

    a) create a new website

    commend: lnmp vhost {add|list|del}

    let’s create a website: project1.abc.com
    run commend “lnmp vhost add”, input the domain for website “project1.abc.com”,

    App Store

    Create database for my website

    • name: project1
    • user: project1
    • password: 0WkWy2dIHhcLfLKs

    App Store

    Press any key to start create virtual host

    App Store

    Now, we write an index.php file with following content
    vim /home/wwwroot/project1.abc.com/index.php

    App Store

    Now, we can access the website on host machine by http://project1.abc.com/

    App Store

    b) LNMP status management

    lnmp {restart | start |stop}

    App Store

    c) MySQL status management

    /etc/init.d/mysql {start|stop|restart|reload|force-reload|status}

    d) Nginx status management

    /etc/init.d/nginx {start|stop|reload|restart}

  4. Operation MySQL on host machine
    a. allow all machine access database by root

    execute mysql –u root –p, and give the password to login mysql

    use mysql database, and execute update statement.

    App Store

    b. restart the LNMP

    App Store

    c. open MySQL Workbench on host machine, create a new server. Give a name for the server, and provide the username, password, and port.

    App Store

    Press test connection

    App Store

    Ok, MySQL database connected. Press “OK” to save the server information.

    click the server block, then we can operate the database now
    App Store

    Now, we can add this server to Phpstorm as remote server. Write code on windows and run in centos.