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
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 lnmpmkdir /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
Now we finished the installation of LNMP.
Create a domain on host machine
a. Run notepad by administrator privilege
b. Open hosts file: C:\Windows\System32\drivers\etc\hosts
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.
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”,Create database for my website
- name: project1
- user: project1
- password: 0WkWy2dIHhcLfLKs
Press any key to start create virtual host
Now, we write an index.php file with following content
vim /home/wwwroot/project1.abc.com/index.phpNow, we can access the website on host machine by http://project1.abc.com/
b) LNMP status management
lnmp {restart | start |stop}
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}
Operation MySQL on host machine
a. allow all machine access database by rootexecute mysql –u root –p, and give the password to login mysql
use mysql database, and execute update statement.
b. restart the LNMP
c. open MySQL Workbench on host machine, create a new server. Give a name for the server, and provide the username, password, and port.
Press test connection
Ok, MySQL database connected. Press “OK” to save the server information.
click the server block, then we can operate the database now
Now, we can add this server to Phpstorm as remote server. Write code on windows and run in centos.