macOS 搭建 LAMP 环境,再部署 NextCloud 站点,最后借助 Frp 实现外网访问。
1.必要的库
$ brew install openldap libiconv
2.安装 Apache
$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
$ brew install httpd
$ brew services start httpd
相关命令:
$ sudo apachectl -k restart
$ tail -f /usr/local/var/log/httpd/error_log
3.升级 PHP
$ brew install php@7.3
自带的 PHP 版本为 7.3.9,没有 zip 扩展,故升级为 7.3.12。
4.配置 httpd.conf
/usr/local/etc/httpd/httpd.conf 修改如下:
Listen 80
DocumentRoot "/Users/wooge/Sites"
<Directory /Users/wooge/Sites>
LoadModule ssl_module lib/httpd/modules/mod_ssl.so
LoadModule socache_shmcb_module lib/httpd/modules/mod_socache_shmcb.so
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
Include /usr/local/etc/httpd/extra/httpd-ssl.conf
ServerName localhost
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
User wooge
Group staff
5.配置 httpd-ssl.conf
/usr/local/etc/httpd/extra/httpd-ssl.conf 修改如下:
Listen 443
<VirtualHost _default_:443>
# General setup for the virtual host
#DocumentRoot "/usr/local/var/www"
#ServerName www.example.com:8443
生成私钥和证书:
$ cd /usr/local/etc/httpd
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
6.配置 httpd-vhost.conf
/usr/local/etc/httpd/extra/httpd-vhost.conf 修改如下:
<VirtualHost *:443>
DocumentRoot "/Users/wooge/Sites/nextcloud"
ServerName next.51simple.com
SSLEngine on
SSLCertificateFile "/usr/local/etc/httpd/51simple.com.cer"
SSLCertificateKeyFile "/usr/local/etc/httpd/51simple.com.key"
ErrorLog "/usr/local/var/log/httpd/next.51simple.com-error_log"
CustomLog "/usr/local/var/log/httpd/next.51simple.com-access_log" common
</VirtualHost>
7.配置 frp
[next]
type = https
local_port = 443
local_ip = 192.168.2.153
custom_domains = next.51simple.com
最后重启 httpd 访问:
https://next.51simple.com:5001
使用的大陆服务器做穿透,没有备案需带端口访问。