Linux + Nginx + Mysql + PHP Local Environment build configuration

Source: Internet
Author: User

1, first we need to download homebrew,homebrew short brew, is Mac OS X on the package management tools, can be easily installed in the Mac software or uninstall software, you can say homebrew equivalent to Linux under the Apt-get, Yum, Its official web site is http://brew.sh, open terminal input:

/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew use

Search Software: Brew search software name, such as Brew search wget

Install software: Brew install software name, such as Brew install wget

Uninstall software: Brew remove software name, such as brew remove wget

2, after installation, we download and install Nginx, open the terminal input:

Brew Install Nginx
Once installed, we can see:

OK, now we're going to start Nginx directly:

$ sudo nginx
Input: PS aux | grep Nginx, you can see that the Nginx process has started:

Now we open the browser to access 127.0.0.1 (or localhost) to see the following effect:

At this point we want this page to display as we want to display the page, how to do?

Open nginx.conf file, terminal input:

Vi/usr/local/etc/nginx/nginx.conf
Locate the following code and modify it to the following code:


server {
Listen 8080;
server_name localhost;

CharSet Koi8-r;

Access_log/usr/local/etc/nginx/logs/host.access.log main;

Location/{
Root/users/evai/web; #你存放的PHP页面路径
Index index.php;
}
}

Continue to search and modify, this code is to parse the PHP file:


Location ~ \.php$ {
Root/users/evai/web; #你存放的php页面路径
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}

After you save the file, reload the configuration and enter:

Nginx-s Reload

Nginx Common commands:

#启动 Nginx
sudo nginx
# Reload Configuration | Reboot | Stop | exit
Nginx-s Reload|reopen|stop|quit
#测试配置是否有语法错误
Nginx-t
3, the next is installed php,php in the Mac under the default installation, but bad control version, so we use brew can then install the latest version of the Mac, or even multiple versions, I installed the php5.6, the full installation path is as follows:


Brew Update
Brew Tap Homebrew/dupes
Brew Tap josegonzalez/homebrew-php
Brew Install php56--with-fpm--without-apache--without-snmp--without-apache--with-debug--with-fpm--with-intl- With-homebrew-curl--with-homebrew-libxslt--with-homebrew-openssl--with-imap--with-mysql--with-tidy

Next, add the following environment variables to the ~/.BASHRC file:

Export path= "/usr/local/bin:/usr/local/sbin: $PATH"
At the same time add php-fpm to boot:

Ln-sfv/usr/local/opt/php56/*.plist ~/library/launchagents
Launchctl Load ~/library/launchagents/homebrew.mxcl.php56.plist
Run Php-v View:

4, the last is the installation of MySQL, the same method:

Brew Install MySQL
unset Tmpdir
mysql_install_db--verbose--user= ' WhoAmI '--basedir= "$ (brew--prefix MySQL)"--datadir=/usr/local/var/mysql--tmpdir =/tmp
sudo chown-r 777/usr/local/var/mysql/
The first sentence is the installation, the following is to ensure normal use. You can start or stop by using the following command:

Mysql.server start
Mysql.server stop
The default should be a blank password after startup, and you can set a password by mysqladmin:

Mysqladmin-uroot password "your password."
Finally, add MySQL to boot:

Cp/usr/local/cellar/mysql/5.6.22/homebrew.mxcl.mysql.plist ~/library/launchagents/
End, environment configuration complete!

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.