freebsd nginx mysql php-fpm

pkg 源更新:

mkdir -p /usr/local/etc/pkg/repos

vim /usr/local/etc/pkg/repos/FreeBSD.conf

# content of FreeBSD.conf

FreeBSD: { url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly", }

运行 pkg update -f 更新索引。

安装Nginx Web服务器

ls /usr/ports/www/ | grep nginx

pkg search -o nginx

pkg install nginx

sysrc nginx_enable=yes

service nginx start

sockstat -4 -6 | grep nginx

有nginx进程 则成功

访问:http://yourdomain.com

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

安装PHP编程语言

ls /usr/ports/lang/ | grep php

pkg search -o php

pkg install php71

#php71-mcrypt mod_php71 php71-mbstring php71-curl php71-zlib php71-gd php71-json//看情况自行添加

pkg install php71-mysqli php71-session

cp /usr/local/etc/php-fpm.d/www.conf{,.backup}

nano /usr/local/etc/php-fpm.d/www.conf

注意以下信息

user = www
group = www
sockstat -4 -6| grep php-fpm
有php-fpm进程 则成功
配置php-fpm:
nano /usr/local/etc/nginx/nginx.conf
添加或添加如下信息:
 location ~ \.php$ {
        root               /usr/local/www/nginx;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;    
        include        fastcgi_params;
}
ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini
sysrc php_fpm_enable=yes
service php-fpm restart

测试nginx配置的语法错误:

nginx –t

service nginx restart

就这样! 您已经在FreeBSD 11中成功安装.

安装mysql数据库

ls /usr/ports/databases/ | grep mysql
pkg search -o mysql
pkg install mysql56-server mysql56-client
sysrc mysql_enable=YES
service mysql-server restart

创建更新用户:
grant all privileges on *.* to metin@'%' identified by "1234";
flush privileges;

安装pdomysql扩展支持:

pkg install php71-pdo_mysql

service php-fpm restart

问题:

nginx下php文件404但是html文件正常访问

1.   nginx.conf 文件 里,root 指令 和 fastcgi_param 指令  与 你要访问的文件 的路径是否一致

/usr/local/www/nginx$fastcgi_script_name

2. 就是权限问题。

修改 nginx php-fpm 的 www.conf  文件, 查看到 php-fpm的 所属组和所属用户  

ports安装方式:
1、输入 cd /usr/ports/databases/mysql51-server
2、输入 make install clean 等待安装完成。
参考url:
https://www.howtoing.com/install-nginx-mariadb-and-php-femp-stack-in-freebsd-11x
ports源更新:
https://forums.freebsd.org/threads/how-to-upgrade-ports-and-all-apps.15799/




报错处理:
==> lf-elf.so.1: Shared object "libssl.so.8" not found required by "pkg".
# pkg-static install -f pkg
# pkg-static bootstrap -f
# pkg update

必杀:
'pkg bootstrap -f' worked for me
then 'pkg update|upgrade'