PHP development environment configuration for mac computers

Source: Internet
Author: User
Tags php development environment php editor
PHP development environment configuration for mac computers

After just a year, there were not many projects. The boss told us to learn more other things during this leisure time. so I learned PHP knowledge with another iOS partner, but encountered one problem: that is, the php environment configuration of the mac computer. So I sorted out the configuration methods and hoped that later learners would be able to get started faster, rather than just half a day as we did.

What do I need?
  1. Install the web server;
  2. Install PHP;
  3. Install databases, such as Navigate Premium and MySQL.

Because the mac OS X system already comes with apache and php, you only need to create a. php file and upload it to the web Directory. The server automatically parses them. Therefore, you do not need to compile or install any additional tools. The steps are as follows.

  • Apache configuration 1. you need to manually enable the apache service. open the terminal and enter the following command: sudo apachectl start. after you manually enable the service, enter localhost or 127.0.0.1 in the browser and "It works !" Indicates that the Apache service is successfully enabled. for example:

    It works.png

    2. modify the Apache configuration file. enter the following command in the terminal: sudo vim/etc/apache2/httpd. conf, and enter the computer password to go to the editing page. Find # LoadModule php5_module libexec/apache2/libphp5.so, remove the preceding annotator "#" (this involves some mac terminal commands to understand some basic commands. Here, Press I to enter the editing mode and press Esc to exit the editing mode, then, enter wq to exit vim and save the modification. for example:

    Config.png

    3. after the last two steps, enter the command: sudo apachectl restart on the terminal. then we can restart Apache. Apache has been configured. 4. a simple "hello word!" can be written below !" Php program. The default root directory of Mac OS Apache2:/Library/WebServer/Documents; we can create a new directory in this directory. php file, but before that, we 'd better install a php Editor. Otherwise, it would be less convenient to use the vim editor. I use Sublime Text2, which can be downloaded from the Sublime Text official website. Open the terminal and enter two commands: touch/Library/WebServer/Documents/hello. phpopen/Library/WebServer/Documents/hello. php.

Hello.png

  • I will not talk about the specific installation of the database (Navigate Premium). There are many tutorials on the Internet; start MySQL Server

    Mysql.png

Create database

Nav.png

Do not enter the password:

Database.png

Now the environment is ready. you can write a program !!! The installation and writing of databases is relatively simple, mainly because there are a lot of online tutorials and different developers use different tools.

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.