Mac configuration php54+php via MacPorts fpm+nginx+mysql5.5

Source: Internet
Author: User
Tags fpm install php php development environment phpinfo

Using MacPorts to configure the PHP development environment (php54+php FPM+NGINX+MYSQL55), you first need to install port, Access: http://www.macports.org/install.php, download the source code directly: Https://distfiles.macports.org/MacPorts/MacPorts-2.1.3.tar.gz.

Install port:

1. Tar xzvf macports-2.1.3.tar.gz Decompression

2. CD MacPorts-2.1.3

3./configure && make && sudo make install

This will install port.

4. VI ~/.bash_profile

Press I button to enter the editing mode, sticky the following text:

Export Path=/opt/local/bin: $PATH

Press ESC to exit edit mode, press: Key again enter Wq save exit.

Now we can use port very conveniently.

Install PHP:

1. Port info PHP listing the supported PHP information, you can choose the corresponding version of the installation, I choose PHP54 this version.

2. Sudo port install php54 php54-fpm php54-mysql php54-mbstring php54-mcrypt php54-sockets php54-curl can increase or decrease as needed

3. cd/opt/local/etc/php54/

4. sudo cp./php-fpm.conf.default./php-fpm.conf

5. sudo cp./php.ini-development/php.ini can be replaced with php.ini-production as needed.

6. VI ~/.bash_profile plus the following elements:

#php-FPM
Alias fpm_start= ' sudo launchctl load-w/library/launchdaemons/org.macports.php54-fpm.plist '
Alias fpm_stop= ' sudo launchctl unload-w/library/launchdaemons/org.macports.php54-fpm.plist '
Alias Fpm_restart= ' Fpm_stop; Fpm_start '

7. Open a new command window, enter: FPM_START,PHP-FPM began to run, you can use the top command to view or use PS-E | grep php-fpm view.

This way, PHP is already done.

Nginx:

1. Sudo port install Nginx

2. VI ~/.bash_profile plus the following elements:

# Nginx
Alias nginx_start= ' sudo launchctl load-w/library/launchdaemons/org.macports.nginx.plist '
Alias nginx_stop= ' sudo launchctl unload-w/library/launchdaemons/org.macports.nginx.plist '
Alias Nginx_restart= ' Nginx_stop; Nginx_start; '

3. cd/opt/local/etc/nginx/

4. sudo cp fastcgi.conf.example fastcgi.conf so on and so on, put those with a. example suffix to a file that has no. example as the suffix.

5. Sudo vi nginx.conf found

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 This section, the content changed to this way:

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
Root share/nginx/html;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/opt/local/share/nginx/html$fastcgi_script_name;
Include Fastcgi_params;
}

In fact, is to remove the front # and changed the Fastcgi_param script_filename/opt/local/share/nginx/html$fastcgi_script_name;

6. The nginx_start can be activated.

7. cd/opt/local/share/nginx/html/

8. VI phpinfo.php Add the following content:

<?php phpinfo ();

9. Access via browser: http://localhost/phpinfo.php complete.

MYSQL:

1. Sudo port install mysql55 then set the database according to the content after installation

2. VI ~/.bash_profile Plus Following:

#mysql
alias mysql_start= ' sudo launchctl load-w/library/launchdaemons/ Org.macports.mysql55-server.plist '
alias mysql_stop= ' sudo launchctl unload-w/library/launchdaemons/ Org.macports.mysql55-server.plist '
alias mysql_restart= ' mysql_stop mysql_start '

3. Mysql_start

4. Sudo vi/opt/local/ect/mysql55/my.cnf!include/opt/local/etc/mysql55/macports-default.cnf this line, plus: [mysqld_ Safe] Socket =/tmp/mysql.sock, otherwise the MySQL command can be connected, the tool is not connected.

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.