Mac OS X 开启Http Ftp服务
2016-03-16 12:15
591 查看
今天想把我们游戏的app包和更新patch放到服务器上,方便大家下载/更新。手头没有linux服务器,工作用的我有一台Windows PC,一台mac mini。windows机器是工作主机器,不能作为文件服务器,而且mac省电/静音,就折腾了一下Mac开启Http和Ftp服务。Mac系统自带了Apache和Ftp服务,只需要开启、配置一下就可以了。
终端输入上述命令,apache就开启了。在本机浏览器中输入http://localhost,可以看到页面显示内容”It works!”。该页面位于apache的默认根目录/Library/WebServer/Documents/。
在httpd.conf中找到#Include /private/etc/apache2/extra/httpd-vhosts.conf,去掉前面的#,保存。
打开Apache虚拟主机配置文件,/etc/apache2/extra/httpd-vhosts.conf。
注释掉文件中配置的2个虚拟主机例子
添加自己的配置
在alias模块里加
Alias update /Users/YourUserName/Desktop/update
保存后重启Apache,#sudo apachectl restart
5. 在浏览器里访问http://localhost/update,error_log提示”Permission Denied”
官方文档http://wiki.apache.org/httpd/13PermissionDenied,里讲到Apache对访问到的各层级目录都要求644权限,我之前只设置了update目录的,要逐层向上把路径中所有层级目录都chmod 644 dir
6. error_log又提示”Client denied by server configuration”
官方文档https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration,真是好啊,讲的明明白白。针对Apache 2.2访问权限配置是
针对2.4配置是
查看我的Mac自带的Apache版本是2.4.16,修改一下配置
7.再访问http://localhost/update,如愿正常显示页面了。
想开机自启动ftp服务就编辑ftp.plist
访问的用户名和密码是登录mac系统的用户名和密码。
开启Apache
#sudo apachectl start
终端输入上述命令,apache就开启了。在本机浏览器中输入http://localhost,可以看到页面显示内容”It works!”。该页面位于apache的默认根目录/Library/WebServer/Documents/。
配置Apache
打开Apche的配置文件,/etc/apache2/httpd.conf在httpd.conf中找到#Include /private/etc/apache2/extra/httpd-vhosts.conf,去掉前面的#,保存。
打开Apache虚拟主机配置文件,/etc/apache2/extra/httpd-vhosts.conf。
注释掉文件中配置的2个虚拟主机例子
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/usr/docs/dummy-host.example.com" ServerName dummy-host.example.com ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/usr/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common </VirtualHost>
添加自己的配置
<VirtualHost *:80> DocumentRoot "/Users/YourUserName/Desktop/update" ServerName localhost ErrorLog "/private/var/log/apache2/error_log" CustomLog "/private/var/log/apache2/access_log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow Allow from all </Directory> </VirtualHost>
在alias模块里加
Alias update /Users/YourUserName/Desktop/update
保存后重启Apache,#sudo apachectl restart
5. 在浏览器里访问http://localhost/update,error_log提示”Permission Denied”
官方文档http://wiki.apache.org/httpd/13PermissionDenied,里讲到Apache对访问到的各层级目录都要求644权限,我之前只设置了update目录的,要逐层向上把路径中所有层级目录都chmod 644 dir
6. error_log又提示”Client denied by server configuration”
官方文档https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration,真是好啊,讲的明明白白。针对Apache 2.2访问权限配置是
<Directory /var/www/example.com> Order deny,allow Deny from all </Directory>
针对2.4配置是
<Directory /var/www/example.com> Require all denied </Directory>
#sudo apachectl -v
查看我的Mac自带的Apache版本是2.4.16,修改一下配置
<VirtualHost *:80> DocumentRoot "/Users/macmini3/Desktop/update" ServerName localhost ErrorLog "/private/var/log/apache2/sites-error_log" CustomLog "/private/var/log/apache2/sites-access_log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted # Order deny,allow # Allow from all </Directory> </VirtualHost>
7.再访问http://localhost/update,如愿正常显示页面了。
Ftp服务
开启和关闭的命令分别是以下两条,很简单sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
想开机自启动ftp服务就编辑ftp.plist
<dict> <key>Disabled</key> --> 改为Enabled <true/>
访问的用户名和密码是登录mac系统的用户名和密码。
相关文章推荐
- RPC failed; result=22, HTTP code = 411
- Apache Isis 1.4.0 发布,领域驱动开发框架
- 什么是Mac OS X?跟Linux有什么区别
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- HTTP Header 属性列表
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- RH436 Day3 课后总结
- 用vsftp快速搭建ftp服务器
- Linux快速构建apache web服务器
- Awstats处理多apache日志
- 安装perl模块小窍门
- 如何在 Linux 中快速地通过 HTTP 提供文件访问服务
- Linux vs Mac:Linux 比 Mac 好的 7 个原因