开发者社区> 问答> 正文

在 FreeBSD 11.2 里安装使用 nginx + php7.1(php-fpm) + mysql 5.7

过程:


1.pkg install nginx # 安装 nginx-1.14

2.pkg install mysql57-server # 安装 mysql server 5.7

3.pkg install php71 php71-curl  php71-gd  php71-mbstring php71-mcrypt php71-mysqli php71-openssl php71-pdo_mysql php71-xml # 安装 php7.1 和相关模块

4.vi /usr/local/etc/nginx/nginx.conf # 编辑nginx配置文件,添加站点,如本例添加drs2.anqun.org的https站点
server {
        listen       443 ssl;
        server_name  drs2.anqun.org;

        ssl_certificate      ssl/drs2.anqun.org.pem;
        ssl_certificate_key  ssl/drs2.anqun.org.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
         ssl_prefer_server_ciphers  on;

         location / {
                 root   /usr/local/www/nginx/drs2.anqun.org;
                 index  index.html index.htm index.php;
                 try_files $uri $uri/ /index.php?$args;
                }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           drs2.anqun.org;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/www/nginx/drs2.anqun.org/$fastcgi_script_name;
            include        fastcgi_params;
        }

        }




5.sysrc nginx_enable=yes # 允许 nginx 服务

6.sysrc mysql_enable=yes # 允许 mysql 服务
  
7.sysrc php_fpm_enable=yes # 允许 php-fpm 服务
  
8.service nginx start # 启动 nginx 服务
  
9.service mysql-server start # 启动 nginx 服务
  
10.service php-fpm start # 启动 nginx 服务
  
11.ALTER USER 'root'@'localhost'  IDENTIFIED BY 'niDEpASSWORD' ; # 首次启动mysql5.7后,root的密码会写在/root/.mysql_secret 文件里,需要用 ALTER USER 命令更改密码后使用

  
12.phpinfo显示信息

  
13.wordpress安装效果



参考: https://www.cnblogs.com/hahawgp/p/3824134.html

展开
收起
dongshan8 2019-02-11 20:17:50 19477 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-直面PHP微服务架构挑战-高驰涛 立即下载
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载

相关镜像