从0开始构建FreeBSD 12 + PHP 7.3 + Nginx + MariaDB的网站环境

再来一个FB系统的。

之前的文章写于FB 12刚发布的时候,那时稳定源还没有nginx-full的包,所以需要改一下源地址,现在不用了。

所有命令单步执行

 

 

#安装所需软件

pkg install -y expect proftpd nginx-full bash php73 php73-bz2 php73-calendar php73-curl php73-dba php73-exif php73-gd php73-gettext php73-hash php73-iconv php73-imap php73-json php73-mbstring php73-mysqli php73-odbc php73-opcache php73-openssl php73-pspell php73-readline php73-session php73-sockets php73-sqlite3 php73-tidy php73-xml php73-xmlrpc php73-xsl php73-zip php73-zlib php73-filter 

 

#MariaDB因为版本号可能变动,所以下面两行命令需要根据第一行的结果来选择你需要安装的版本:

pkg search mariadb
pkg install mariadb103-server-10.3.11_2 mariadb103-client-10.3.11_2

 

#更换shell、时区什么的:

chsh -s /usr/local/bin/bash
echo "alias ll='ls -al'" >> /root/.profile
alias ll='ls -al'

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
adjkerntz -a

sysrc sendmail_enable="NONE"
sysrc sendmail_submit_enable="NO"
sysrc sendmail_outbound_enable="NO"
sysrc sendmail_msp_queue_enable="NO" 

 

#设置mariadb:

sysrc mysql_enable=YES
sysrc mysql_pidfile=/var/db/mysql/mysql.pid
sysrc mysql_optfile=/usr/local/etc/my.cnf
service mysql-server start

/usr/local/bin/mysql_secure_installation


mysql -u root -pmysql密码
set password for root@localhost = password('mysql密码'); 
grant all privileges on *.* to root@"127.0.0.1" identified by 'mysql密码' with grant option;
grant all privileges on *.* to root@"%" identified by 'mysql密码' with grant option;
exit;


wget https://soft.tingtao.org/freebsd/mariadb.cnf.txt -O /usr/local/etc/my.cnf
service mysql-server restart

 

#nginx设置:

sysrc nginx_enable="yes"

mkdir -p /var/www/cachemem
mkdir -p /var/www/cachemem/phpfile
mkdir -p /var/www/cachemem/fastcgi

mkdir -p /cachemem/phpfile
mkdir -p /cachedisk/staticfile
mkdir -p /var/www/logs
mkdir -p /usr/local/etc/nginx/sites-enabled/
cp /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.bak
wget https://soft.tingtao.org/nginx/nginx_freebsd.conf.txt -O /usr/local/etc/nginx/nginx.conf
cp /usr/local/etc/nginx/fastcgi_params /usr/local/etc/nginx/fastcgi_params.default

service nginx restart

 

#php设置:

sysrc php_fpm_enable=yes
mv /usr/local/etc/php-fpm.d/www.conf  /usr/local/etc/php-fpm.d/www.conf.bak
service php-fpm restart

 

#proftpd设置:

sysrc proftpd_enable="YES"
mkdir /var/log/proftpd
wget https://soft.tingtao.org/freebsd/proftpd.txt -O /usr/local/etc/proftpd.conf
service proftpd restart

 

 

至此就完成了,比Linux还是方便很多。

 

##########################################

创建站点过程:

 

#站点与ftp、文件系统:

 

pw groupadd www.tingtao.org
pw useradd www.tingtao.org -s /sbin/nologin -m -d /var/www/www.tingtao.org -G www.tingtao.org www
echo "ftp密码" | pw usermod www.tingtao.org -h 0
chown -R www.tingtao.org:www.tingtao.org /var/www/www.tingtao.org
chmod -R 755 /var/www/www.tingtao.org
rm -R /var/www/www.tingtao.org/.*

wget https://soft.tingtao.org/nginx/freebsd/php_www.tingtao.org.conf.txt -O  /usr/local/etc/php-fpm.d/www.tingtao.org.conf 
wget https://soft.tingtao.org/nginx/sites_debian9/www.tingtao.org.conf_nocache.txt -O /usr/local/etc/nginx/sites-enabled/www.tingtao.org_nocache.conf

 

数据库语句与前文一直,不复制了。

新建了站点以后需要重启php-fpm和nginx:

service nginx restart
service php-fpm restart

 

从soft.tingtao.org下载的文件随时可能变动,所以请自行留档。

 

 

 

 

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: