


Detailed explanation of the steps to build LNMP development environment under Mac OS
This article mainlyintroduces the steps to build an LNMP development environment under Mac OS. The article introduces the step-by-step steps in very detail and has certain reference value for everyone. Friends who need it can follow Let’s take a look together.
1. Overview
Everyone should know that LNMP stands for: LinuxNginx+# under the system ##MySQL+PHP is a website server architecture. Linux is the collective name for a class of Unix computer operating systems and is currently the most popular free operating system. Representative versions include: debian, centos, ubuntu, fedora, gentoo, etc. Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. Mysql is a small relational database management system. PHP is a scripting language that is executed on the server side and embedded in HTML documents. These four kinds of software are all free and open source software. When combined together, they become a free, efficient, and scalable website service system. Let’s take a look at the details of this article.
2. Install Homebrew
yum command of centOS is the same as the
apt-get command of ubuntu. Through the
brew command, we can quickly install some software packages.
The command to install Homebrew using the command line is as follows:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew doctor to check if there is a conflict, and then use
brew update && brew upgradeUpgrade brew.
3. Install nginx
brew install nginx
sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/ sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo nginx
configuration file The listening port is 8080, so make a request to port 8080 first:
curl -IL http://www.php.cn/:8080
HTTP/1.1 200 OK Server: nginx/1.9.1 Date: Fri, 29 May 2015 14:50:47 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Fri, 29 May 2015 14:40:47 GMT Connection: keep-alive ETag: "5444dea7-264" Accept-Ranges: bytes
sudo nginx //启动nginx sudo nginx -s reload|reopen|quit //重新加载|重启|退出
4. Install php-fpm
brew tap homebrew/dupes brew tap homebrew/php
brew install php56 --whitout-apache --with-imap --with-tidy --with-debug --with-pgsql --with-mysql --with-fpm
$PATH:
# 如果使用bash的话 vim ~/.bash_profile export PATH="/usr/local/sbin:$PATH" source ~/.bash_profile # 如果使用ZSH的话 vim ~/.zshrc export PATH="/usr/local/sbin:$PATH" source ~/.zshrc
mkdir -p ~/Library/LaunchAgents ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
lsof -Pni4 | grep LISTEN | grep php
php-fpm 27578 wenzhiquan 9u IPv4 0xf29f8b26c08fc27 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 27628 wenzhiquan 0u IPv4 0xf29f8b26c08fc27 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 27629 wenzhiquan 0u IPv4 0xf29f8b26c08fc27 0t0 TCP 127.0.0.1:9000 (LISTEN) php-fpm 27630 wenzhiquan 0u IPv4 0xf29f8b26c08fc27 0t0 TCP 127.0.0.1:9000 (LISTEN)
5. Install MySQL
brew install mysql
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql_secure_installation
> Enter current password for root (enter for none): //默认没有密码,直接回车即可 > Change the root password? [Y/n] //是否更改root密码,选择是,然后输入并确认密码 > Remove anonymous users? [Y/n] //是否删除匿名用户,选择是 > Disallow root login remotely? [Y/n] //是否禁止远程登录,选择是 > Remove test database and access to it? [Y/n] //是否删除test数据库,选择是 > Reload privilege tables now? [Y/n] //是否重载表格数据,选择是
mysql -u root -p
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exit //输入exit退出数据库
6. Configure nginx
mkdir -p /usr/local/etc/nginx/logs mkdir -p /usr/local/etc/nginx/sites-available mkdir -p /usr/local/etc/nginx/sites-enabled mkdir -p /usr/local/etc/nginx/conf.d mkdir -p /usr/local/etc/nginx/ssl sudo mkdir -p /var/www sudo chown :staff /var/www sudo chmod 775 /var/www
vim /usr/local/etc/nginx/nginx.conf
worker_processes 1; error_log /usr/local/etc/nginx/logs/error.log debug; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /usr/local/etc/nginx/logs/access.log main; sendfile on; keepalive_timeout 65; index index.html index.php; include /usr/local/etc/nginx/sites-enabled/*; }
vim /usr/local/ect/nginx/conf.d/php-fpm
location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
vim /usr/local/ect/nginx/sites-enabled/default
server { listen 80; server_name localhost; root /var/www/; access_log /usr/local/etc/nginx/logs/default.access.log main; location / { include /usr/local/etc/nginx/conf.d/php-fpm; } location = /info { allow 127.0.0.1; deny all; rewrite (.*) /.info.php; } error_page 404 /404.html; error_page 403 /403.html; }
Summary
The above is the detailed content of Detailed explanation of the steps to build LNMP development environment under Mac OS. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Introduction: In this article, this website will introduce to you the relevant content about the Mac keyboard not responding when entering passwords. I hope it will be helpful to you, let’s take a look. How to solve the problem that the password cannot be entered on the Apple Mac system? You can also try to connect this keyboard to other computers to see if it works normally. If the same problem occurs on another computer, it's most likely a fault with the keyboard itself. You may consider replacing the keyboard or repairing it. The first time you log in to Alipay with your Mac computer, you will find the login interface and cannot enter your password. The password input field displays: "Please click here to install the control", so Alipay login requires the installation of security controls. Security controls can encrypt and protect the information you enter (amount, password, etc.) to improve account security. Tie

Many Mac users tend to keep the default name of their device and may never consider changing it. Many people choose to stick with the name from the initial setup, such as "Johnny's MacBook Air" or simply "iMac." Learning how to change the name of your Mac is a very useful skill, especially when you have multiple devices, as it can help you quickly distinguish and manage them. Next, we will teach you step by step how to change the computer name, host name and Bonjour name (local host name) in macOS system. Why should you change your Mac name? Changing the name of your Mac can not only show your personality, but also help improve the user experience: Personalize your Mac: The default name may not be to your taste, change it to a name you like.

Introduction: In this article, this website will introduce to you the relevant content about forgetting the password of the Mac installation program. I hope it will be helpful to you, let’s take a look. What to do if you forget your password for Apple computer installation software. First, find iCloud in the phone settings and click to open it. Next, enter your account number and password. There is a line of small words below the login button that prompts you if you have forgotten your ID or password. Click this option. Normally, after you enter an incorrect password multiple times on the login interface, your MacBook Pro will prompt you to use your bound Apple ID to reset your password. You only need to follow the steps prompted by the system to complete the password reset. 3. First shut down your Mac, then restart it. While pressing the power button, immediately press and hold com on the keyboard.

Preface: Today, this site will share with you the relevant content about installing pkg files on Mac. If it can solve the problem you are facing now, don’t forget to follow this site and start now! The previous version of macos pkg cannot be installed to upgrade the operating system: If your laptop is using an older operating system version, it is recommended to upgrade to the latest operating system version. Because older versions may not support installation of the latest macOS system. Select "Erase" in Disk Utility, then select the Macos extension in the format, do not check the encryption option, and do not select the apfs format, and finally click the "Erase" button to solve the problem of being unable to complete the macOS installation. Drag the application's icon to the file starting with App

Recently, some friends have consulted the editor about how to set up WeChat Mac to automatically convert voice messages into text. The following is a method for setting up WeChat Mac to automatically convert voice messages into text. Friends in need can come and learn more. Step 1: First, open the Mac version of WeChat. As shown in the picture: Step 2: Next, click "Settings". As shown in the picture: Step 3: Then, click "General". As shown in the picture: Step 4: Then check the option "Automatically convert voice messages in chat to text". As shown in the picture: Step 5: Finally, close the window. As shown in the picture:

Introduction: This article is here to introduce you to the relevant content of cutting files to the hard disk on Mac. I hope it will be helpful to you, let’s take a look. How to Export Photos to a Mobile Hard Drive on a Mac Computer You can use the Finder or Photos application to export photos to a mobile hard drive. When using Finder to export photos, first make sure the mobile hard drive is connected to the Mac and is successfully recognized by the Mac. The steps to transfer photos from Mac to hard drive are simple: first, connect the mobile hard drive to the computer, and then open the [Launcher] icon. Then, find and click the [Photos] icon in the pop-up window. In the opened [Photos] window, hold down the [Shift] key

Preface: This article is here to introduce you to the relevant content about the mac black apple boot method. I hope it will be helpful to you, let’s take a look. Black Apple OC boot quick configuration tutorial 1. After entering the loverconfigurator software interface, click on the "Boot Parameters" setting. The default boot volume name is set to the disk name that was erased when installing the Black Apple system. But Benjuannai? 0, then click Save in the lower right corner, restart the computer, and replace the lover boot interface with the Apple logo boot interface. Secure Boot effectively prevents unsigned bootloaders from booting from any internal disk or USB drive. However, Clover or OC boot does not support the secure boot function. To start

Introduction: This article will introduce to you the relevant content about the mac configuration file not taking effect. I hope it will be helpful to you, let's take a look. The solution to the problem that environment variables cannot take effect under Mac. After configuring environment variables in the Mac system, it is found that they are only effective in the current terminal and will become invalid once the terminal is switched. After inquiry, it was found that the Mac system is pre-installed with a tool called ultimate shell-zsh, and the reading of environment variables needs to be set in the .zshrc file. 2. In order for our configuration file to take effect, we can only add the above configuration in .zshrc. If you don’t make the above settings, you will find that it will only take effect every time you source ~/.bash_profile. Re-open z next time.
