mac nginx 安装教程
eeking a satisfactory solution to create a local web server for programming in macOS with PHP and MySQL, I was disappointed that the turnkey solutions were far from equaling the WAMP that may exist on Windows.
But I forgot macOS is a Unix system, and unlike Windows, it’s perfectly possible to create a customized local server with some packages.
We will see how to install Nginx, PHP-FPM and MariaDB (MySQL) on macOS El Capitan thanks to Homebrew package manager.
Homebrew
HomeBrew is a package manager for macOS, that allows to easily install various Unix applications.
To install, simply execute the command shown on the official website.
If you do not already have them, macOS will prompt you to first install Xcode Command Line Tools.
After installation, the following command, if necessary, will tell you how to complete the installation:
brew doctor
Then updates all packages with:
brew update
brew upgrade
Nginx
Although Apache is natively included with macOS, we propose here to install Nginx, particularly lightweight and easily configurable. Its installation is done with:
brew install nginx
The following will automatically launch Nginx at startup:
brew services start nginx
We want to store our web site in the folder of our choice, and access to the URL http://localhost/.
To do this, edit the configuration file:
nano /usr/local/etc/nginx/nginx.conf
To begin, we edit the line beginning with Nginx #user to give permission to access our files, to modify the following line, where <user> is your username:
user <user> staff;
To use port 80, changing the line beginning with listen in :
listen 80;
Finally, it indicates the folder where you want to store your sites through the variable root :
root <chemin/vers/votre/site>;
We can now start Nginx:
sudo nginx
PHP
To use PHP with Nginx we will use PHP-FPM. To install PHP 7.0, launch the following commands:
Setup the homebrew taps which has dependencies we need:
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
Then we install :
brew install php70
Once installed, use the following commands to run only PHP-FPM on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
One can ensure that the service runs well watching if the following command produces a result:
lsof -Pni4 | grep LISTEN | grep php
Finally, re-edit the configuration file:
nano /usr/local/etc/nginx/nginx.conf
We modify the line starting with index by:
index index.php;
Finally, add in the section server the following lines to run PHP for all files with the extension .php:
location ~ \.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
Restart Nginx to activate the changes:
sudo nginx -s reload
MySQL
Rather than installing the version of MySQL by Oracle achieved, we will install the free MariaDB fork with the following commands:
brew install mariadb
The following lines are used to start the server at startup:
brew services start mariadb
Finally, complete the installation by choosing a root password for MySQL:
mysql_secure_installation
Here is the perfect MAMP installation !
转载 https://www.sylvaindurand.org/setting-up-a-nginx-web-server-on-macos/
mac nginx 安装教程的更多相关文章
- MATLAB R2018b Mac中文版安装教程
MATLAB r2018b mac中文版是一款强大的可视化数学分析软件,专门用于在Mac上执行数值计算,编程和可视化任务时极大地提高您的工作效率.在MATLAB的帮助下,您可以分析数据,创建应用程序, ...
- Visual Studio for Mac离线安装教程
Visual Studio for Mac离线安装教程 可以在线安装,也可以离线安装(本次安装博主使用离线,在线安装失败了) 据说翻个墙就可以,有条件的就翻吧 没条件的我于是选择离线安装………… 离线 ...
- nginx 安装教程
Nginx 安装教程 本教程在CentOS6.7中安装nginx 1.8.0,Nginx中加入了taobao的concat模块,nginx-upload-module模块,pcre 以及nginx-u ...
- nginx安装教程(详细)
所见即所得编辑器, editorhtml{cursor:text;*cursor:auto} img,input,textarea{cursor:default}.cke_editable{curso ...
- xmind2020 zen 10.2.1win/mac/linux安装教程
xmind是一款优秀的思维导图软件,本文教大家如何安装xmind zen 2020 10.2.1版本,解锁使用全部功能,包括去掉xmind zen水印.上传图片等功能,支持windows/mac/li ...
- Linux中Nginx安装教程
Nginx 是一个很强大的高性能Web和反向代理服务器,它具有很多非常优越的特性: 在连接高并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的 ...
- centos7.2下nginx安装教程
1.准备工作 1)关闭iptables 关闭操作 iptables -t nat -F 查看操作 iptables -t nat -L 2)关闭selinux 查看操作 setenforce 关闭操作 ...
- nginx安装教程
一.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel 二.首先要安装 PCRE ...
- Windows、mac字体安装教程
请问字体如何安装? Win7.8.10安装字体方法: http://jingyan.baidu.com/article/14bd256e27c517bb6c26127c.html mac安装字体方法: ...
随机推荐
- IE8的兼容问题
1: rgba失效的问题: 在添加rgba的类名内加上:filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#7f00000 ...
- (15)模型层-什么是ORM
ORM是什么 1.MVC或者MTV框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的减轻了开发 ...
- seelog 文件输出格式
项目中用到seelog,希望每个小时的记录输入在当前小时命名的日志,配置如下: <seelog> <outputs formatid="leads"> &l ...
- linux日志管理
//有关当前登录用户的信息记录在文件utmp中 //登录进入和退出纪录在文件wtmp中 [root@bogon python]# who //who命令查询utmp文件并报告当前登录的每个用户 /va ...
- Eclipse无法编译,提示错误“找不到或者无法加载主类”解决方法
jar包问题: 1.项目的Java Build Path中的Libraries中有个jar包的Source attachment指为了一个不可用的jar包, 解决办法是:将这个不可用的jar包remo ...
- MySQL Transaction--事务无法正常回滚导致的异常
问题表现:系统增删改操作明显变慢(由原来的几十毫秒变为几十秒) 查看未提交事务 ## 查看未提交的事务 ## SELECT p.ID, P.USER, P.HOST, p.DB, P.TIME, T. ...
- Java开发培训基础知识解析之反射机制
Java是老牌编程语言,是当前应用最广泛的编程语言之一.想要学习Java你就一定要掌握Java基础知识,而反射对于初学Java的人来说绝对是非常重要的知识点.什么是反射?如何理解反射机制?如何使用反射 ...
- sqler sql 转rest api 数据聚合操作
sqler 2.0 提供了一个新的指令aggregate,注意这个和sql 的聚合函数不是一个概念,这个只是为了 方便api数据的拼接 参考格式 databases { exec = &qu ...
- Java各个知识点详解总结
Java基础知识总结 写代码: 1,明确需求.我要做什么? 2,分析思路.我要怎么做?1,2,3. 3,确定步骤.每一个思路部分用到哪些语句,方法,和对象. 4,代码实现.用具体的java语言代码把思 ...
- .NET本质论 组件
模块定义 CLR程序存在模块(module)中.一个CLR模块是一个字节流,通常作为一个文件存储在本地的文件系统中或者Web服务器上 CLR模块采用Windows NT的PE/COFF可执行文件格式的 ...