Use brew to install nginx + php-fpm + mysql for mac

Source: Internet
Author: User
Tags fpm install php install brew brew cask

Recently, I am playing the Mac. As a developer, the development environment is necessary. Of course, xmapp has this integration package, but how can I use the integration package for systems on mac such a tall one, so I plan to use the command to install nginx + php-fpm + mysql.
At first, I didn't know that the mac was installed with the brew management software. I installed nginx by compiling and found brew. So I deleted the nginx directory and re-installed it with brew.
Brew is not installed on mac by default. It seems that the brew command is the same as the centos yum command. You can see the following command.

Step 1 install brew

Ruby-e "$ (curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"

Install brew

There are a lot of invalid links on the internet. The above links are feasible when I install them.

Install nginx

Brew install nginx
The dependency is automatically installed for convenience.
Sudo nginx # Start the nginx service
Sudo nginx-s reload # Restart the nginx service
Configuration file path/usr/local/etc/nginx. conf
After installation, the default port is 8080.

Install mysql

Brew install mysql
The default password for mysql is null.
Mysql. server start # start the mysql service
Mysql. server stop # shut down the mysql service
Configuration file path/usr/local/Cellar/mysql/

Install php-fpm

Php installed with brew instead of built-in mac

Brew tap homebrew/dupes
Brew tap maid/homebrew-phpbr
Brew search php # query the php version. The following command php70 is the version.
Brew install php70 -- with-imap -- with-tidy -- with-debug -- with-pgsql -- with-mysql -- with-fpm
Finally, because mac comes with php, you need to modify a configuration by using the php version installed by brew.

Vi ~ /. Bash_profile
Add

Export PATH = "$ (brew -- prefix php70)/sbin: $ PATH"
The content added above php70 should be changed to your installed version

Source./. bash_profile
If no. bash_profile exists, check whether the. bashrc file exists.

Sudo php-fpm # start php-fpm
Configuration file/usr/local/etc/php/7.0/php. ini

Finally, create a website directory

Modify the nginx configuration file. The. php file is parsed using php-fpm.

Location ~ \. Php $ {
Fastcgi_intercept_errors on;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/Users/qiucarson/www $ fastcgi_script_name;
Include/usr/local/etc/nginx/fastcgi_params;
    }
Add the above configuration. Note: The/Users/qiucarson/www path above is changed to its own directory.

All configurations are completed here. You can refer to phpinfo.

LaunchRocket graphical management php-fpm nginx mysql

This article has explained how to install the php environment. If you want to install the php environment through Homebrew, refer to this article.

① Install launchrocket

The installation is very simple and can be done with one command.

Brew cask install launchrocket
Other installation methods some people on the Internet say there is a problem with the use after the installation, which is not recommended here. It is no problem to install it through the above command.

I found out how to use it on Baidu. I was also drunk and finally found out how to use launchrocket.

② Use launchrocket

[Finder] [application] [System Preference settings]



The LaunchRocket icon can be found below.

Open the graphical interface of the software, as shown in the following figure.
Note the following issues:
After I installed it, I tested and started the service and disabled the service. Then Baidu never found the problem. Suddenly, if you started the service by using commands, there was no way to control the GUI, you must use commands to close the service and start the service with launchrocket.
Related Article

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.