First of all, a digression, the black apple of NUC is really fragrant!
The company installed a black apple for the NUC. After using it for a period of time, I felt that the landline at home was tasteless and decided to start a NUC.
The integration software MxSrvs used in the company's development environment is also very easy to use.
But I still want to learn the native installation method under mac, resolutely give up the one click installation package and start tossing.
This article is installed through brew. Brew is as convenient and simple for MacOS as apt for Ubuntu. You can install brew first. Official one click installation, very simple!
Official address: https://brew.sh/
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
1. Preparation
In order to install the latest configuration, we upgrade brew in advance
brew update
2. Install php7.4
brew search php74 brew install php@74
If your system has installed other versions, the error may be as follows. Don't panic
➜ ~ brew install php@74 ==> Installing php74 from homebrew/php Error: Cannot install homebrew/php/php74 because conflicting formulae are installed. php55: because different php versions install the same binaries. Please `brew unlink php55` before continuing. //That is, your system has installed php5.5 Unlinking removes a formula's symlinks from /usr/local. You can link the formula again after the install finishes. You can --force this install, but the build may fail or cause obscure side-effects in the resulting software.
Then you can uninstall php5.5 under the current system
brew unlink php55
Profile location
The configuration files generated after installation are in / usr/local/etc/php/7.4 directory, as follows:
The php.ini location is / usr/local/etc/php/7.4/php.ini
Php-fpm.conf is located at / usr/local/etc/php/7.4/php-fpm.conf
PHP runs phpize, and PHP configures ls /usr/local/opt/php@7.4/bin
The PHP FPM location is / usr/local/opt/php@7.4/sbin/php-fpm
Check whether the installation is successful
lsof -Pni4 | grep LISTEN | grep php
//As a result, the installation is successful php-fpm 604 sandyliao 8u IPv4 0x71e9686149e1591f 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 692 sandyliao 9u IPv4 0x71e9686149e1591f 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 693 sandyliao 9u IPv4 0x71e9686149e1591f 0t0 TCP 127.0.0.1:9000 (LISTEN)
Restart php
If you change the configuration, you need to restart php
brew services restart php
3. Install Nginx
brew install nginx
Through homebrew, the nginx file is installed in / usr/local/etc/nginx/nginx.conf by default, and then type in the browser http://localhost:8080 , you can access the welcome interface of nginx.
to configure
vim /usr/local/etc/nginx/nginx.conf
After nginx is installed, access the local directory. The default directory is / usr / local / cell / nginx / 1.15.12/html
At the bottom of the nginx configuration file, there is a line of code that introduces all the. You can create different sites in this directory (server).
Add the following codes. See the notes for each meaning. Copy and paste the following codes directly from multiple sites, and then modify the root and server_name can restart nginx
server { listen 80; root /usr/local/etc/nginx/www/cat/public; #Project file address index index.php index.html index.htm; server_name blog.e9china.net; #Local domain name. You want to define it in host location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
After the configuration is completed, we can restart nginx to make the configuration effective:
nginx -s reload
Nginx command:
//Test the configuration for syntax errors nginx -t //Reload configuration | restart | stop | exit nginx nginx -s reload|reopen|stop|quit
4. Install MySQL
//Direct installation brew install mysql@5.7
Set the startup and self startup of MySQL:
ln -sfv /usr/local/opt/mysql@5.7/*.plist ~/Library/LaunchAgents /Users/wangteng/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist -> /usr/local/opt/mysql@5.7/homebrew.mxcl.mysql@5.7.plist
Add environment variable
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"
After adding environment variables, don't forget to make them take effect
Then start mysql
mysql.server start
Test whether the database is installed successfully
mysql -u root -p //Because no password is set, press enter twice
View network monitoring
$ netstat -nat | grep LISTEN tcp4 0 0 127.0.0.1.3306 *.* LISTEN tcp4 0 0 127.0.0.1.9000 *.* LISTEN tcp4 0 0 *.80 *.* LISTEN tcp4 0 0 *.8080 *.* LISTEN tcp4 0 0 127.0.0.1.63342 *.* LISTEN tcp4 0 0 127.0.0.1.30100 *.* LISTEN tcp4 0 0 127.0.0.1.55154 *.* LISTEN tcp4 0 0 127.0.0.1.6942 *.* LISTEN tcp6 0 0 *.49159 *.* LISTEN tcp4 0 0 *.49159 *.* LISTEN tcp6 0 0 fe80::aede:48ff:.49156 *.* LISTEN tcp6 0 0 fe80::aede:48ff:.49155 *.* LISTEN tcp6 0 0 fe80::aede:48ff:.49154 *.* LISTEN tcp6 0 0 fe80::aede:48ff:.49153 *.* LISTEN
At this point, the environment of Nginx+Mysql+PHP is installed. After a lap, I decided to reinstall MxSrvs. Well, it smells good.