在Mac OS下搭建LNMP开发环境的步骤详解

时间:2017-04-09

然后会输出以下内容:

> 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

然后输入刚才设置的root密码,将会输出以下内容:

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit   //输入exit退出数据库

六、配置nginx

首先,为我们的配置文件创建一些文件夹,这些是仿照ubuntu的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

然后修改nginx配置文件:

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/*;
}

然后创建php-fpm配置文件:

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;
}

重启nginx,至此,配置完成,在www下写一个测试文件,进行测试即可

总结

以上就是在Mac OS上搭建LNMP开发环境的全部步骤了,尽情的享受在Mac OS开发PHP的快感吧!希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对的支持。

  • 共2页:
  • 上一页
  • 2/2下一篇
    上一篇:yii2简单使用less代替css示例 下一篇:Yii2.0中使用js异步删除示例

    相关文章

    最新文章