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

环境:FreeBSD 11.1-RELEASE

过程:

  1. pkg install apache24 # 安装 apache2.4
  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. /usr/local/etc/apache24/httpd.conf # 编辑 httpd 的配置文件,本例,启用了好些模块 rewrite_module, mpm_event_module, http2_module, ssl_module, mod_proxy_fcgi, mod_proxy,引用了 httpd-vhosts.conf 文件,禁用了 mpm_worker_module 模块
  5. /usr/local/etc/apache24/extra/httpd-vhosts.conf # 编辑虚拟主机配置文件,如下例,是添加了https站点 portal.anqun.org的配置内容

    Listen 443
    <VirtualHost *:443>
        Protocols h2 http/1.1
        ServerName portal.anqun.org
    
        SSLEngine on
        SSLCertificateFile "/usr/local/etc/apache24/ssl/214238936730268.pem"
        SSLCertificateKeyFile "/usr/local/etc/apache24/ssl/214238936730268.key"
    
        DocumentRoot "/usr/local/www/portal_anqun_org/public_html"
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/www/portal_anqun_org/public_html/$1
        ErrorLog "/usr/local/www/portal_anqun_org/logs/error.log"
    
    <Directory "/usr/local/www/portal_anqun_org/public_html">
        AllowOverride All
        DirectoryIndex index.php index.html
        Require all granted
        Allow from all
    </Directory>
    
    </VirtualHost>
  6. sysrc apache24_enable=yes # 允许 apache24 服务
  7. sysrc mysql_enable=yes # 允许 mysql-server 服务
  8. sysrc php_fpm_enable=yes # 允许 php-fpm 服务
  9. service apache24 start # 启动 apache24 服务
  10. service mysql-server start # 启动 mysql-server 服务
  11. service php-fpm start # 启动 php-fpm 服务
  12. ALTER USER 'root'@'localhost' IDENTIFIED BY 'niDEpASSWORD' ; # 首次启动mysql5.7后,root的密码会写在/root/.mysql_secret 文件里,需要用 ALTER USER 命令更改密码后使用
  13. 安装wordpress,测试正常

参考:

标签: none

添加新评论