1.4.2. PHP 5.6 Goddess Level Tutorial - Goddess Growth Environment (PHP Development Environment Configuration and Installation under Mac php5.6.x nginx mysql)

Keywords: PHP brew Nginx Attribute

Catalog

Blog directory

http://www.foxwho.com/article/24

CSDN directory

http://blog.csdn.net/fenglailea/article/details/60330101

Wind.fox

Environmental description

System: mac 10.12.3
PHP: 5.6.x
Nginx: the latest edition
mysql recommends Docker installation
redis recommends Docker installation

install

Install the dependency management tool Homebrew and execute it from the command line

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

Then you can install the software in the following format

brew install  xxxx

See Homebrew for more information

https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md

Use common Homebrew operations:
1. Add a program source (add a faucet) brew tap homebrew/php
2. Update program source brew update
3. Installation package brew install php56
4. See what parameters brew options php56 has when installing a program
5. Looking at the configuration brew config, you can see that the package is installed by default under / usr/local/Cellar
6. Search software brew search php
7. Unload or delete software brew remove php56 or brew uninstall --force php56
8. View the installed software brew list

Install PHP 5.6 (FPM mode)

Official software source

First join Homebrew's official software sources

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php

Update source

brew update

Install PHP

Choose which parameters you want to install according to the following commands

brew options php56

Then start the installation according to the selected parameters

brew install php56 \
--with-debug \
--with-homebrew-curl \
--with-homebrew-libxslt \
--with-homebrew-libressl \
--with-homebrew-libxml2 \
--with-phpdbg \
--with-imap

Phpdbg: phpdbg: a powerful tool for PHP debugging

Install PHP extensions

brew install --build-from-source php56-mcrypt php56-igbinary \
php56-redis

Commonly used extensions

php56-igbinary: serialization and deserialization
php56-mcrypt: Encryption Extension Library
php56-mongodb: Needless to say, database
php56-redis: Cached database
php56-intl: help from internationalization
php56-uuid: UUID Means Universal Unique Identification Code
php56-grpc: a rpc framework

For more extensions, please enter the following command to view

brew search php56

configuration file

/usr/local/etc/php/5.6/php.ini
 For other configuration files, go to the following directory
cd /usr/local/etc/php/5.6/

Increase error log display

vim /usr/local/etc/php/5.6/php.ini

Revised as follows

#php error log
error_log = /Volumes/work/php/php_errors.log 

Modify PHP user group

There are too many restrictions on permissions on MAC, so PHP uses the current user

vim /usr/local/etc/php/5.6/php-fpm.conf

Find the following information and modify it to

#php-fpm error log (recommended settings)
error_log = /Volumes/work/php/php-fpm.log
#The default port is 9000, which conflicts with many ports. Here it is changed to 9950.
listen = 127.0.0.1:9950
user = fox
group = admin
//If there is any problem with the modification, please restore the original as follows
#user = _www
#group = _www

fox is my current login user
admin User Group for Current User

PHP PHP-FPM startup and shutdown, etc.

start-up

Must operate with root user privileges

sudo php56-fpm start

Close

sudo php56-fpm stop

Other parameters

sudo php56-fpm

output

Usage: /usr/local/sbin/php56-fpm {start|stop|force-quit|restart|reload|status|configtest}

View phpinfo information from the command line

php -i "(command-line 'phpinfo()')"

Install Nginx

brew install nginx

nginx boot

Must operate with root user privileges

sudo nginx

nginx shut down

Must operate with root user privileges

sudo nginx -s quit

nginx other

Must operate with root user privileges

Start and close, but also support overloading configuration files and other operations

sudo nginx -s reload|reopen|stop|quit

nginx configuration file

/usr/local/etc/nginx/nginx.conf

nginx User Group User Settings

This works with PHP users and user groups

vim /usr/local/etc/nginx/nginx.conf

Find the following and modify it as follows:

#User user group
user  fox admin;

fox is my current login user
admin User Group for Current User

Other

If nginx defaults to listen on port 8080 after installation, it can be accessed

http://localhost:8080

View status. If you need root privileges to listen on port 80, run the following command

sudo chown root:wheel /usr/local/Cellar/nginx/1.10.0/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.10.0/bin/nginx

Finally, start with root privileges

sudo nginx

Install Mysql

Installation commands (I recommend docker to install mysql here):

brew install mysql

start-up

mysql.server start
mysql.server stop

After startup, the password defaults to null

docker install mysql

To be added

Install Redis

Installation commands (I recommend docker to install redis here):

brew install redis

Redis default configuration files are not allowed to run in Deamon mode, so you need to modify the configuration files first.

vim /usr/local/etc/redis.conf

Modify daemonize to yes, and then load the configuration file to start the background process

redis-server /usr/local/etc/redis.conf

docker install redis

To be added

Install other

brew install composer

Reference resources

http://avnpc.com/pages/install-lnmp-on-osx

Posted by Thikho on Tue, 11 Dec 2018 02:18:06 -0800