https://wiki.archlinux.org/api.php?action=feedcontributions&user=%E6%97%A0%E6%9E%81&feedformat=atomArchWiki - User contributions [en]2024-03-28T13:24:03ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=User:%E6%97%A0%E6%9E%81&diff=487968User:无极2017-08-29T15:42:16Z<p>无极: Created page with "none"</p>
<hr />
<div>none</div>无极https://wiki.archlinux.org/index.php?title=GNOME_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=452383GNOME (简体中文)2016-09-29T16:18:51Z<p>无极: /* 安装 */</p>
<hr />
<div>[[Category:Desktop environments (简体中文)]]<br />
[[cs:GNOME]]<br />
[[de:GNOME]]<br />
[[en:GNOME]]<br />
[[es:GNOME]]<br />
[[fr:GNOME]]<br />
[[it:GNOME]]<br />
[[ja:GNOME]]<br />
[[nl:GNOME]]<br />
[[pl:GNOME]]<br />
[[pt:GNOME]]<br />
[[ru:GNOME]]<br />
[[sr:GNOME]]<br />
[[th:GNOME]]<br />
[[tr:Gnome Masaüstü Ortamı]]<br />
[[uk:GNOME]]<br />
[[zh-TW:GNOME]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Desktop environment}}<br />
{{Related|Display manager}}<br />
{{Related|Window manager}}<br />
{{Related|GTK+}}<br />
{{Related|GDM}}<br />
{{Related|GNOME/Tips and tricks (简体中文)}}<br />
{{Related|GNOME/Troubleshooting (简体中文)}}<br />
{{Related|GNOME/Files}}<br />
{{Related|GNOME/Gedit}}<br />
{{Related|GNOME/Web}}<br />
{{Related|GNOME/Evolution}}<br />
{{Related|GNOME/Flashback}}<br />
{{Related|GNOME/Keyring}}<br />
{{Related|Cinnamon}}<br />
{{Related|MATE}}<br />
{{Related|Official repositories#gnome-unstable}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|GNOME|2016-09-21|451075}}<br />
<br />
GNOME (读音是''gah-nohm'' 或 ''nohm'')是一个简单易用的[[Desktop environment (简体中文)|桌面环境]]. 它由[[Wikipedia:The GNOME Project|GNOME 项目组]]设计,完全自由和开源. GNOME是[[Wikipedia:GNU Project|GNU 项目]]的一部分.<br />
<br />
== 安装 ==<br />
<br />
以下两个软件组均包含 GNOME 的组件:<br />
<br />
* {{Grp|gnome}} 组包含基本桌面环境和精选的[https://wiki.gnome.org/Apps 应用程序].<br />
<br />
* {{Grp|gnome-extra}} 包组包含剩余的可选工具,例如[[Gedit|文本编辑器]]、压缩文件管理器、光盘烧录工具、邮件客户端、游戏、开发工具及其它非必需的软件。 {{Grp|gnome}} 软件组是这个组的基础。 <br />
<br />
The base desktop consists of [[Wikipedia:GNOME_Shell|GNOME Shell]], a plugin for the [[Wikipedia:Mutter_(software)|Mutter]] window manager. It can be installed separately with {{Pkg|gnome-shell}}.<br />
<br />
{{Note|''mutter'' 是gnome桌面的混合管理器, 利用硬件加速防止屏幕撕裂. ''mutter''自动检测显卡驱动是否足以运行gnome, 不足以胜任就用''llvmpipe''软件绘制.}} <br />
<br />
=== 附加的软件包 ===<br />
<br />
上面提到的包组不包括这些包:<br />
* {{App|[[Wikipedia:GNOME Boxes|Boxes]]|访问 [[libvirt]] 虚拟机的用户接口.|https://wiki.gnome.org/Apps/Boxes|{{Pkg|gnome-boxes}}}}<br />
* {{App|GNOME Initial Setup|准备新系统的简单、易用和安全的工具。|https://github.com/GNOME/gnome-initial-setup|{{Pkg|gnome-initial-setup}}}}<br />
* {{App|GNOME PackageKit|GNOME 使用 PackageKit 的工具集。|https://github.com/GNOME/gnome-packagekit|{{Pkg|gnome-packagekit}}}}<br />
* {{App|[[Wikipedia:Nemiver|Nemiver]]|C/C++ 调试器.|https://wiki.gnome.org/Apps/Nemiver|{{Pkg|nemiver}}}}<br />
* {{App|[[Wikipedia:GNOME Software|Software]]|安装和更新软件和系统扩展.|https://wiki.gnome.org/Apps/Software/|{{Pkg|gnome-software}}}}<br />
<br />
== GNOME会话==<br />
<br />
GNOME 有三个可用的会话,都使用 GNOME Shell<br />
*'''GNOME''' 是默认会话, 有创新的布局<br />
*'''GNOME Classic''' 的桌面布局类似于传统的GNOME 2, using pre-activated extensions and parameters. [http://worldofgnome.org/welcome-to-gnome-3-8-flintstones-mode/] Hence it is more a customized GNOME Shell than a truly distinct mode<br />
*'''GNOME on Wayland''' GNOME Shell 在新的Wayland协议上运行. 而传统的 X 应用程序在Xwayland上运行<br />
<br />
== 运行 GNOME ==<br />
<br />
GNOME可以通过 [[display manager (简体中文)|显示管理器]]以图形方式启动,或者从控制台手动启动。 为优化桌面整合, 建议使用[[GDM (简体中文)]] (GNOME显示管理器)。<br />
注意 [[systemd (简体中文)#使用单元|启用]] 一个显示管理器(例如GDM)意味着Xorg将会以root权限运行. <br />
{{注意| 如果不使用 GDM,你将无法体验到对锁屏的原生支持,因此你不得不使用另一个屏幕锁来提供类似功能,参见[[Xmonad (简体中文)#GNOME 3 and xmonad]].}}<br />
<br />
=== 图形界面登录===<br />
<br />
可以在登录管理器中选择 ''GNOME'', ''GNOME Classic'' 或 ''GNOME on Wayland'' 作为登录选项。<br />
<br />
=== 手动启动 ===<br />
<br />
* 对于标准的GNOME会话, 在{{ic|~/.xinitrc}} 中添加:{{ic|exec gnome-session}}.<br />
* 对于经典的gnome会话,在 {{ic|~/.xinitrc}} 中添加:{{bc|<nowiki>export XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME<br />
export GNOME_SHELL_SESSION_MODE=classic<br />
exec gnome-session --session=gnome-classic</nowiki>}}<br />
{{注意|最好把gnome--session之前的应用注释掉,我之前因为没有注释掉{{ic|twm}}(另一个窗口管理器)导致启动gnome失败}}<br />
我现在的{{ic|/etc/X11/xinit/xinitrc}}如下:<br />
{{bc|#twm &<br />
#xclock -geometry 50x50-1+1 &<br />
#xterm -geometry 80x50+494+51 &<br />
#xterm -geometry 80x20+494-0 &<br />
#exec xterm -geometry 80x66+0+0 -name login<br />
exec gnome-session}}<br />
<br />
改完{{ic|~/.xinitrc}} ,即可用{{ic|startx}} 启动Gnome (see [[xinitrc]] for additional details, such as preserving the logind session). After setting up the {{ic|~/.xinitrc}} file it can also be arranged to [[Start X at login]].<br />
<br />
{{Note|Wayland 上的 Gnome 需要安装 {{Pkg|xorg-server-xwayland}} 包, 不能使用 ''startx'' 和{{ic|~/.xinitrc}},而是要运行 {{ic|gnome-session --session&#61;gnome-wayland}}. 更多参见 [[Wayland]].}}<br />
<br />
===Wayland 中的 GNOME 应用程序===<br />
<br />
根据当前的默认情况,GNOME 应用程序会利用 XWayland,以传统 X 应用程序的方式运行。若需在 Wayland 下测试 GNOME 应用,请以命令行方式运行程序,并加上以下前缀: {{ic|env GDK_BACKEND&#61;wayland <command>}}。<br />
<br />
{{Note|可以设置全局的 Wayland 环境,使用 {{ic|env GDK_BACKEND&#61;wayland gnome-session --session&#61;gnome-wayland}}。 但是现在无法工作 [[GNOME/Troubleshooting#Setting global Wayland environment with an environment variable]] 提供了一个临时解决方案.}}<br />
<br />
请查看以下页面以了解开发进展: [https://wiki.gnome.org/Initiatives/Wayland/Applications/ GNOME Applications under Wayland].<br />
<br />
== 导览 ==<br />
<br />
您可以阅读这篇文章: [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell cheat sheet] 以了解如何高效地使用 GNOME shell,它展示了 GNOME shell 的特色与使用快捷键。文章内容包括怎么切换任务,使用键盘,窗口控制,使用面板,预览模式等。<br />
部分常用的快捷键:<br />
<br />
* {{ic|Super}}: 进入预览模式<br />
* {{ic|Super}} + {{ic|m}}: 显示消息托盘<br />
* {{ic|Super}} + {{ic|a}}:显示应用程序菜单<br />
* {{ic|Alt}} + {{ic|F2}}:输入命令以快速启动应用<br />
* {{ic|Alt}} + {{ic|F2}},然后输入 {{ic|r}} 或 {{ic|restart}},再 {{ic|Enter}}:重启 GNOME shell。这一条在你遇到 shell 图形界面错误时十分有用。<br />
<br />
=== 重启 GNOME shell ===<br />
<br />
当修改过界面之后你可能需要重启 GNOME shell。你可以重新登陆,不过有一个简单快捷的方法。 按 {{ic|Alt}} + {{ic|F2}} 再输入 {{ic|r}} 再 {{ic|Enter}}<br />
<br />
=== GNOME Shell 崩溃 ===<br />
<br />
一些特定的微调或者经常性重启 Shell 会导致 shell 在将要重启的时候崩溃。这个时候你必须做好心理准备,然后强制注销。有一些修改,例如在'''''GNOME Shell''''' 和 '''''fallback mode,''''' 之间切换,不能简单地使用 r 重启;必须重登陆来应用这个效果。<br />
<br />
丑话说在前面,在重启 shell 前请先把有用的文档保存(或者关闭)。虽然这不是必要的,因为窗口和文档在重启了 shell 之后应该还在。<br />
<br />
=== 遗留名称 ===<br />
{{注意|<br />
一些GNOME程序在文档和关于对话框的名称已更改,但可执行文件的名称却没有。这样的应用程序在下面表格列出.}}<br />
<br />
{{提示|在搜索栏中搜索的应用程序的遗留名称将成功返回现在的应用程序,例如搜索''nautilus''将返回''Files''.}}<br />
<br />
{| class="wikitable"<br />
! Current<br />
! Legacy<br />
|-<br />
| [[Files]]<br />
| Nautilus<br />
|-<br />
| [[GNOME Web|Web]]<br />
| Epiphany<br />
|-<br />
| Videos<br />
| Totem<br />
|-<br />
| Main Menu<br />
| Alacarte<br />
|-<br />
| Document Viewer<br />
| Evince<br />
|-<br />
| Disk Usage Analyser<br />
| Baobab<br />
|-<br />
| Image Viewer<br />
| EoG (Eye of GNOME)<br />
|-<br />
| [[GNOME Keyring|Passwords and Keys]]<br />
| Seahorse<br />
|}<br />
<br />
== 配置 ==<br />
<br />
GNOME 3 是重新设计的,但是像大多数大型软件项目一样,他是很多不同时间的部分组装起来的。他没有一个 '''无所不包''' 的配置工具。新的 ''系统设置'' 比以前的控制面板有很大的改进。 ''系统设置'' 组织得很好,但是你可能想要更深层次地改变外观。<br />
<br />
以前你所熟悉的配置工具现在有的好用,有的不好用了。有些设置选项隐藏着,不太容易找到。许多设置将会,或已经迁移到了新的工具上。你需要了解应当去哪里寻找适当的设置项,才能更好地配置 GNOME 外观。 <br />
<br />
GNOME 桌面环境依赖于一个存储配置的数据库后端(DConf)来存储 GNOME 与 GNOME 应用的设置。安装桌面环境时,GNOME 提供一套默认的配置,而各类应用程序向数据库中添加它们自己的配置。<br />
<br />
对用户来说,最基础而直观的配置方式莫过于使用 GNOME 系统设置面板(gnome-control-center),以及 GNOME 应用程序各自的首选项(preferences)面板。如果您愿意,直接在 DConf 数据库中进行修改与配置总是可行的,尤其是在某些设置选项没有暴露在用户界面的情况下,直接修改可以更改某些隐藏选项。<br />
<br />
GNOME 的这些配置通常是用户间相互独立的。以下文字仅供单用户配置所用,并没有提及更改全局配置模板的方法。<br />
<br />
=== GNOME 系统设置 ===<br />
<br />
系统设置工具包括了一些最基础的 GNOME 环境配置选项。<br />
<br />
==== 色彩设置 ====<br />
<br />
{{ic|colord}} 守护进程读取显示器的 [https://zh.wikipedia.org/wiki/EDID EDID]信息,并提取出合适的色彩配置内容。大多数情况下,自动色彩配置都是正确的,不需要额外设置;但是对于可能出现的偏差情况,例如使用较旧的显示器时,您可以将色彩配置文件放在 {{ic|~/.local/share/icc/}} 下,并在设置面板里启用。<br />
<br />
==== 日期与时间 ====<br />
<br />
如果系统已有配置好的 [https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon_(简体中文) NTP 守护进程],它同样会对 GNOME 桌面环境起作用。如果需要,您也可以手动控制进行同步。<br />
<br />
如需在顶栏显示日期,请运行:<br />
<br />
$ gsettings set org.gnome.desktop.interface clock-show-date true<br />
<br />
另外,如需在 shell 的日历中显示周数,请运行:<br />
<br />
$ gsettings set org.gnome.shell.calendar show-weekdate true<br />
<br />
当然,以上配置均可以在 {{ic|gnome-tweak-tool}} 里完成。<br />
<br />
==== 默认应用程序 ==== <br />
<br />
Upon installing GNOME for the first time, you may find that the wrong applications are handling certain protocols. For example, ''totem'' opens videos instead of a previously used [[VLC]]. Some of the associations can be set from system settings via: ''System'' > ''Details'' > ''Default applications''. <br />
<br />
For other protocols and methods see [[Default applications]] for configuration.<br />
<br />
==== 鼠标和触摸板 ====<br />
<br />
为了帮助减少触摸板的干扰,你可能希望实现以下设置:<br />
<br />
* 禁用触摸板,打字时<br />
* 禁用滚动<br />
* 禁用点击<br />
<br />
{{Note|1=GNOME 目前不再支持 [[synaptics]],请使用 [[libinput]]. 参考 [https://bugzilla.gnome.org/show_bug.cgi?id=764257#c12 this bug report].}}<br />
<br />
==== 网络 ====<br />
<br />
[[NetworkManager]] is the native tool of the GNOME project to control network settings from the shell. It is installed by default as a dependency for {{Pkg|tracker}} package, which is a part of {{Grp|gnome}} group, and just needs to be [[NetworkManager#Enable NetworkManager|enabled]].<br />
<br />
While any other [[List_of_applications/Internet#Network_managers|network manager]] can be used as well, NetworkManager provides the full integration via the shell network settings and a status indicator applet {{Pkg|network-manager-applet}} (not required for GNOME).<br />
<br />
==== 在线帐户 ====<br />
<br />
Backends for the GNOME messaging application {{Pkg|empathy}} as well as the GNOME Online Accounts section of the System Settings panel are provided in a separate group: {{Grp|telepathy}}. See [[#Unable to add accounts in Empathy and GNOME Online Accounts]]. Some online accounts, such as [[ownCloud]], require {{Pkg|gvfs-goa}} to be installed for full functionality in GNOME applications such as [[GNOME Files]] and GNOME Documents [https://wiki.gnome.org/ThreePointSeven/Features/Owncloud].<br />
<br />
==== 搜索 ====<br />
<br />
The GNOME shell has a search that can be quickly accessed by pressing the {{ic|Super}} key and starting to type. The {{Pkg|tracker}} package is installed by default as a part of {{Grp|gnome}} group and provides an indexing application and metadata database. It can be configured with the ''Search and Indexing'' menu item; monitor status with ''tracker-control''. It is started automatically by ''gnome-session'' when the user logs in. Indexing can be started manually with {{ic|tracker-control -s}}. Search settings can also be configured in the ''System Settings'' panel.<br />
<br />
The Tracker database can be queried using the ''tracker-sparql'' command. View its manual page {{ic|man tracker-sparql}} for more information.<br />
<br />
<br />
=== 高级设置 ===<br />
==== 外观 ====<br />
<br />
=====GTK+主题和图标主题=====<br />
除了以下所述的直接从底层修改主题的方法,您也可以使用 gnome-tweak-tool 工具进行修改。 <br />
安装一个新的主题和图标集,分别添加相关的{{ic|~/.local/share/themes}} 或者 {{ic|~/.local/share/icons}} respectively (add to {{ic|/usr/share/}} instead of {{ic|~/.local/share/}} for the themes to be available systemwide.) 他们和其他GUI设置也可以在 {{ic|~/.config/gtk-3.0/settings.ini}}中定义:<br />
<br />
{{hc|~/.config/gtk-3.0/settings.ini|<nowiki><br />
[Settings]<br />
gtk-theme-name = Adwaita<br />
# next option is applicable only if selected theme supports it<br />
gtk-application-prefer-dark-theme = true<br />
# set font name and dimension<br />
gtk-font-name = Sans 10<br />
</nowiki>}}<br />
<br />
其他主题的站点:<br />
* [http://www.deviantart.com/browse/all/customization/skins/linuxutil/desktopenv/gnome/gtk3/ DeviantArt].<br />
* [http://gnome-look.org/index.php?xcontentmode=167 gnome-look.org].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=gtk3&do_Search=Go GTK3 themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=xcursor&do_Search=Go&PP=50&SB=v&SO=d Cursor themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=icon-theme&do_Search=Go&PP=50&SB=v&SO=d Icon themes in the AUR].<br />
<br />
一旦安装,就可以使用 GNOME Tweak Tool或GSettings -参阅下面的GSettings命令:<br />
<br />
对于GTK+主题:<br />
$ gsettings set org.gnome.desktop.interface gtk-theme ''theme-name''<br />
<br />
对于图标主题<br />
$ gsettings set org.gnome.desktop.interface icon-theme ''theme-name''<br />
<br />
====== 全局暗色主题======<br />
<br />
GNOME will use the Adwaita light theme by default however a dark variant of this theme (called the Global Dark Theme) also exists and can be selected using the Tweak Tool or by editing the GTK+ 3 settings file - see [[GTK+#Dark theme variant]]. Some applications such as Image Viewer (''eog'') use the dark theme by default. It should be noted that the Global Dark Theme only works with GTK+ 3 applications; some GTK+ 3 applications may only have partial support for the Global Dark theme. Qt and GTK+ 2 support for the Global Dark Theme may be added in the future.<br />
<br />
===== 窗口管理器主题=====<br />
<br />
The window manager theme (the style of the window titlebars) can be set using the GNOME Tweak Tool or the following GSettings command:<br />
$ gsettings set org.gnome.desktop.wm.preferences theme ''theme-name''<br />
<br />
====== 标题栏的高度 ======<br />
<br />
{{Note|下面配置会修改 GNOME 终端和 Chromium 的标题栏高度,但是不会影响 Nautilus。}}<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<br />
headerbar.default-decoration {<br />
padding-top: 0px;<br />
padding-bottom: 0px;<br />
min-height: 0px;<br />
font-size: 0.6em;<br />
}<br />
<br />
headerbar.default-decoration button.titlebutton {<br />
padding: 0px;<br />
min-height: 0px;<br />
}<br />
}}<br />
<br />
更多信息请阅读 [https://ask.fedoraproject.org/en/question/10035/shrink-title-bar/?answer=86149#post-id-86149].<br />
<br />
====== 标题栏按钮重新排序 ======<br />
<br />
设置 GNOME 窗口管理器顺序 (Mutter, Metacity): <br />
$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'<br />
<br />
{{提示|冒号表示窗口标题栏的按钮会出现在哪一方}}<br />
<br />
====== 最大化时隐藏标题栏 ======<br />
<br />
*[[Install]] {{AUR|gnome-shell-extension-pixel-saver-git}} or {{AUR|gnome-shell-extension-pixel-saver}}. Maximized windows get the title bar merged into the activity bar, saving precious pixels.<br />
<br />
*[[Install]] {{AUR|mutter-hide-legacy-decorations}}. It changes a default setting in the window manager, so as to automatically hide the titlebar on legacy (non-headerbar) apps when they are maximized or tiled to the side.<br />
<br />
*[[Install]] {{AUR|maximus}}. To start the application, execute ''maximus'' from a terminal. When running, the daemon will automatically maximize windows. It will undecorate maximized windows and redecorate them when they are unmaximized. If you do not want all windows to start maximized, run {{ic|maximus -m}} instead. Note that this will only work with windows decorated by the window manager; applications that use client-side decoration such as [[GNOME Files]] will not be undecorated when maximized.<br />
<br />
===== GNOME Shell主题 =====<br />
<br />
The theme of GNOME Shell itself is configurable. To use a Shell theme, firstly ensure that you have the {{Pkg|gnome-shell-extensions}} package installed. Then enable the ''User Themes'' extension, either through GNOME Tweak Tool or through the [https://extensions.gnome.org GNOME Shell Extensions] webpage. Shell themes can then be loaded and selected using the GNOME Tweak Tool.<br />
<br />
There are a number of GNOME Shell themes available [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-theme&do_Search=Go&PP=50&SB=v&SO=d in the AUR].<br />
<br />
Shell themes can also be downloaded from [http://gnome-look.org/index.php?xcontentmode=191 gnome-look.org].<br />
<br />
===== Icons on menu =====<br />
<br />
The default GNOME schema doesn't display any icon on menus. To display icons on menus, issue the following command.<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"<br />
<br />
==== 桌面 ====<br />
<br />
各种桌面设置可以应用。<br />
<br />
===== 桌面上的图标 =====<br />
<br />
参阅 [[GNOME Files#Desktop Icons]].<br />
<br />
===== 锁屏和背景=====<br />
<br />
When setting the Desktop or Lock screen background, it is important to note that the Pictures tab will only display pictures located in {{ic|/home/''username''/Pictures}} folder. If you wish to use a picture not located in this folder, use the commands indicated below.<br />
<br />
对于桌面背景:<br />
$ gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
对于锁屏背景<br />
$ gsettings set org.gnome.desktop.screensaver picture-uri 'file:///path/to/my/picture.jpg'<br />
====扩展 ====<br />
<br />
{{注意|GNOME Shell browser 插件可以让用户从[https://extensions.gnome.org extensions.gnome.org]安装扩展,支持 [[Firefox (简体中文)]] 和 [[GNOME/Web]],要在 Google Chrome/Chromium, Opera 和 Vivaldi 中使用,需要安装 {{AUR|chrome-gnome-shell-git}}.}}<br />
<br />
GNOME Shell 可以使用第三方扩展来定制。这些扩展提供了一些额外的功能,如:提供一个可以一直显示的 Dock、更换 Shell 的主题,等等。<br />
<br />
名为 {{Pkg|gnome-shell-extensions}} 的软件包提供了一组由 The GNOME Project 维护,被当做 GNOME 计划的一部分的扩展,其中许多扩展被用在了 GNOME Classic 会话环境中。(最新版本的扩展你可以用他的代码 snapshot)[https://www.archlinux.org/packages/?sort=&q=gnome-shell-extension&maintainer=&last_update=&flagged=&limit=50 列表在这里]<br />
<br />
$ pacman -Ss gnome-shell-extension<br />
<br />
另外,有许多扩展被收集并托管在了[https://extensions.gnome.org extensions.gnome.org] 上。你可以在浏览器中浏览扩展列表,并轻松地一键点击来安装、管理、启用扩展。你可以在 [https://extensions.gnome.org/about/ 这里]找到有关插件的更多信息。<br />
<br />
你也可以在 [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-extension&do_Search=Go AUR]里面找到一些有用的扩展。当然,它们大多也可以在 [https://extensions.gnome.org extensions.gnome.org] 找到。一些值得一提的是:<br />
<br />
* {{AUR|gnome-shell-extension-lockkeys-git}} 一个指示 NumLock/CapsLock 激活情况的扩展。<br />
* {{AUR|gnome-shell-extension-weather-git}} 一个可以显示天气通知的扩展。<br />
* {{AUR|gnome-shell-extension-nohotcorner-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-nohotcorner-git}}}} 一个禁用“Hot Corner”功能的拓展。<br />
* {{AUR|gnome-shell-extension-insensitive-message-tray-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-insensitive-message-tray-git}}}} 使鼠标在屏幕底部激活信息托盘的行为变迟钝的拓展。<br />
*[https://extensions.gnome.org/extension/5/alternative-status-menu/ Alternative Status Menu] 让你的用户菜单里显示休眠和关机的扩展。<br />
<br />
另外,想要在屏幕底部显示一个任务栏,但又不想使用 GNOME Classic 的用户可以考虑使用 Window list 扩展 (由 {{Pkg|gnome-shell-extensions}} 提供).<br />
<br />
在安装完一个扩展之后可能需要[[#重启_GNOME_shell|重启 GNOME shell ]] 。故障排除信息参照[[#安装扩展导致GNOME停止工作|安装扩展导致GNOME停止工作]]。<br />
<br />
==== 输入法 ====<br />
<br />
GNOME集成了的通过[[IBus]]的输入法, 只有{{Pkg|ibus}}和添加想要的输入法引擎 (例如:{{Pkg|ibus-libpinyin}} for Intelligent Pinyin) 需要安装,安装后,输入法引擎可以加入GNOME的区域和语言设置键盘布局。<br />
<br />
==== 字体 ====<br />
<br />
{{Tip|If you set the ''Scaling factor'' to a value above 1.00, the Accessibility menu will be automatically enabled.}}<br />
<br />
Fonts can be set for Window titles, Interface (applications), Documents and Monospace. See the Fonts tab in the Tweak Tool for the relevant options.<br />
<br />
For hinting, RGBA will likely be desired as this fits most monitors types, and if fonts appear too blocked reduce hinting to ''Slight'' or ''None''.<br />
==== 启动应用程序====<br />
要启动登录某些应用程序, copy the relevant {{ic|.desktop}} file from {{ic|/usr/share/applications/}} to {{ic|~/.config/autostart/}}.<br />
{{Pkg|gnome-tweak-tool}} 支持管理 autostart-entries。<br />
<br />
{{Tip|If the plus sign button in the Tweak Tool's Startup Applications section is unresponsive, try start the Tweak Tool from the terminal using the following command: {{ic|gnome-tweak-tool}}. See the following [https://bbs.archlinux.org/viewtopic.php?pid&#61;1413631#p1413631 forum thread].}}<br />
<br />
{{Note|The ''gnome-session-properties'' dialog was removed as of GNOME 3.12. It can be added back by [[install]]ing the {{AUR|gnome-session-properties}} package.}}<br />
<br />
==== 电源 ====<br />
<br />
你可能希望修改基本的电源管理设置(以下的设置以笔记本电脑用户为例,请按需调整):<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.power button-power ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout ''3600''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout ''1800''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type ''hibernate''<br />
$ gsettings set org.gnome.desktop.lockdown disable-lock-screen ''true''<br />
<br />
如需在合上盖子后依然保持显示器开启:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup do-nothing<br />
<br />
===== 配置合上盖子时的行为 =====<br />
GNOME TWEAK Tool 自 3.17.1 开始,可以'''阻止''' ''systemd'' 在“合上盖子”这一 ACPI 事件发生后采取默认行动。[http://ftp.gnome.org/pub/GNOME/sources/gnome-tweak-tool/3.17/gnome-tweak-tool-3.17.1.news] 若想要'''阻止''' ''systemd'' 的默认行为,打开 Tweak Tool,在“电源”标签页下选择“合上盖子后不待机”的选项。此选项意味着在盖子合上后,系统将不会默认待机,而是不采取任何措施。如果选择了此选项,一个自启动项目{{ic|~/.config/autostart/ignore-lid-switch-tweak.desktop}}将会被创建,用于阻止''systemd''的默认行为。<br />
<br />
如果你在合上盖子后既不希望系统待机,也不希望系统不动于衷,你首先要确保你并没有打开上述的选项,然后再配置''systemd''的{{ic|1=HandleLidSwitch=''默认行为''}}选项,详见[[Power management#ACPI events]]中的说明。<br />
<br />
===== 修改电池电量严重不足时的行为 =====<br />
<br />
The settings panel does not provide an option for changing the critical battery level action. These settings have been removed from dconf as well. They are now managed by upower. Edit the upower settings in {{ic|/etc/UPower/UPower.conf}}. Find these settings and adjust to your needs.<br />
<br />
{{hc|head=/etc/UPower/UPower.conf|output=<br />
PercentageLow=10<br />
PercentageCritical=3<br />
PercentageAction=2<br />
CriticalPowerAction=HybridSleep<br />
}}<br />
<br />
==== Sort applications into application (app) folders ====<br />
<br />
{{Tip|The [https://github.com/prurigro/gnome-catgen gnome-catgen] ({{AUR|gnome-catgen-git}}) script allows you to manage folders through the creation of files in {{ic|~/.local/share/applications-categories}} named after each category and containing a list of the desktop files belonging to apps you'd like to have inside. Optionally, you can have it cycle through each app without a folder and input the desired category until you ctrl-c or run out of apps.}}<br />
<br />
In the '''dconf-editor''' navigate to {{ic|org.gnome.desktop.app-folders}} and set the value of {{ic|folder-children}} to an array of comma separated folder names:<br />
<br />
['Utilities', 'Sundry']<br />
<br />
Add applications using {{ic|gsettings}}:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ apps "['alacarte.desktop', 'dconf-editor.desktop']"<br />
<br />
This adds the applications {{ic|alacarte.desktop}} and {{ic|dconf-editor.desktop}} to the Sundry folder. This will also create the folder {{ic|org.gnome.desktop.app-folders.folders.Sundry}}.<br />
<br />
To name the folder (if it has no name that appears at the top of the applications):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ name "Sundry"<br />
<br />
Applications can also be sorted by their category (specified in their ''.desktop'' file):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ categories "['Office']"<br />
<br />
If certain applications matching a category are not wanted in a certain folder, exclusions can be set:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ excluded-apps "['libreoffice-draw.desktop']"<br />
<br />
For further information, refer to the [https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.app-folders.gschema.xml.in.in app-folders schema].<br />
<br />
== 参见 ==<br />
* [http://www.gnome.org/ 官方网站]<br />
* [http://extensions.gnome.org/ GNOME-shell扩展]<br />
* 主题、图标和壁纸:<br />
** [http://art.gnome.org/ GNOME Art]<br />
** [http://www.gnome-look.org/ GNOME 外观]<br />
* GTK/GNOME 程序:<br />
** [http://www.gnomefiles.org/ GNOME 文件管理]<br />
** [http://www.gnome.org/projects/ GNOME 项目列表]<br />
* [http://blog.fpmurphy.com/2011/03/customizing-the-gnome-3-shell.html 自定义 GNOME Shell] <br />
* GNOME 代码和镜像:<br />
** [https://git.gnome.org/browse/ GNOME Git 仓库]<br />
** [https://github.com/GNOME GNOME Github 镜像]</div>无极https://wiki.archlinux.org/index.php?title=%E9%99%8D%E7%BA%A7%E8%BD%AF%E4%BB%B6&diff=433974降级软件2016-05-05T16:00:51Z<p>无极: /* 步骤一 */</p>
<hr />
<div>==步骤一==<br />
打开[https://www.archlinux.org/packages/ 这个页面]搜索需要的软件包;<br />
<br />
==步骤二==<br />
在搜索结果中选择符合的结果进入<br />
==步骤三==<br />
点击右侧的View Changes<br />
==步骤五==<br />
选择合适的版本并进入<br />
==步骤六==<br />
下载PKGBUILD(在dowload后两个链接随便选一个)<br />
==步骤七==<br />
解压下载的文件,进入解压后的目录,最好选repos目录,运行makepkg,如果提示依赖不满足,运行makepkg -s</div>无极https://wiki.archlinux.org/index.php?title=%E9%99%8D%E7%BA%A7%E8%BD%AF%E4%BB%B6&diff=433973降级软件2016-05-05T16:00:20Z<p>无极: 降级软件包</p>
<hr />
<div>==步骤一==<br />
打开[https://www.archlinux.org/packages/]搜索需要的软件包;<br />
==步骤二==<br />
在搜索结果中选择符合的结果进入<br />
==步骤三==<br />
点击右侧的View Changes<br />
==步骤五==<br />
选择合适的版本并进入<br />
==步骤六==<br />
下载PKGBUILD(在dowload后两个链接随便选一个)<br />
==步骤七==<br />
解压下载的文件,进入解压后的目录,最好选repos目录,运行makepkg,如果提示依赖不满足,运行makepkg -s</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=419864PHP (简体中文)2016-02-10T04:57:57Z<p>无极: /* imagemagick */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[en:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
欲使用 {{Pkg|php-gd}} 勿在{{ic|/etc/php/php.ini}}中注释下列内容:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
运行{{ic|# pecl install imagick}}安装{{Pkg|imagemagick}} . ''pecl'' 包含于{{AUR|php-pear}} 包. 在 {{ic|/etc/php/php.ini}}中加入<br />
<br />
extension=imagick.so<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=419863PHP (简体中文)2016-02-10T04:54:35Z<p>无极: /* gd */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[en:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
欲使用 {{Pkg|php-gd}} 勿在{{ic|/etc/php/php.ini}}中注释下列内容:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417090PHP (简体中文)2016-01-25T02:43:49Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417089PHP (简体中文)2016-01-25T02:43:09Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{建议| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417088PHP (简体中文)2016-01-25T02:42:47Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{warning| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417087PHP (简体中文)2016-01-25T02:41:03Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{建议| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417086PHP (简体中文)2016-01-25T02:39:26Z<p>无极: /* OPCache */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417085PHP (简体中文)2016-01-25T02:38:50Z<p>无极: /* 缓存 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{ic|zend_mm_heap corrupted}}。<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=417084PHP (简体中文)2016-01-25T02:37:06Z<p>无极: /* 缓存 */</p>
<hr />
<div>[[Category:Programming languages (简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
PHP有两种缓存: ''opcode''/''bytecode'' 缓存和''userland''/''user data'' 缓存,这两种缓存都大幅度提升性能,因此最好开启。<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]]仅提供''opcode''缓存。<br />
* [https://github.com/krakjoe/apcu/ APCu]仅提供''userland''缓存<br />
<br />
要获得最佳性能,应当开启两种缓存。按照下面[[#OPCache]]和[[#APCu]]的步骤操作即可。<br />
<br />
=== OPCache ===<br />
<br />
OPCache随PHP发布,因此在[[#Configuration|PHP configuration file]]中开启或添加下面两行即可:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
你可在[https://secure.php.net/manual/en/book.opcache.php 官网] 找到其他设置以及建议设置。<br />
<br />
{{警告|如果你使用[https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended 推荐设置],要确保你一仔细看过[https://secure.php.net/manual/en/opcache.installation.php#114567 说明],某些情况下可能导致如下错误:{{{{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=GNOME_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416811GNOME (简体中文)2016-01-23T03:25:20Z<p>无极: /* 手动启动 */</p>
<hr />
<div>[[Category:Desktop environments (简体中文)]]<br />
[[cs:GNOME]]<br />
[[de:GNOME]]<br />
[[en:GNOME]]<br />
[[es:GNOME]]<br />
[[fr:GNOME]]<br />
[[it:GNOME]]<br />
[[ja:GNOME]]<br />
[[nl:GNOME]]<br />
[[pl:GNOME]]<br />
[[pt:GNOME]]<br />
[[ru:GNOME]]<br />
[[sr:GNOME]]<br />
[[th:GNOME]]<br />
[[tr:Gnome Masaüstü Ortamı]]<br />
[[uk:GNOME]]<br />
[[zh-TW:GNOME]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Desktop environment}}<br />
{{Related|Display manager}}<br />
{{Related|Window manager}}<br />
{{Related|GTK+}}<br />
{{Related|GDM}}<br />
{{Related|GNOME Files}}<br />
{{Related|Gedit}}<br />
{{Related|Epiphany}}<br />
{{Related|GNOME Flashback}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|GNOME|2015-10-05|400254}}<br />
<br />
GNOME (pronounced ''gah-nohm'' or ''nohm'')是一个简单易用的[[Desktop environment (简体中文)|桌面环境 ]].它由[[Wikipedia:The GNOME Project|The GNOME Project]] 设计并且完全自由和开源. GNOME是[[Wikipedia:GNU Project|GNU Project]]的一部分.<br />
<br />
== 安装 ==<br />
<br />
以下两个软件包(组)均包含 GNOME 的组件:<br />
<br />
'''gnome''' 包组包含基本桌面环境和软件,以提供标准的 GNOME 体验。<br />
<br />
'''gnome-extra''' 包组包含剩余的可选工具,例如文本编辑器、压缩文件管理器、光盘烧录工具、邮件客户端、游戏、开发工具及其它非必需的软件。这些软件与 GNOME 桌面的集成很好。假如您不想安装 GNOME 全部的软件包,在安装它的时候注意看软件包描述(或者你可以先安装再删除他们)。<br />
<br />
{{Note|''mutter'' acts as a composite manager for the desktop, employing hardware graphics acceleration to provide effects aimed at reducing screen clutter. The GNOME session manager automatically detects if your video driver is capable of running GNOME Shell and if not, falls back to software rendering using ''llvmpipe''.}} <br />
<br />
=== 附加的软件包 ===<br />
<br />
上面提到的包组不包括这些包:<br />
* {{App|[[Wikipedia:GNOME Boxes|Boxes]]|A simple user interface to access [[libvirt]] virtual machines.|https://wiki.gnome.org/Apps/Boxes|{{Pkg|gnome-boxes}}}}<br />
* {{App|GNOME Initial Setup|A simple, easy, and safe way to prepare a new system.|https://github.com/GNOME/gnome-initial-setup|{{Pkg|gnome-initial-setup}}}}<br />
* {{App|GNOME PackageKit|Collection of graphical tools for PackageKit to be used in the GNOME desktop.|https://github.com/GNOME/gnome-packagekit|{{Pkg|gnome-packagekit}}}}<br />
* {{App|[[Wikipedia:Nemiver|Nemiver]]|A C/C++ debugger.|https://wiki.gnome.org/Apps/Nemiver|{{Pkg|nemiver}}}}<br />
* {{App|[[Wikipedia:GNOME Software|Software]]|Lets you install and update applications and system extensions.|https://wiki.gnome.org/Apps/Software/|{{Pkg|gnome-software}}}}<br />
<br />
== GNOME会话==<br />
<br />
GNOME 有三个可用的会话,都使用 GNOME Shell<br />
*'''GNOME''' 是默认会话, 有创新的布局<br />
*'''GNOME Classic''' 的桌面布局类似于传统的GNOME 2, using pre-activated extensions and parameters. [http://worldofgnome.org/welcome-to-gnome-3-8-flintstones-mode/] Hence it is more a customized GNOME Shell than a truly distinct mode<br />
*'''GNOME on Wayland''' GNOME Shell 在新的Wayland协议上运行. 而传统的 X 应用程序在Xwayland上运行<br />
<br />
== 运行 GNOME ==<br />
<br />
GNOME可以通过 [[display manager (简体中文)|显示管理器]]以图形方式启动,或者从控制台手动启动。 为优化桌面整合, 建议使用[[GDM (简体中文)]] (GNOME显示管理器)。<br />
注意 [[systemd (简体中文)#使用单元|启用]] 一个显示管理器(例如GDM)意味着Xorg将会以root权限运行. <br />
{{注意| 如果不使用 GDM,你将无法体验到对锁屏的原生支持,因此你不得不使用另一个屏幕锁来提供类似功能,参见[[Xmonad (简体中文)#GNOME 3 and xmonad]].}}<br />
<br />
=== 图形界面登录===<br />
<br />
可以在登录管理器中选择 ''GNOME', ''GNOME Classic'' 或 ''GNOME on Wayland'' 作为登录选项。<br />
<br />
=== 手动启动 ===<br />
<br />
* 对于标准的GNOME会话, 在{{ic|~/.xinitrc}} 中添加:{{ic|exec gnome-session}}.<br />
* 对于经典的gnome会话,在 {{ic|~/.xinitrc}} 中添加:{bc|<nowiki>export XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME<br />
export GNOME_SHELL_SESSION_MODE=classic<br />
exec gnome-session --session=gnome-classic</nowiki>}}<br />
{{注意|最好把gnome--session之前的应用注释掉,我之前因为没有注释掉{{ic|twm}}(另一个窗口管理器)导致启动gnome失败}}<br />
我现在的{{ic|/etc/X11/xinit/xinitrc}}如下:<br />
{{bc|#twm &<br />
#xclock -geometry 50x50-1+1 &<br />
#xterm -geometry 80x50+494+51 &<br />
#xterm -geometry 80x20+494-0 &<br />
#exec xterm -geometry 80x66+0+0 -name login<br />
exec gnome-session}}<br />
<br />
改完{{ic|~/.xinitrc}} ,即可用{{ic|startx}} 启动Gnome (see [[xinitrc]] for additional details, such as preserving the logind session). After setting up the {{ic|~/.xinitrc}} file it can also be arranged to [[Start X at login]].<br />
<br />
{{Note|Wayland 上的Gnome需要r {{Pkg|xorg-server-xwayland}} 包, 不能使用 ''startx'' 和{{ic|~/.xinitrc}},而是要运行 {{ic|gnome-session --session&#61;gnome-wayland}}. 更多参见 [[Wayland]].}}<br />
<br />
===Wayland 中的 GNOME 应用程序===<br />
<br />
根据当前的默认情况,GNOME 应用程序会利用 XWayland,以传统 X 应用程序的方式运行。若需在 Wayland 下测试 GNOME 应用,请以命令行方式运行程序,并加上以下前缀: {{ic|env GDK_BACKEND&#61;wayland <command>}}。<br />
<br />
{{Note|可以设置全局的 Wayland 环境,使用 {{ic|env GDK_BACKEND&#61;wayland gnome-session --session&#61;gnome-wayland}}。 但是现在无法工作—— ''gnome-session'' 会立即闪退.}}<br />
<br />
请查看以下页面以了解开发进展: [https://wiki.gnome.org/Initiatives/Wayland/Applications/ GNOME Applications under Wayland].<br />
<br />
== 导览 ==<br />
<br />
您可以阅读这篇文章: [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell cheat sheet] 以了解如何高效地使用 GNOME shell,它展示了 GNOME shell 的特色与使用快捷键。文章内容包括怎么切换任务,使用键盘,窗口控制,使用面板,预览模式等。<br />
部分常用的快捷键:<br />
<br />
* {{ic|Super}}: 进入预览模式<br />
* {{ic|Super}} + {{ic|m}}: 显示消息托盘<br />
* {{ic|Super}} + {{ic|a}}:显示应用程序菜单<br />
* {{ic|Alt}} + {{ic|F2}}:输入命令以快速启动应用<br />
* {{ic|Alt}} + {{ic|F2}},然后输入 {{ic|r}} 或 {{ic|restart}},再 {{ic|Enter}}:重启 GNOME shell。这一条在你遇到 shell 图形界面错误时十分有用。<br />
<br />
=== 重启 GNOME shell ===<br />
<br />
当修改过界面之后你可能需要重启 GNOME shell。你可以重新登陆,不过有一个简单快捷的方法。 按 {{ic|Alt}} + {{ic|F2}} 再输入 {{ic|r}} 再 {{ic|Enter}}<br />
<br />
=== GNOME Shell 崩溃 ===<br />
<br />
一些特定的微调或者经常性重启 Shell 会导致 shell 在将要重启的时候崩溃。这个时候你必须做好心理准备,然后强制注销。有一些修改,例如在'''''GNOME Shell''''' 和 '''''fallback mode,''''' 之间切换,不能简单地使用 r 重启;必须重登陆来应用这个效果。<br />
<br />
丑话说在前面,在重启 shell 前请先把有用的文档保存(或者关闭)。虽然这不是必要的,因为窗口和文档在重启了 shell 之后应该还在。<br />
<br />
=== 遗留名称 ===<br />
{{注意|<br />
一些GNOME程序在文档和关于对话框的名称已更改,但可执行文件的名称却没有。这样的应用程序在下面表格列出.}}<br />
<br />
{{提示|在搜索栏中搜索的应用程序的遗留名称将成功返回现在的应用程序,例如搜索''nautilus''将返回''Files''.}}<br />
<br />
{| class="wikitable"<br />
! Current<br />
! Legacy<br />
|-<br />
| [[Files]]<br />
| Nautilus<br />
|-<br />
| [[GNOME Web|Web]]<br />
| Epiphany<br />
|-<br />
| Videos<br />
| Totem<br />
|-<br />
| Main Menu<br />
| Alacarte<br />
|-<br />
| Document Viewer<br />
| Evince<br />
|-<br />
| Disk Usage Analyser<br />
| Baobab<br />
|-<br />
| Image Viewer<br />
| EoG (Eye of GNOME)<br />
|-<br />
| [[GNOME Keyring|Passwords and Keys]]<br />
| Seahorse<br />
|}<br />
<br />
== 配置 ==<br />
<br />
GNOME 3 是重新设计的,但是像大多数大型软件项目一样,他是很多不同时间的部分组装起来的。他没有一个 '''无所不包''' 的配置工具。新的 ''系统设置'' 比以前的控制面板有很大的改进。 ''系统设置'' 组织得很好,但是你可能想要更深层次地改变外观。<br />
<br />
以前你所熟悉的配置工具现在有的好用,有的不好用了。有些设置选项隐藏着,不太容易找到。许多设置将会,或已经迁移到了新的工具上。你需要了解应当去哪里寻找适当的设置项,才能更好地配置 GNOME 外观。 <br />
<br />
GNOME 桌面环境依赖于一个存储配置的数据库后端(DConf)来存储 GNOME 与 GNOME 应用的设置。安装桌面环境时,GNOME 提供一套默认的配置,而各类应用程序向数据库中添加它们自己的配置。<br />
<br />
对用户来说,最基础而直观的配置方式莫过于使用 GNOME 系统设置面板(gnome-control-center),以及 GNOME 应用程序各自的首选项(preferences)面板。如果您愿意,直接在 DConf 数据库中进行修改与配置总是可行的,尤其是在某些设置选项没有暴露在用户界面的情况下,直接修改可以更改某些隐藏选项。<br />
<br />
GNOME 的这些配置通常是用户间相互独立的。以下文字仅供单用户配置所用,并没有提及更改全局配置模板的方法。<br />
<br />
=== GNOME 系统设置 ===<br />
<br />
系统设置工具包括了一些最基础的 GNOME 环境配置选项。<br />
<br />
==== 色彩设置 ====<br />
<br />
{{ic|colord}} 守护进程读取显示器的 [https://zh.wikipedia.org/wiki/EDID EDID]信息,并提取出合适的色彩配置内容。大多数情况下,自动色彩配置都是正确的,不需要额外设置;但是对于可能出现的偏差情况,例如使用较旧的显示器时,您可以将色彩配置文件放在 {{ic|~/.local/share/icc/}} 下,并在设置面板里启用。<br />
<br />
==== 日期与时间 ====<br />
<br />
如果系统已有配置好的 [https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon_(简体中文) NTP 守护进程],它同样会对 GNOME 桌面环境起作用。如果需要,您也可以手动控制进行同步。<br />
<br />
如需在顶栏显示日期,请运行:<br />
<br />
$ gsettings set org.gnome.desktop.interface clock-show-date true<br />
<br />
另外,如需在 shell 的日历中显示周数,请运行:<br />
<br />
$ gsettings set org.gnome.shell.calendar show-weekdate true<br />
<br />
当然,以上配置均可以在 {{ic|gnome-tweak-tool}} 里完成。<br />
<br />
==== 默认应用程序 ==== <br />
<br />
Upon installing GNOME for the first time, you may find that the wrong applications are handling certain protocols. For example, ''totem'' opens videos instead of a previously used [[VLC]]. Some of the associations can be set from system settings via: ''System'' > ''Details'' > ''Default applications''. <br />
<br />
For other protocols and methods see [[Default applications]] for configuration.<br />
<br />
==== 鼠标和触摸板 ====<br />
<br />
为了帮助减少触摸板的干扰,你可能希望实现以下设置:<br />
<br />
* 禁用触摸板,打字时<br />
* 禁用滚动<br />
* 禁用点击<br />
<br />
==== 网络 ====<br />
<br />
[[NetworkManager]] is the native tool of the GNOME project to control network settings from the shell. It is installed by default as a dependency for {{Pkg|tracker}} package, which is a part of {{Grp|gnome}} group, and just needs to be [[NetworkManager#Enable NetworkManager|enabled]].<br />
<br />
While any other [[List_of_applications/Internet#Network_managers|network manager]] can be used as well, NetworkManager provides the full integration via the shell network settings and a status indicator applet {{Pkg|network-manager-applet}} (not required for GNOME).<br />
<br />
==== 在线帐户 ====<br />
<br />
Backends for the GNOME messaging application {{Pkg|empathy}} as well as the GNOME Online Accounts section of the System Settings panel are provided in a separate group: {{Grp|telepathy}}. See [[#Unable to add accounts in Empathy and GNOME Online Accounts]]. Some online accounts, such as [[ownCloud]], require {{Pkg|gvfs-goa}} to be installed for full functionality in GNOME applications such as [[GNOME Files]] and GNOME Documents [https://wiki.gnome.org/ThreePointSeven/Features/Owncloud].<br />
<br />
==== 搜索 ====<br />
<br />
The GNOME shell has a search that can be quickly accessed by pressing the {{ic|Super}} key and starting to type. The {{Pkg|tracker}} package is installed by default as a part of {{Grp|gnome}} group and provides an indexing application and metadata database. It can be configured with the ''Search and Indexing'' menu item; monitor status with ''tracker-control''. It is started automatically by ''gnome-session'' when the user logs in. Indexing can be started manually with {{ic|tracker-control -s}}. Search settings can also be configured in the ''System Settings'' panel.<br />
<br />
The Tracker database can be queried using the ''tracker-sparql'' command. View its manual page {{ic|man tracker-sparql}} for more information.<br />
<br />
<br />
=== 高级设置 ===<br />
==== 外观 ====<br />
<br />
=====GTK+主题和图标主题=====<br />
除了以下所述的直接从底层修改主题的方法,您也可以使用 gnome-tweak-tool 工具进行修改。 <br />
安装一个新的主题和图标集,分别添加相关的{{ic|~/.local/share/themes}} 或者 {{ic|~/.local/share/icons}} respectively (add to {{ic|/usr/share/}} instead of {{ic|~/.local/share/}} for the themes to be available systemwide.) 他们和其他GUI设置也可以在 {{ic|~/.config/gtk-3.0/settings.ini}}中定义:<br />
<br />
{{hc|~/.config/gtk-3.0/settings.ini|<nowiki><br />
[Settings]<br />
gtk-theme-name = Adwaita<br />
# next option is applicable only if selected theme supports it<br />
gtk-application-prefer-dark-theme = true<br />
# set font name and dimension<br />
gtk-font-name = Sans 10<br />
</nowiki>}}<br />
<br />
其他主题的站点:<br />
* [http://www.deviantart.com/browse/all/customization/skins/linuxutil/desktopenv/gnome/gtk3/ DeviantArt].<br />
* [http://gnome-look.org/index.php?xcontentmode=167 gnome-look.org].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=gtk3&do_Search=Go GTK3 themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=xcursor&do_Search=Go&PP=50&SB=v&SO=d Cursor themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=icon-theme&do_Search=Go&PP=50&SB=v&SO=d Icon themes in the AUR].<br />
<br />
一旦安装,就可以使用 GNOME Tweak Tool或GSettings -参阅下面的GSettings命令:<br />
<br />
对于GTK+主题:<br />
$ gsettings set org.gnome.desktop.interface gtk-theme ''theme-name''<br />
<br />
对于图标主题<br />
$ gsettings set org.gnome.desktop.interface icon-theme ''theme-name''<br />
<br />
====== 全局暗色主题======<br />
<br />
GNOME will use the Adwaita light theme by default however a dark variant of this theme (called the Global Dark Theme) also exists and can be selected using the Tweak Tool or by editing the GTK+ 3 settings file - see [[GTK+#Dark theme variant]]. Some applications such as Image Viewer (''eog'') use the dark theme by default. It should be noted that the Global Dark Theme only works with GTK+ 3 applications; some GTK+ 3 applications may only have partial support for the Global Dark theme. Qt and GTK+ 2 support for the Global Dark Theme may be added in the future.<br />
<br />
===== 窗口管理器主题=====<br />
<br />
The window manager theme (the style of the window titlebars) can be set using the GNOME Tweak Tool or the following GSettings command:<br />
$ gsettings set org.gnome.desktop.wm.preferences theme ''theme-name''<br />
<br />
====== 标题栏的高度 ======<br />
<br />
{{注意|在GNOME 3.16中,Mutter不再使用metacity主题。相反,标题栏的装饰主题使用GTK+。}}<br />
<br />
改变标题栏的高度,创建以下文件,调整填充所需:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<br />
.header-bar.default-decoration {<br />
padding-top: 3px;<br />
padding-bottom: 3px;<br />
}<br />
<br />
.header-bar.default-decoration .button.titlebutton {<br />
padding-top: 2px;<br />
padding-bottom: 2px;<br />
}<br />
}}<br />
<br />
标题栏的高度也可以通过选择一个较小的字体。默认情况下,字体设置为Cantarell Bold 11。您可能希望将字体设置为较小的,例如Sans Bold 10. 你可以这样使用以下GSettings命令来完成:<br />
$ gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Sans Bold 10'<br />
<br />
====== 标题栏按钮重新排序 ======<br />
<br />
设置 GNOME 窗口管理器顺序 (Mutter, Metacity): <br />
$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'<br />
<br />
{{提示|冒号表示窗口标题栏的按钮会出现在哪一方}}<br />
<br />
====== 最大化时隐藏标题栏 ======<br />
<br />
*[[Install]] {{AUR|mutter-hide-legacy-decorations}}. It changes a default setting in the window manager, so as to automatically hide the titlebar on legacy (non-headerbar) apps when they are maximized or tiled to the side.<br />
<br />
*[[Install]] {{AUR|maximus}}. To start the application, execute ''maximus'' from a terminal. When running, the daemon will automatically maximize windows. It will undecorate maximized windows and redecorate them when they are unmaximized. If you do not want all windows to start maximized, run {{ic|maximus -m}} instead. Note that this will only work with windows decorated by the window manager; applications that use client-side decoration such as [[GNOME Files]] will not be undecorated when maximized.<br />
===== GNOME Shell主题 =====<br />
<br />
The theme of GNOME Shell itself is configurable. To use a Shell theme, firstly ensure that you have the {{Pkg|gnome-shell-extensions}} package installed. Then enable the ''User Themes'' extension, either through GNOME Tweak Tool or through the [https://extensions.gnome.org GNOME Shell Extensions] webpage. Shell themes can then be loaded and selected using the GNOME Tweak Tool.<br />
<br />
There are a number of GNOME Shell themes available [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-theme&do_Search=Go&PP=50&SB=v&SO=d in the AUR].<br />
<br />
Shell themes can also be downloaded from [http://gnome-look.org/index.php?xcontentmode=191 gnome-look.org].<br />
==== 桌面 ====<br />
<br />
各种桌面设置可以应用。<br />
<br />
===== 桌面上的图标 =====<br />
<br />
参阅 [[GNOME Files#Desktop Icons]].<br />
<br />
===== 锁屏和背景=====<br />
<br />
When setting the Desktop or Lock screen background, it is important to note that the Pictures tab will only display pictures located in {{ic|/home/''username''/Pictures}} folder. If you wish to use a picture not located in this folder, use the commands indicated below.<br />
<br />
对于桌面背景:<br />
$ gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
对于锁屏背景<br />
$ gsettings set org.gnome.desktop.screensaver picture-uri 'file:///path/to/my/picture.jpg'<br />
====扩展 ====<br />
<br />
{{注意|通过 The GNOME Shell browser plugin(即 [https://extensions.gnome.org extensions.gnome.org])安装扩展的方法暂时无法在 Chrome/Chromium 35 或更高的版本上进行。用户应当采用其它对网页安装更兼容的浏览器进行安装,如 [[Firefox (简体中文)]] 或 [[GNOME/Web]]。}}<br />
<br />
GNOME Shell 可以使用第三方扩展来定制。这些扩展提供了一些额外的功能,如:提供一个可以一直显示的 Dock、更换 Shell 的主题,等等。<br />
<br />
名为 {{Pkg|gnome-shell-extensions}} 的软件包提供了一组由 The GNOME Project 维护,被当做 GNOME 计划的一部分的扩展,其中许多扩展被用在了 GNOME Classic 会话环境中。(最新版本的扩展你可以用他的代码 snapshot)[https://www.archlinux.org/packages/?sort=&q=gnome-shell-extension&maintainer=&last_update=&flagged=&limit=50 列表在这里]<br />
<br />
$ pacman -Ss gnome-shell-extension<br />
<br />
另外,有许多扩展被收集并托管在了[https://extensions.gnome.org extensions.gnome.org] 上。你可以在浏览器中浏览扩展列表,并轻松地一键点击来安装、管理、启用扩展。你可以在 [https://extensions.gnome.org/about/ 这里]找到有关插件的更多信息。<br />
<br />
你也可以在 [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-extension&do_Search=Go AUR]里面找到一些有用的扩展。当然,它们大多也可以在 [https://extensions.gnome.org extensions.gnome.org] 找到。一些值得一提的是:<br />
<br />
* {{AUR|gnome-shell-extension-lockkeys-git}} 一个指示 NumLock/CapsLock 激活情况的扩展。<br />
* {{AUR|gnome-shell-extension-weather-git}} 一个可以显示天气通知的扩展。<br />
* {{AUR|gnome-shell-extension-nohotcorner-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-nohotcorner-git}}}} 一个禁用“Hot Corner”功能的拓展。<br />
* {{AUR|gnome-shell-extension-insensitive-message-tray-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-insensitive-message-tray-git}}}} 使鼠标在屏幕底部激活信息托盘的行为变迟钝的拓展。<br />
*[https://extensions.gnome.org/extension/5/alternative-status-menu/ Alternative Status Menu] 让你的用户菜单里显示休眠和关机的扩展。<br />
<br />
另外,想要在屏幕底部显示一个任务栏,但又不想使用 GNOME Classic 的用户可以考虑使用 Window list 扩展 (由 {{Pkg|gnome-shell-extensions}} 提供).<br />
<br />
在安装完一个扩展之后可能需要[[#重启_GNOME_shell|重启 GNOME shell ]] 。故障排除信息参照[[#安装扩展导致GNOME停止工作|安装扩展导致GNOME停止工作]]。<br />
<br />
==== 输入法 ====<br />
<br />
GNOME集成了的通过[[IBus]]的输入法, 只有{{Pkg|ibus}}和添加想要的输入法引擎 (例如:{{Pkg|ibus-libpinyin}} for Intelligent Pinyin) 需要安装,安装后,输入法引擎可以加入GNOME的区域和语言设置键盘布局。<br />
<br />
==== 字体 ====<br />
<br />
{{Tip|If you set the ''Scaling factor'' to a value above 1.00, the Accessibility menu will be automatically enabled.}}<br />
<br />
Fonts can be set for Window titles, Interface (applications), Documents and Monospace. See the Fonts tab in the Tweak Tool for the relevant options.<br />
<br />
For hinting, RGBA will likely be desired as this fits most monitors types, and if fonts appear too blocked reduce hinting to ''Slight'' or ''None''.<br />
==== 启动应用程序====<br />
要启动登录某些应用程序, copy the relevant {{ic|.desktop}} file from {{ic|/usr/share/applications/}} to {{ic|~/.config/autostart/}}.<br />
可以使用Tweak Tool.来达到同样的效果。<br />
<br />
{{Tip|If the plus sign button in the Tweak Tool's Startup Applications section is unresponsive, try start the Tweak Tool from the terminal using the following command: {{ic|gnome-tweak-tool}}. See the following [https://bbs.archlinux.org/viewtopic.php?pid&#61;1413631#p1413631 forum thread].}}<br />
<br />
{{Note|The ''gnome-session-properties'' dialog was removed as of GNOME 3.12. It can be added back by [[install]]ing the {{AUR|gnome-session-properties}} package.}}<br />
==== 电源 ====<br />
<br />
The basic power settings that may want to be altered (these example settings assume the user is using a laptop - change them as desired):<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.power button-power ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout ''3600''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout ''1800''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type ''hibernate''<br />
$ gsettings set org.gnome.desktop.lockdown disable-lock-screen ''true''<br />
<br />
To keep a monitor active on lid close: <br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup do-nothing<br />
<br />
===== Configure behaviour on lid switch close =====<br />
<br />
The GNOME Tweak Tool, as of version 3.17.1, can optionally ''inhibit'' the ''systemd'' setting for the lid close ACPI event.[http://ftp.gnome.org/pub/GNOME/sources/gnome-tweak-tool/3.17/gnome-tweak-tool-3.17.1.news] To ''inhibit'' the setting, start the Tweak Tool and, under the power tab, check the ''Don't suspend on lid close'' option. This means that the system will do nothing on lid close instead of suspending - the default behaviour. Checking the setting creates {{ic|~/.config/autostart/ignore-lid-switch-tweak.desktop}} which will autostart the Tweak Tool's inhibitor.<br />
<br />
If you do not want the system to suspend or do nothing on lid close, you will need to ensure that the setting described above is '''not''' checked and then configure ''systemd'' with {{ic|1=HandleLidSwitch=''preferred_behaviour''}} as described in [[Power management#ACPI events]].<br />
<br />
===== Change critical battery level action =====<br />
<br />
The System Settings panel only allows the user to choose between ''Suspend'' or ''Hibernate''. To choose another option such as ''Do Nothing'' open the {{ic|dconf-editor}} and navigate to {{ic|org.gnome.settings-daemon.plugins.power}}. Edit the {{ic|"critical-battery-action"}} value to {{ic|"nothing"}}.<br />
<br />
==== Sort applications into application (app) folders ====<br />
<br />
{{Tip|The [https://github.com/prurigro/gnome-catgen gnome-catgen] ({{AUR|gnome-catgen-git}}) script allows you to manage folders through the creation of files in {{ic|~/.local/share/applications-categories}} named after each category and containing a list of the desktop files belonging to apps you'd like to have inside. Optionally, you can have it cycle through each app without a folder and input the desired category until you ctrl-c or run out of apps.}}<br />
<br />
In the '''dconf-editor''' navigate to {{ic|org.gnome.desktop.app-folders}} and set the value of {{ic|folder-children}} to an array of comma separated folder names:<br />
<br />
['Utilities', 'Sundry']<br />
<br />
Add applications using {{ic|gsettings}}:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ apps "['alacarte.desktop', 'dconf-editor.desktop']"<br />
<br />
This adds the applications {{ic|alacarte.desktop}} and {{ic|dconf-editor.desktop}} to the Sundry folder. This will also create the folder {{ic|org.gnome.desktop.app-folders.folders.Sundry}}.<br />
<br />
To name the folder (if it has no name that appears at the top of the applications):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ name "Sundry"<br />
<br />
Applications can also be sorted by their category (specified in their ''.desktop'' file):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ categories "['Office']"<br />
<br />
If certain applications matching a category are not wanted in a certain folder, exclusions can be set:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ excluded-apps "['libreoffice-draw.desktop']"<br />
<br />
For further information, refer to the [https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.app-folders.gschema.xml.in.in app-folders schema].<br />
<br />
== 提示与技巧==<br />
<br />
其他GNOME系统设置和提示。 <br />
<br />
=== 键盘 ===<br />
<br />
==== 登陆打开NumLock键 ====<br />
<br />
运行以下命令:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state on<br />
<br />
==== 热键选择====<br />
<br />
很多的快捷键可以通过系统设置菜单中更改. 例如,重新启用“显示桌面快捷键:<br />
<br />
''System settings'' > ''Keyboard'' > ''Shortcuts'' > ''Navigation'' > ''Hide all normal windows''<br />
<br />
However, certain hotkeys cannot be changed directly via system settings. In order to change these keys, use ''dconf-editor''. An example of particular note is the hotkey {{ic|Alt-}} + {{ic|`}} (the key above {{ic|Tab}} on US keyboard layouts). In GNOME Shell it is pre-configured to cycle through windows of an application, however it is also a hotkey often used in the [[Emacs]] editor. It can be changed by opening ''dconf-editor'' and modifying the ''switch-group'' key found in {{ic|org.gnome.desktop.wm.keybindings}}.<br />
<br />
It is possible to manually change the keys via an application's so-called '''accel''' map file. Where it is to be found is up to the application: For instance, Thunar's is at {{ic|~/.config/Thunar/accels.scm}}, whereas Files's is located at {{ic|~/.config/nautilus/accels}} and {{ic|~/.gnome2/accels/nautilus}} on old release.<br />
<br />
The file should contain a list of possible hotkeys, each unchanged line commented out with a leading ";" that has to be removed for a change to become active.<br />
For example to replace the hotkey used by Files to move files to the trash folder, change the line:<br />
<br />
; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete")<br />
to this:<br />
<br />
(gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete")<br />
<br />
The file is regenerated regularly so do not comment the file. The uncommented line will stay but every comment you add will be lost.<br />
<br />
==== 打开键盘开关命令 ====<br />
<br />
To have keyboard shortcut '''Alt''' + '''Shift''' switch keyboards:<br />
<br />
Open Gnome-Tweak-Tool (or Keyboard Settings, in GNOME 3.16) and set ''Typing'' > ''Modifiers-only input sources'' > ''select Alt-shift''. For more information see also the forum [https://bbs.archlinux.org/viewtopic.php?id=152127 thread].<br />
<br />
==== XkbOptions键盘选项 ====<br />
<br />
Using the '''dconf-editor''', navigate to the key named {{ic|org.gnome.desktop.input-sources.xkb-options}} and add desired XkbOptions (e.g. ''caps:swapescape'') to the list.<br />
<br />
See {{ic|/usr/share/X11/xkb/rules/xorg}} for all XkbOptions and {{ic|/usr/share/X11/xkb/symbols/*}} for the respective descriptions.<br />
<br />
{{Note|To enable the {{ic|Ctrl+Alt+Backspace}} combination to terminate Xorg, use the {{Pkg|gnome-tweak-tool}}. Within the '''Tweak Tool''', navigate to ''Typing > Key sequence to kill the X server'' and select the option {{ic|Ctrl+Alt+Backspace}} from the dropdown menu.}}<br />
<br />
==== De-bind Windows key ====<br />
<br />
默认情况下,“Windows键”将打开GNOMEshelly预览模式。 You can unbind this key by running the command below<br />
<br />
$ gsettings set org.gnome.mutter overlay-key 'Foo'<br />
<br />
=== 磁盘===<br />
<br />
GNOME提供磁盘实用程序来操作的存储驱动器设置。这是它的一些特点:<br />
<br />
* '''Enable write cache''' is a feature that most hard drives provide. Data is cached and allocated at chosen times to improve system performance. Not recommended unless the computer has a backup battery pack or is a laptop as data would be lost on power failure.<br />
: ''Settings'' > ''Drive Settings'' > ''Write Cache'' > '''On'''<br />
* '''Automatic Mount Options''' can mount drives and partitions that are GPT based - will use default, recommended options.<br />
: {{Warning|This setting erases related [[fstab]] entries}}<br />
: ''Partition Settings'' > ''Edit Mount Options'' > ''Automatic Mount Options'' > '''On'''<br />
<br />
=== 从菜单隐藏的应用程序===<br />
<br />
{{Tip|Desktop entries can be hidden by editing the {{ic|.desktop}} files themselves. See [[Desktop entries#Hide desktop entries]].}}<br />
<br />
Use the ''Main Menu'' application (provided by the {{Pkg|alacarte}} package) to hide any applications you do not wish to show in the menu.<br />
<br />
=== 截屏记录 ===<br />
<br />
GNOME features built-in screencast recording with the '''Ctrl''' + '''Shift''' + '''Alt''' + '''R''' key combination. A red circle is displayed in the bottom right corner of the screen when the recording is in progress. After the recording is finished, a file named {{ic|Screencast from %d%u-%c.webm}} is saved in the Videos directory. In order to use the screencast feature the gst plugins need to be installed.<br />
<br />
=== 截图 ===<br />
<br />
默认保存目录:<br />
<br />
$ gsettings set org.gnome.gnome-screenshot auto-save-directory file:///home/''USER''/Desktop<br />
<br />
Check the ''gnome-screenshot'' manual page for more options.<br />
<br />
===注销延迟 ===<br />
去掉注销的确认和 60 秒的延迟:<br />
这个对话框一般出现在你用状态菜单注销的时候。这个修改对于 关机 也生效。这个不是全局修改,只对使用该命令的用户生效。使用该命令立即生效。<br />
$ gsettings set org.gnome.SessionManager logout-prompt false<br />
<br />
=== 禁用动画 ===<br />
<br />
To disable Shell animations (such as "Show Applications" and the wave animation in the top left activities hot corner), run:<br />
<br />
$ gsettings set org.gnome.desktop.interface enable-animations false<br />
<br />
=== Retina (HiDPI) display support ===<br />
<br />
GNOME introduced HiDPI support in version 3.10. If your display does not provide the correct screen size through EDID, this can lead to incorrectly scaled UI elements. As a workaround you can open ''dconf-editor'' and find the key {{ic|scaling-factor}} in {{ic|org.gnome.desktop.interface}}. Set it to {{ic|1}} to get the standard scale.<br />
<br />
Also see [[HiDPI]].<br />
<br />
=== 密码和密钥 (PGP Keys) ===<br />
<br />
You can use the Passwords and Keys program (''seahorse'') to create a PGP key as it is a front end for [[GnuPG]] and installs it as dependency. This may be useful in the future (for instance if to encrypt a file). Create a key as shown below (the process may take about 10 minutes):<br />
<br />
''File'' > ''New'' > ''PGP Key'' > ''Name'' > ''Email'' > ''Defaults'' > ''Passphrase''.<br />
<br />
=== 终端 ===<br />
<br />
==== 更改默认的终端大小====<br />
<br />
新终端的默认大小可以在''编辑 > 配置文件首选项 ''中调整<br />
<br />
==== 新终端采用当前目录====<br />
<br />
By default new terminals open in the {{ic|$HOME}} directory. To have new terminals adopt the current working directory: {{ic|source /etc/profile.d/vte.sh}}. Add the command to the shell configuration to retain the behaviour.<br />
<br />
==== Pad the terminal ====<br />
<br />
To pad the terminal (create a small, invisible border between the window edges and the terminal contents) create the file below:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<nowiki><br />
VteTerminal,<br />
TerminalScreen {<br />
padding: 10px 10px 10px 10px;<br />
-VteTerminal-inner-border: 10px 10px 10px 10px;<br />
}</nowiki>}}<br />
<br />
==== 禁用光标闪烁====<br />
<br />
Since GNOME 3.8 and the migration to GSettings and DConf the key required to modify in order to disable the blinking cursor in the Terminal differs slightly in contrast to the old GConf key. To disable the blinking cursor in GNOME 3.8 and above use:<br />
<br />
$ gsettings set org.gnome.desktop.interface cursor-blink false<br />
<br />
To disable the blinking cursor in Terminal only use (make sure profile uid is correct one):<br />
<br />
$ dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/cursor-blink-mode "'off'"<br />
<br />
Note that {{ic|gnome-settings-daemon}}, from the package of the same name, must be running for this and other settings changes to take effect in GNOME applications - see [[GNOME#Configuration]].<br />
<br />
====关闭终端时,禁用确认窗口====<br />
<br />
试图关闭该窗口,而一个以root身份登录时,终端将始终显示一个确认窗口。为了避免这种情况,执行以下命令:<br />
$ gsettings set org.gnome.Terminal.Legacy.Settings confirm-close false<br />
<br />
=== 鼠标中键===<br />
<br />
By default, GNOME 3 disables middle mouse button emulation regardless of [[Xorg]] settings ('''Emulate3Buttons'''). To enable middle mouse button emulation use:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.mouse middle-button-enabled true<br />
<br />
=== 启用按钮和菜单图标===<br />
<br />
Since GTK+ 3.10, the GSettings key 'menus-have-icons' has been deprecated. Icons in buttons and menus can still be enabled by setting the following overrides:<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"<br />
<br />
=== 使用自定义的色彩和渐变色的桌面背景 ===<br />
使用自定义颜色和渐变为您的桌面背景,您首先需要设置一个透明的图片或其他不存在的图片作为您的桌面背景。例如,下面的命令将设置一个不存在的图片为背景。<br />
<br />
$ gsettings set org.gnome.desktop.background picture-uri none<br />
<br />
在这一点上,桌面背景应该是一个平坦的颜色-默认的颜色设置为深蓝色。<br />
<br />
对于不同的平面彩色你只需要改变的主要颜色设置:<br />
<br />
$ gsettings set org.gnome.desktop.background primary-color <my color><br />
where <my color> is a hex value (such as ''ffffff'' for white).<br />
<br />
对于颜色渐变,你也需要改变次要颜色设置 {{ic|org.gnome.desktop.background secondary-color}} <br />
并选择一个阴影类型。举例来说,如果你想有一个horizontal gradient,执行以下命令:<br />
$ gsettings set org.gnome.desktop.background color-shading-type horizontal<br />
<br />
如果你是使用一个透明的图片作为你的背景,你可以通过执行以下设置的透明度:<br />
$ gsettings set org.gnome.desktop.background picture-opacity <value><br />
数值在100和1之间(最大不透明度为100)。<br />
<br />
=== 渐变背景===<br />
<br />
GNOME 可以在特定的时间间隔之间的使用不同的壁纸。 这是通过创建一个XML文件,指定要使用的图片和时间间隔完成的。有关创建这些文件的详细信息,请参阅下面的 [http://www.linuxjournal.com/content/create-custom-transitioning-background-your-gnome-228-desktop article].<br />
<br />
可替代地,一些工具可用自动化过程:<br />
* {{App|mkwlppr|This script creates XML files that can act as dynamic wallpapers for GNOME by referring to multiple wallpapers.|http://pastebin.com/019G2rCy|see [http://pastebin.com/019G2rCy mkwlppr]}}<br />
* {{App|[[Wallpapoz]]|Wallpapoz is a tool that provides dynamic wallpapers for GNOME and Xfce desktops.|https://vajrasky.wordpress.com/|{{AUR|wallpapoz}}}}<br />
* {{App|CreBS|A Python/GTK application used to create and set desktop wallpaper slideshows for GNOME.|http://www.obfuscatepenguin.net/|{{AUR|crebs}}}}<br />
<br />
对于设置XML文件作为默认的背景,参阅 [[#Lock screen and background]].<br />
<br />
=== 自定义 GNOME 会话 ===<br />
<br />
It is possible to create custom GNOME sessions which use the GNOME session manager but start different sets of components ([[Openbox]] with [[tint2]] instead of GNOME Shell for example).<br />
<br />
Two files are required for a custom GNOME session: a session file in {{ic|/usr/share/gnome-session/sessions/}} which defines the components to be started and a [[desktop entry]] in {{ic|/usr/share/xsessions}} which is read by the [[display manager]]. An example session file is provided below:<br />
{{hc|/usr/share/gnome-session/sessions/gnome-openbox.session|<nowiki><br />
[GNOME Session]<br />
Name=GNOME Openbox<br />
RequiredComponents=openbox;tint2;gnome-settings-daemon;<br />
</nowiki>}}<br />
<br />
And an example desktop file:<br />
{{hc|/usr/share/xsessions/gnome-openbox.desktop|<nowiki><br />
[Desktop Entry]<br />
Name=GNOME Openbox<br />
Exec=gnome-session --session=gnome-openbox<br />
</nowiki>}}<br />
<br />
{{Note|GNOME Session calls upon the {{ic|.desktop}} files of each of the components to be started. If a component you wish to start does not provide a {{ic|.desktop}} file, you must create a suitable desktop entry in a directory such as {{ic|/usr/local/share/applications}}.}}<br />
<br />
==故障排除==<br />
<br />
=== 终端冻结 ===<br />
<br />
In the event of a Shell freeze (which might be caused by certain appearance tweaks, malfunctioning extensions or perhaps a lack of available memory) restarting the Shell by pressing {{ic|Alt}} + {{ic|F2}} and then entering '''r''' may not be possible.<br />
<br />
In this case, try switching to another TTY ('''Ctrl''' + '''Alt''' + '''F2''') and entering the following command: {{ic|pkill -HUP gnome-shell}}. It may take a few seconds before the Shell successfully restarts. Restarting the shell in this fashion should not log the user out but it is a good idea to try and ensure that all work is saved anyway.<br />
<br />
If this fails, the [[Xorg]] server will need to be restarted either by: {{ic|pkill X}} for console logins or: {{ic|systemctl restart gdm}} for GDM logins. Bear in mind that restarting the Xorg server will log the user out so try to ensure that all work is saved before attempting this.<br />
<br />
=== Incorrect application defaults ===<br />
<br />
When installing applications for the first time you may find that GNOME has the wrong application associated to a certain protocols - for instance, ''easytag'' becomes the folder handler instead of [[GNOME Files]].<br />
<br />
For GNOME Files see the following page: [[GNOME Files#Files is no longer the default file manager]].<br />
<br />
For Document Viewer, run the following command:<br />
$ xdg-mime default evince.desktop application/pdf<br />
<br />
For other applications, default handler settings are detailed on the following page: [[Default applications]].<br />
<br />
Optionally, you can [[install]] {{AUR|gnome-defaults-list}}. It will place your configuration file at {{ic|/etc/gnome/defaults.list}}.<br />
<br />
=== Tracker & Documents do not list any local files ===<br />
<br />
In order for Tracker (and, therefore, Documents) to detect your local files, they must be stored in an [http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html XDG compliant directory] (such as 'Documents' or 'Music'). For more information, see [[Xdg user directories]].<br />
<br />
You can also configure Tracker to recursively search inside specific directories such as your home directory. These settings can be made using {{ic|tracker-preferences}}.<br />
<br />
=== Unable to add accounts in Empathy and GNOME Online Accounts ===<br />
<br />
Empathy, the engine behind integrated messaging, GNOME Online Accounts, and all other system settings based on messaging accounts will not function correctly unless the {{Grp|telepathy}} group of packages or at least one of the backends ({{Pkg|telepathy-gabble}}, or {{Pkg|telepathy-haze}}, for example) is [[install]]ed. View descriptions of ''telepathy'' components on the [http://telepathy.freedesktop.org/wiki/Components freedesktop.org telepathy wiki].<br />
<br />
{{Note|[[Avahi]] daemon is required for connecting with the People Nearby account, and also in order for some desktop extensions to work correctly like [https://extensions.gnome.org/extension/746/chat-status/ Chat Status]}}<br />
<br />
=== Cannot change settings in dconf-editor ===<br />
<br />
When one cannot set settings in {{pkg|dconf}}, it is possible their dconf user settings are corrupt. In this case it is best to delete the user dconf files in {{ic|~/.config/dconf/user*}} and set the settings in dconf-editor after.<br />
<br />
=== When an extension breaks the shell ===<br />
<br />
When enabling shell extensions causes GNOME breakage, you should first remove the ''user-theme'' and ''auto-move-windows'' extensions from their installation directory.<br />
<br />
The installation directory could be one of {{ic|~/.local/share/gnome‑shell/extensions}}, {{ic|/usr/share/gnome‑shell/extensions}} or {{ic|/usr/local/share/gnome‑shell/extensions}}. Removing these two extension-containing folders may fix the breakage. Otherwise, isolate the problem extension with trial‑and‑error.<br />
<br />
Removing or adding an extension-containing folder to the aforementioned directories removes or adds the corresponding extension to your system. Details on GNOME Shell extensions are available at the [https://live.gnome.org/GnomeShell/Extensions GNOME web site.]<br />
<br />
If you have trouble with uninstalling an extension via [https://extensions.gnome.org/local/ extensions.gnome.org/local], then probably they have been installed as system-wide extensions with the {{Pkg|gnome-shell-extensions}} package. Removing the package again obviously affects all user accounts.<br />
<br />
=== 扩展在 GNOME 3 升级后不工作了===<br />
<br />
{{Note|Please bear in mind that whilst the methods below will allow you to '''try''' and activate an extension with an unsupported version of GNOME Shell, it is by no means a guarantee that the extension will work successfully. The most likely outcome of trying to activate such an extension is that GNOME Shell will crash and then restart.}}<br />
<br />
Before trying the workarounds below, check if an update is available for the extension by visiting [https://extensions.gnome.org/local extensions.gnome.org/local]. <br />
<br />
If there is no update for your current GNOME version yet, use the following command to disable version validation for extensions:<br />
$ gsettings set org.gnome.shell disable-extension-version-validation true<br />
<br />
Alternatively, you could modify the extension itself, changing the supported shell version to satisfy the version validation. See the method below.<br />
<br />
<br />
找到扩展的安装目录,可能是 {{ic|~/.local/share/gnome-shell/extensions}} 或 {{ic|/usr/share/gnome-shell/extensions}}.<br />
<br />
编辑扩展子文件夹中的每一个 '''{{ic|metadata.json}}''' <br />
<br />
{| border="0"<br />
| Insert: || {{ic|"shell-version": ["3.x"]}}<br />
|-<br />
| Instead of (for example): || {{ic|"shell-version": ["3.4"]}}<br />
|}<br />
<br />
{{ic|"3.x"}} 是最好的选择,这个表示扩展能在所有 '''''3.x''''' GNOME Shell版本下工作。<br />
<br />
=== 只有 conky 运行时键盘快捷方式不工作 ===<br />
gnome-shell 键盘快捷方式(如 Alt+F2,Alt+F1 和多媒体键快捷方式)当只有 conky 运行时不会工作。然而如果另一个程序(例如 gedit)在运行,键盘快捷方式就可以工作了。<br />
<br />
解决方式:编辑 .conkyrc <br />
<br />
own_window yes<br />
own_window_transparent yes<br />
own_window_argb_visual yes<br />
own_window_type dock<br />
own_window_class Conky<br />
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager<br />
<br />
=== Unable to apply stored configuration for monitors ===<br />
<br />
If you encounter this message try to disable the ''xrandr'' {{ic|gnome-settings-daemon plugin}}:<br />
<br />
$ dconf write /org/gnome/settings-daemon/plugins/xrandr/active false<br />
<br />
=== 一致的光标主题 ===<br />
<br />
See [[Cursor themes#Desktop environments]].<br />
<br />
=== Windows cannot be modified with Alt-Key + mouse-button ===<br />
<br />
In GNOME 3.6 and above, the mouse button modifier (the key that allows you to drag a window from a location other than the titlebar) is the {{ic|Super}} key instead of the {{ic|Alt}} key which was used in the past. The change was made in response to the following [https://bugzilla.gnome.org/show_bug.cgi?id=607797 bug report]. <br />
<br />
To change the mouse button modifier back to the {{ic|Alt}} key, execute the following:<br />
$ gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier '<Alt>' <br />
<br />
{{Note|It is not possible to change this with ''System settings'' > ''Keyboard'' > ''Shortcuts''}}<br />
<br />
=== 加载速度慢的系统图标/慢GDM登录===<br />
<br />
{{Accuracy|1=As per [https://bbs.archlinux.org/viewtopic.php?pid=1565891#p1565891], it's probably the fact that on {{Pkg|gdk-pixbuf2}} post install {{ic|gdk-pixbuf-query-loaders --update-cache}} is run which fixes the issue, not the re-installation of the package per se.}}<br />
<br />
Problems with the loading of system icons, such the ones in the title bar of Files, might be solved by [[pacman#Installing specific packages|installing]] (or re-installing) the {{Pkg|gdk-pixbuf2}} package.<br />
<br />
Re-installing the aforementioned package may also fix repeated occurrences of the "Oh no! Something has gone wrong!" error screen and/or very slow loading and login with GDM as described in the following [https://bbs.archlinux.org/viewtopic.php?pid=1414157 forum thread].<br />
<br />
=== Artifacts when maximizing windows ===<br />
<br />
Maximizing windows may cause artifacts as of GNOME 3.12.0 - see the following [https://bbs.archlinux.org/viewtopic.php?id=183617 forum thread] and [https://bugzilla.gnome.org/show_bug.cgi?id=728385 bug report]. A solution is detailed in the following section: [[#Tear-free video with Intel HD Graphics]].<br />
<br />
=== Tear-free video with Intel HD Graphics ===<br />
<br />
;Intel TearFree<br />
Enabling the [[Intel _Graphics#Tear-free_video|Xorg Intel TearFree option]] is a known workaround for tearing problems on Intel adapters. However, the way this option acts makes it redundant with the use of a compositor (it increases memory consumption and lowers performance, see [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c123 the original bug report's final comment]).<br />
<br />
;DRI3<br />
According to [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c2 this bug report], DRI3 includes the {{ic|buffer_age}} extension that allows GNOME Shell's Mutter compositor to sync windows to vblank in an efficient way. DRI3 support is not compiled in to the mesa package, so you have to recompile {{Pkg|mesa}} with {{ic|--enable-dri3}} in the {{ic|./configure}} flags (see [[ABS]]). Then enable it in the Xorg driver:<br />
<br />
{{hc|/etc/X11/xorg.conf.d/20-intel.conf|<br />
Section "Device"<br />
Identifier "Intel Graphics"<br />
Driver "intel"<br />
Option "DRI" "3"<br />
EndSection}}<br />
<br />
;Mutter tweaks<br />
{{Note|1=This workaround has been [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c0 reported] to have side effects and may not fix tearing in all cases.}}<br />
GNOME Shell's Mutter compositor has a tweak known to address tearing problems (see [https://bugzilla.gnome.org/show_bug.cgi?id=657071#c1 the original suggestion for this fix] and its mention in [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c59 the Freedesktop bug report]). To enable this tweak, append the following line to {{ic|/etc/environment}}: {{ic|1=CLUTTER_PAINT=disable-clipped-redraws:disable-culling}}. Then restart the Xorg server.<br />
<br />
=== Window opens behind other windows when using multiple monitors ===<br />
<br />
This is possibly a bug in GNOME Shell which causes new windows to open behind others. To fix this issue, one can run the following command:<br />
$ gsettings set org.gnome.shell.overrides workspaces-only-on-primary false<br />
<br />
=== 锁定按钮无法重新启用触摸板===<br />
<br />
Some laptops have a touchpad lock button that disables the touchpad so that users can type without worrying about touching the touchpad. Currently, it appears that although GNOME can lock the touchpad by pressing this button, it cannot unlock it. If the touchpad gets locked you can run the following to unlock it:<br />
<br />
$ xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1<br />
<br />
=== GNOME Shell键盘源菜单不可见 ===<br />
<br />
A menu showing the keyboard input sources (for example 'en' for an English keyboard layout) should be visible next to the status area containing icons for network, volume and power sources. If the keyboard sources menu is not visible, this is probably because you have configured your [[Xorg]] keyboard layout in a way which GNOME does not recognise.<br />
<br />
To ensure that the menu is visible, remove any Xorg keyboard configuration you might have created and set the keyboard locale using [[Keyboard_configuration_in_Xorg#Using_localectl|localectl]].<br />
<br />
Upon running the command and then logging out, you should find that the keyboard input sources menu is visible in GDM and in the GNOME Shell desktop. See [http://blogs.gnome.org/mclasen/2012/09/21/input-sources-in-gnome/ Input sources in GNOME] for more information.<br />
<br />
=== 鼠标指针丢失 ===<br />
<br />
When using a separate [[window manager]] with ''gnome-settings-daemon'', the mouse cursor may vanish. Run:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.cursor active false<br />
<br />
=== 在会话菜单中没有重启按钮时,屏幕被锁定===<br />
<br />
If [[XScreenSaver]] is installed, ensure that it is not running at startup, see [[GNOME#Startup applications]].<br />
<br />
=== pulseaudio系统原因延误GNOME和GDM ===<br />
<br />
If you are running [[PulseAudio]] in system-wide mode, the PulseAudio 7.0 upgrade breaks [[GDM]] and GNOME.<br />
See [https://bbs.archlinux.org/viewtopic.php?id=203051 this forum post] for more information.<br />
<br />
=== GNOME crashes when trying to reorder applications in the GNOME Shell Dash ===<br />
The dash is the "toolbar" that appears, by default, [[wikipedia:GNOME_Shell#Design_components|on the left]] when you click Activities. Applications can be reordered in the dash by dragging and dropping. If this fails, and/or causes GNOME to crash, try [https://bbs.archlinux.org/viewtopic.php?id=171689 changing your icon theme].<br />
<br />
== 参见 ==<br />
* [http://www.gnome.org/ 官方网站]<br />
* [http://extensions.gnome.org/ GNOME-shell扩展]<br />
* 主题、图标和壁纸:<br />
** [http://art.gnome.org/ GNOME Art]<br />
** [http://www.gnome-look.org/ GNOME Look]<br />
* GTK/GNOME 程序:<br />
** [http://www.gnomefiles.org/ GNOME Files]<br />
** [http://www.gnome.org/projects/ GNOME Project Listing]<br />
* [http://blog.fpmurphy.com/2011/03/customizing-the-gnome-3-shell.html 自定义GNOME Shell]</div>无极https://wiki.archlinux.org/index.php?title=GNOME_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416810GNOME (简体中文)2016-01-23T03:23:44Z<p>无极: </p>
<hr />
<div>[[Category:Desktop environments (简体中文)]]<br />
[[cs:GNOME]]<br />
[[de:GNOME]]<br />
[[en:GNOME]]<br />
[[es:GNOME]]<br />
[[fr:GNOME]]<br />
[[it:GNOME]]<br />
[[ja:GNOME]]<br />
[[nl:GNOME]]<br />
[[pl:GNOME]]<br />
[[pt:GNOME]]<br />
[[ru:GNOME]]<br />
[[sr:GNOME]]<br />
[[th:GNOME]]<br />
[[tr:Gnome Masaüstü Ortamı]]<br />
[[uk:GNOME]]<br />
[[zh-TW:GNOME]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Desktop environment}}<br />
{{Related|Display manager}}<br />
{{Related|Window manager}}<br />
{{Related|GTK+}}<br />
{{Related|GDM}}<br />
{{Related|GNOME Files}}<br />
{{Related|Gedit}}<br />
{{Related|Epiphany}}<br />
{{Related|GNOME Flashback}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|GNOME|2015-10-05|400254}}<br />
<br />
GNOME (pronounced ''gah-nohm'' or ''nohm'')是一个简单易用的[[Desktop environment (简体中文)|桌面环境 ]].它由[[Wikipedia:The GNOME Project|The GNOME Project]] 设计并且完全自由和开源. GNOME是[[Wikipedia:GNU Project|GNU Project]]的一部分.<br />
<br />
== 安装 ==<br />
<br />
以下两个软件包(组)均包含 GNOME 的组件:<br />
<br />
'''gnome''' 包组包含基本桌面环境和软件,以提供标准的 GNOME 体验。<br />
<br />
'''gnome-extra''' 包组包含剩余的可选工具,例如文本编辑器、压缩文件管理器、光盘烧录工具、邮件客户端、游戏、开发工具及其它非必需的软件。这些软件与 GNOME 桌面的集成很好。假如您不想安装 GNOME 全部的软件包,在安装它的时候注意看软件包描述(或者你可以先安装再删除他们)。<br />
<br />
{{Note|''mutter'' acts as a composite manager for the desktop, employing hardware graphics acceleration to provide effects aimed at reducing screen clutter. The GNOME session manager automatically detects if your video driver is capable of running GNOME Shell and if not, falls back to software rendering using ''llvmpipe''.}} <br />
<br />
=== 附加的软件包 ===<br />
<br />
上面提到的包组不包括这些包:<br />
* {{App|[[Wikipedia:GNOME Boxes|Boxes]]|A simple user interface to access [[libvirt]] virtual machines.|https://wiki.gnome.org/Apps/Boxes|{{Pkg|gnome-boxes}}}}<br />
* {{App|GNOME Initial Setup|A simple, easy, and safe way to prepare a new system.|https://github.com/GNOME/gnome-initial-setup|{{Pkg|gnome-initial-setup}}}}<br />
* {{App|GNOME PackageKit|Collection of graphical tools for PackageKit to be used in the GNOME desktop.|https://github.com/GNOME/gnome-packagekit|{{Pkg|gnome-packagekit}}}}<br />
* {{App|[[Wikipedia:Nemiver|Nemiver]]|A C/C++ debugger.|https://wiki.gnome.org/Apps/Nemiver|{{Pkg|nemiver}}}}<br />
* {{App|[[Wikipedia:GNOME Software|Software]]|Lets you install and update applications and system extensions.|https://wiki.gnome.org/Apps/Software/|{{Pkg|gnome-software}}}}<br />
<br />
== GNOME会话==<br />
<br />
GNOME 有三个可用的会话,都使用 GNOME Shell<br />
*'''GNOME''' 是默认会话, 有创新的布局<br />
*'''GNOME Classic''' 的桌面布局类似于传统的GNOME 2, using pre-activated extensions and parameters. [http://worldofgnome.org/welcome-to-gnome-3-8-flintstones-mode/] Hence it is more a customized GNOME Shell than a truly distinct mode<br />
*'''GNOME on Wayland''' GNOME Shell 在新的Wayland协议上运行. 而传统的 X 应用程序在Xwayland上运行<br />
<br />
== 运行 GNOME ==<br />
<br />
GNOME可以通过 [[display manager (简体中文)|显示管理器]]以图形方式启动,或者从控制台手动启动。 为优化桌面整合, 建议使用[[GDM (简体中文)]] (GNOME显示管理器)。<br />
注意 [[systemd (简体中文)#使用单元|启用]] 一个显示管理器(例如GDM)意味着Xorg将会以root权限运行. <br />
{{注意| 如果不使用 GDM,你将无法体验到对锁屏的原生支持,因此你不得不使用另一个屏幕锁来提供类似功能,参见[[Xmonad (简体中文)#GNOME 3 and xmonad]].}}<br />
<br />
=== 图形界面登录===<br />
<br />
可以在登录管理器中选择 ''GNOME', ''GNOME Classic'' 或 ''GNOME on Wayland'' 作为登录选项。<br />
<br />
=== 手动启动 ===<br />
<br />
* 对于标准的GNOME会话, 在{{ic|~/.xinitrc}} 中添加:{{ic|exec gnome-session}}.<br />
* 对于经典的gnome会话,在 {{ic|~/.xinitrc}} 中添加:{bc|<nowiki>export XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME<br />
export GNOME_SHELL_SESSION_MODE=classic<br />
exec gnome-session --session=gnome-classic</nowiki>}}<br />
{{注意|最好把gnome--session之前的应用注释掉,我之前因为没有注释掉{{ic|twm}}(另一个窗口管理器)导致启动gnome失败}}<br />
我现在的{{ic|/etc/X11/xinit/xinitrc}}如下:<br />
#twm &<br />
#xclock -geometry 50x50-1+1 &<br />
#xterm -geometry 80x50+494+51 &<br />
#xterm -geometry 80x20+494-0 &<br />
#exec xterm -geometry 80x66+0+0 -name login<br />
exec gnome-session<br />
<br />
改完{{ic|~/.xinitrc}} ,即可用{{ic|startx}} 启动Gnome (see [[xinitrc]] for additional details, such as preserving the logind session). After setting up the {{ic|~/.xinitrc}} file it can also be arranged to [[Start X at login]].<br />
<br />
{{Note|Wayland 上的Gnome需要r {{Pkg|xorg-server-xwayland}} 包, 不能使用 ''startx'' 和{{ic|~/.xinitrc}},而是要运行 {{ic|gnome-session --session&#61;gnome-wayland}}. 更多参见 [[Wayland]].}}<br />
<br />
===Wayland 中的 GNOME 应用程序===<br />
<br />
根据当前的默认情况,GNOME 应用程序会利用 XWayland,以传统 X 应用程序的方式运行。若需在 Wayland 下测试 GNOME 应用,请以命令行方式运行程序,并加上以下前缀: {{ic|env GDK_BACKEND&#61;wayland <command>}}。<br />
<br />
{{Note|可以设置全局的 Wayland 环境,使用 {{ic|env GDK_BACKEND&#61;wayland gnome-session --session&#61;gnome-wayland}}。 但是现在无法工作—— ''gnome-session'' 会立即闪退.}}<br />
<br />
请查看以下页面以了解开发进展: [https://wiki.gnome.org/Initiatives/Wayland/Applications/ GNOME Applications under Wayland].<br />
<br />
== 导览 ==<br />
<br />
您可以阅读这篇文章: [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell cheat sheet] 以了解如何高效地使用 GNOME shell,它展示了 GNOME shell 的特色与使用快捷键。文章内容包括怎么切换任务,使用键盘,窗口控制,使用面板,预览模式等。<br />
部分常用的快捷键:<br />
<br />
* {{ic|Super}}: 进入预览模式<br />
* {{ic|Super}} + {{ic|m}}: 显示消息托盘<br />
* {{ic|Super}} + {{ic|a}}:显示应用程序菜单<br />
* {{ic|Alt}} + {{ic|F2}}:输入命令以快速启动应用<br />
* {{ic|Alt}} + {{ic|F2}},然后输入 {{ic|r}} 或 {{ic|restart}},再 {{ic|Enter}}:重启 GNOME shell。这一条在你遇到 shell 图形界面错误时十分有用。<br />
<br />
=== 重启 GNOME shell ===<br />
<br />
当修改过界面之后你可能需要重启 GNOME shell。你可以重新登陆,不过有一个简单快捷的方法。 按 {{ic|Alt}} + {{ic|F2}} 再输入 {{ic|r}} 再 {{ic|Enter}}<br />
<br />
=== GNOME Shell 崩溃 ===<br />
<br />
一些特定的微调或者经常性重启 Shell 会导致 shell 在将要重启的时候崩溃。这个时候你必须做好心理准备,然后强制注销。有一些修改,例如在'''''GNOME Shell''''' 和 '''''fallback mode,''''' 之间切换,不能简单地使用 r 重启;必须重登陆来应用这个效果。<br />
<br />
丑话说在前面,在重启 shell 前请先把有用的文档保存(或者关闭)。虽然这不是必要的,因为窗口和文档在重启了 shell 之后应该还在。<br />
<br />
=== 遗留名称 ===<br />
{{注意|<br />
一些GNOME程序在文档和关于对话框的名称已更改,但可执行文件的名称却没有。这样的应用程序在下面表格列出.}}<br />
<br />
{{提示|在搜索栏中搜索的应用程序的遗留名称将成功返回现在的应用程序,例如搜索''nautilus''将返回''Files''.}}<br />
<br />
{| class="wikitable"<br />
! Current<br />
! Legacy<br />
|-<br />
| [[Files]]<br />
| Nautilus<br />
|-<br />
| [[GNOME Web|Web]]<br />
| Epiphany<br />
|-<br />
| Videos<br />
| Totem<br />
|-<br />
| Main Menu<br />
| Alacarte<br />
|-<br />
| Document Viewer<br />
| Evince<br />
|-<br />
| Disk Usage Analyser<br />
| Baobab<br />
|-<br />
| Image Viewer<br />
| EoG (Eye of GNOME)<br />
|-<br />
| [[GNOME Keyring|Passwords and Keys]]<br />
| Seahorse<br />
|}<br />
<br />
== 配置 ==<br />
<br />
GNOME 3 是重新设计的,但是像大多数大型软件项目一样,他是很多不同时间的部分组装起来的。他没有一个 '''无所不包''' 的配置工具。新的 ''系统设置'' 比以前的控制面板有很大的改进。 ''系统设置'' 组织得很好,但是你可能想要更深层次地改变外观。<br />
<br />
以前你所熟悉的配置工具现在有的好用,有的不好用了。有些设置选项隐藏着,不太容易找到。许多设置将会,或已经迁移到了新的工具上。你需要了解应当去哪里寻找适当的设置项,才能更好地配置 GNOME 外观。 <br />
<br />
GNOME 桌面环境依赖于一个存储配置的数据库后端(DConf)来存储 GNOME 与 GNOME 应用的设置。安装桌面环境时,GNOME 提供一套默认的配置,而各类应用程序向数据库中添加它们自己的配置。<br />
<br />
对用户来说,最基础而直观的配置方式莫过于使用 GNOME 系统设置面板(gnome-control-center),以及 GNOME 应用程序各自的首选项(preferences)面板。如果您愿意,直接在 DConf 数据库中进行修改与配置总是可行的,尤其是在某些设置选项没有暴露在用户界面的情况下,直接修改可以更改某些隐藏选项。<br />
<br />
GNOME 的这些配置通常是用户间相互独立的。以下文字仅供单用户配置所用,并没有提及更改全局配置模板的方法。<br />
<br />
=== GNOME 系统设置 ===<br />
<br />
系统设置工具包括了一些最基础的 GNOME 环境配置选项。<br />
<br />
==== 色彩设置 ====<br />
<br />
{{ic|colord}} 守护进程读取显示器的 [https://zh.wikipedia.org/wiki/EDID EDID]信息,并提取出合适的色彩配置内容。大多数情况下,自动色彩配置都是正确的,不需要额外设置;但是对于可能出现的偏差情况,例如使用较旧的显示器时,您可以将色彩配置文件放在 {{ic|~/.local/share/icc/}} 下,并在设置面板里启用。<br />
<br />
==== 日期与时间 ====<br />
<br />
如果系统已有配置好的 [https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon_(简体中文) NTP 守护进程],它同样会对 GNOME 桌面环境起作用。如果需要,您也可以手动控制进行同步。<br />
<br />
如需在顶栏显示日期,请运行:<br />
<br />
$ gsettings set org.gnome.desktop.interface clock-show-date true<br />
<br />
另外,如需在 shell 的日历中显示周数,请运行:<br />
<br />
$ gsettings set org.gnome.shell.calendar show-weekdate true<br />
<br />
当然,以上配置均可以在 {{ic|gnome-tweak-tool}} 里完成。<br />
<br />
==== 默认应用程序 ==== <br />
<br />
Upon installing GNOME for the first time, you may find that the wrong applications are handling certain protocols. For example, ''totem'' opens videos instead of a previously used [[VLC]]. Some of the associations can be set from system settings via: ''System'' > ''Details'' > ''Default applications''. <br />
<br />
For other protocols and methods see [[Default applications]] for configuration.<br />
<br />
==== 鼠标和触摸板 ====<br />
<br />
为了帮助减少触摸板的干扰,你可能希望实现以下设置:<br />
<br />
* 禁用触摸板,打字时<br />
* 禁用滚动<br />
* 禁用点击<br />
<br />
==== 网络 ====<br />
<br />
[[NetworkManager]] is the native tool of the GNOME project to control network settings from the shell. It is installed by default as a dependency for {{Pkg|tracker}} package, which is a part of {{Grp|gnome}} group, and just needs to be [[NetworkManager#Enable NetworkManager|enabled]].<br />
<br />
While any other [[List_of_applications/Internet#Network_managers|network manager]] can be used as well, NetworkManager provides the full integration via the shell network settings and a status indicator applet {{Pkg|network-manager-applet}} (not required for GNOME).<br />
<br />
==== 在线帐户 ====<br />
<br />
Backends for the GNOME messaging application {{Pkg|empathy}} as well as the GNOME Online Accounts section of the System Settings panel are provided in a separate group: {{Grp|telepathy}}. See [[#Unable to add accounts in Empathy and GNOME Online Accounts]]. Some online accounts, such as [[ownCloud]], require {{Pkg|gvfs-goa}} to be installed for full functionality in GNOME applications such as [[GNOME Files]] and GNOME Documents [https://wiki.gnome.org/ThreePointSeven/Features/Owncloud].<br />
<br />
==== 搜索 ====<br />
<br />
The GNOME shell has a search that can be quickly accessed by pressing the {{ic|Super}} key and starting to type. The {{Pkg|tracker}} package is installed by default as a part of {{Grp|gnome}} group and provides an indexing application and metadata database. It can be configured with the ''Search and Indexing'' menu item; monitor status with ''tracker-control''. It is started automatically by ''gnome-session'' when the user logs in. Indexing can be started manually with {{ic|tracker-control -s}}. Search settings can also be configured in the ''System Settings'' panel.<br />
<br />
The Tracker database can be queried using the ''tracker-sparql'' command. View its manual page {{ic|man tracker-sparql}} for more information.<br />
<br />
<br />
=== 高级设置 ===<br />
==== 外观 ====<br />
<br />
=====GTK+主题和图标主题=====<br />
除了以下所述的直接从底层修改主题的方法,您也可以使用 gnome-tweak-tool 工具进行修改。 <br />
安装一个新的主题和图标集,分别添加相关的{{ic|~/.local/share/themes}} 或者 {{ic|~/.local/share/icons}} respectively (add to {{ic|/usr/share/}} instead of {{ic|~/.local/share/}} for the themes to be available systemwide.) 他们和其他GUI设置也可以在 {{ic|~/.config/gtk-3.0/settings.ini}}中定义:<br />
<br />
{{hc|~/.config/gtk-3.0/settings.ini|<nowiki><br />
[Settings]<br />
gtk-theme-name = Adwaita<br />
# next option is applicable only if selected theme supports it<br />
gtk-application-prefer-dark-theme = true<br />
# set font name and dimension<br />
gtk-font-name = Sans 10<br />
</nowiki>}}<br />
<br />
其他主题的站点:<br />
* [http://www.deviantart.com/browse/all/customization/skins/linuxutil/desktopenv/gnome/gtk3/ DeviantArt].<br />
* [http://gnome-look.org/index.php?xcontentmode=167 gnome-look.org].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=gtk3&do_Search=Go GTK3 themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=xcursor&do_Search=Go&PP=50&SB=v&SO=d Cursor themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=icon-theme&do_Search=Go&PP=50&SB=v&SO=d Icon themes in the AUR].<br />
<br />
一旦安装,就可以使用 GNOME Tweak Tool或GSettings -参阅下面的GSettings命令:<br />
<br />
对于GTK+主题:<br />
$ gsettings set org.gnome.desktop.interface gtk-theme ''theme-name''<br />
<br />
对于图标主题<br />
$ gsettings set org.gnome.desktop.interface icon-theme ''theme-name''<br />
<br />
====== 全局暗色主题======<br />
<br />
GNOME will use the Adwaita light theme by default however a dark variant of this theme (called the Global Dark Theme) also exists and can be selected using the Tweak Tool or by editing the GTK+ 3 settings file - see [[GTK+#Dark theme variant]]. Some applications such as Image Viewer (''eog'') use the dark theme by default. It should be noted that the Global Dark Theme only works with GTK+ 3 applications; some GTK+ 3 applications may only have partial support for the Global Dark theme. Qt and GTK+ 2 support for the Global Dark Theme may be added in the future.<br />
<br />
===== 窗口管理器主题=====<br />
<br />
The window manager theme (the style of the window titlebars) can be set using the GNOME Tweak Tool or the following GSettings command:<br />
$ gsettings set org.gnome.desktop.wm.preferences theme ''theme-name''<br />
<br />
====== 标题栏的高度 ======<br />
<br />
{{注意|在GNOME 3.16中,Mutter不再使用metacity主题。相反,标题栏的装饰主题使用GTK+。}}<br />
<br />
改变标题栏的高度,创建以下文件,调整填充所需:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<br />
.header-bar.default-decoration {<br />
padding-top: 3px;<br />
padding-bottom: 3px;<br />
}<br />
<br />
.header-bar.default-decoration .button.titlebutton {<br />
padding-top: 2px;<br />
padding-bottom: 2px;<br />
}<br />
}}<br />
<br />
标题栏的高度也可以通过选择一个较小的字体。默认情况下,字体设置为Cantarell Bold 11。您可能希望将字体设置为较小的,例如Sans Bold 10. 你可以这样使用以下GSettings命令来完成:<br />
$ gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Sans Bold 10'<br />
<br />
====== 标题栏按钮重新排序 ======<br />
<br />
设置 GNOME 窗口管理器顺序 (Mutter, Metacity): <br />
$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'<br />
<br />
{{提示|冒号表示窗口标题栏的按钮会出现在哪一方}}<br />
<br />
====== 最大化时隐藏标题栏 ======<br />
<br />
*[[Install]] {{AUR|mutter-hide-legacy-decorations}}. It changes a default setting in the window manager, so as to automatically hide the titlebar on legacy (non-headerbar) apps when they are maximized or tiled to the side.<br />
<br />
*[[Install]] {{AUR|maximus}}. To start the application, execute ''maximus'' from a terminal. When running, the daemon will automatically maximize windows. It will undecorate maximized windows and redecorate them when they are unmaximized. If you do not want all windows to start maximized, run {{ic|maximus -m}} instead. Note that this will only work with windows decorated by the window manager; applications that use client-side decoration such as [[GNOME Files]] will not be undecorated when maximized.<br />
===== GNOME Shell主题 =====<br />
<br />
The theme of GNOME Shell itself is configurable. To use a Shell theme, firstly ensure that you have the {{Pkg|gnome-shell-extensions}} package installed. Then enable the ''User Themes'' extension, either through GNOME Tweak Tool or through the [https://extensions.gnome.org GNOME Shell Extensions] webpage. Shell themes can then be loaded and selected using the GNOME Tweak Tool.<br />
<br />
There are a number of GNOME Shell themes available [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-theme&do_Search=Go&PP=50&SB=v&SO=d in the AUR].<br />
<br />
Shell themes can also be downloaded from [http://gnome-look.org/index.php?xcontentmode=191 gnome-look.org].<br />
==== 桌面 ====<br />
<br />
各种桌面设置可以应用。<br />
<br />
===== 桌面上的图标 =====<br />
<br />
参阅 [[GNOME Files#Desktop Icons]].<br />
<br />
===== 锁屏和背景=====<br />
<br />
When setting the Desktop or Lock screen background, it is important to note that the Pictures tab will only display pictures located in {{ic|/home/''username''/Pictures}} folder. If you wish to use a picture not located in this folder, use the commands indicated below.<br />
<br />
对于桌面背景:<br />
$ gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
对于锁屏背景<br />
$ gsettings set org.gnome.desktop.screensaver picture-uri 'file:///path/to/my/picture.jpg'<br />
====扩展 ====<br />
<br />
{{注意|通过 The GNOME Shell browser plugin(即 [https://extensions.gnome.org extensions.gnome.org])安装扩展的方法暂时无法在 Chrome/Chromium 35 或更高的版本上进行。用户应当采用其它对网页安装更兼容的浏览器进行安装,如 [[Firefox (简体中文)]] 或 [[GNOME/Web]]。}}<br />
<br />
GNOME Shell 可以使用第三方扩展来定制。这些扩展提供了一些额外的功能,如:提供一个可以一直显示的 Dock、更换 Shell 的主题,等等。<br />
<br />
名为 {{Pkg|gnome-shell-extensions}} 的软件包提供了一组由 The GNOME Project 维护,被当做 GNOME 计划的一部分的扩展,其中许多扩展被用在了 GNOME Classic 会话环境中。(最新版本的扩展你可以用他的代码 snapshot)[https://www.archlinux.org/packages/?sort=&q=gnome-shell-extension&maintainer=&last_update=&flagged=&limit=50 列表在这里]<br />
<br />
$ pacman -Ss gnome-shell-extension<br />
<br />
另外,有许多扩展被收集并托管在了[https://extensions.gnome.org extensions.gnome.org] 上。你可以在浏览器中浏览扩展列表,并轻松地一键点击来安装、管理、启用扩展。你可以在 [https://extensions.gnome.org/about/ 这里]找到有关插件的更多信息。<br />
<br />
你也可以在 [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-extension&do_Search=Go AUR]里面找到一些有用的扩展。当然,它们大多也可以在 [https://extensions.gnome.org extensions.gnome.org] 找到。一些值得一提的是:<br />
<br />
* {{AUR|gnome-shell-extension-lockkeys-git}} 一个指示 NumLock/CapsLock 激活情况的扩展。<br />
* {{AUR|gnome-shell-extension-weather-git}} 一个可以显示天气通知的扩展。<br />
* {{AUR|gnome-shell-extension-nohotcorner-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-nohotcorner-git}}}} 一个禁用“Hot Corner”功能的拓展。<br />
* {{AUR|gnome-shell-extension-insensitive-message-tray-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-insensitive-message-tray-git}}}} 使鼠标在屏幕底部激活信息托盘的行为变迟钝的拓展。<br />
*[https://extensions.gnome.org/extension/5/alternative-status-menu/ Alternative Status Menu] 让你的用户菜单里显示休眠和关机的扩展。<br />
<br />
另外,想要在屏幕底部显示一个任务栏,但又不想使用 GNOME Classic 的用户可以考虑使用 Window list 扩展 (由 {{Pkg|gnome-shell-extensions}} 提供).<br />
<br />
在安装完一个扩展之后可能需要[[#重启_GNOME_shell|重启 GNOME shell ]] 。故障排除信息参照[[#安装扩展导致GNOME停止工作|安装扩展导致GNOME停止工作]]。<br />
<br />
==== 输入法 ====<br />
<br />
GNOME集成了的通过[[IBus]]的输入法, 只有{{Pkg|ibus}}和添加想要的输入法引擎 (例如:{{Pkg|ibus-libpinyin}} for Intelligent Pinyin) 需要安装,安装后,输入法引擎可以加入GNOME的区域和语言设置键盘布局。<br />
<br />
==== 字体 ====<br />
<br />
{{Tip|If you set the ''Scaling factor'' to a value above 1.00, the Accessibility menu will be automatically enabled.}}<br />
<br />
Fonts can be set for Window titles, Interface (applications), Documents and Monospace. See the Fonts tab in the Tweak Tool for the relevant options.<br />
<br />
For hinting, RGBA will likely be desired as this fits most monitors types, and if fonts appear too blocked reduce hinting to ''Slight'' or ''None''.<br />
==== 启动应用程序====<br />
要启动登录某些应用程序, copy the relevant {{ic|.desktop}} file from {{ic|/usr/share/applications/}} to {{ic|~/.config/autostart/}}.<br />
可以使用Tweak Tool.来达到同样的效果。<br />
<br />
{{Tip|If the plus sign button in the Tweak Tool's Startup Applications section is unresponsive, try start the Tweak Tool from the terminal using the following command: {{ic|gnome-tweak-tool}}. See the following [https://bbs.archlinux.org/viewtopic.php?pid&#61;1413631#p1413631 forum thread].}}<br />
<br />
{{Note|The ''gnome-session-properties'' dialog was removed as of GNOME 3.12. It can be added back by [[install]]ing the {{AUR|gnome-session-properties}} package.}}<br />
==== 电源 ====<br />
<br />
The basic power settings that may want to be altered (these example settings assume the user is using a laptop - change them as desired):<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.power button-power ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout ''3600''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout ''1800''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type ''hibernate''<br />
$ gsettings set org.gnome.desktop.lockdown disable-lock-screen ''true''<br />
<br />
To keep a monitor active on lid close: <br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup do-nothing<br />
<br />
===== Configure behaviour on lid switch close =====<br />
<br />
The GNOME Tweak Tool, as of version 3.17.1, can optionally ''inhibit'' the ''systemd'' setting for the lid close ACPI event.[http://ftp.gnome.org/pub/GNOME/sources/gnome-tweak-tool/3.17/gnome-tweak-tool-3.17.1.news] To ''inhibit'' the setting, start the Tweak Tool and, under the power tab, check the ''Don't suspend on lid close'' option. This means that the system will do nothing on lid close instead of suspending - the default behaviour. Checking the setting creates {{ic|~/.config/autostart/ignore-lid-switch-tweak.desktop}} which will autostart the Tweak Tool's inhibitor.<br />
<br />
If you do not want the system to suspend or do nothing on lid close, you will need to ensure that the setting described above is '''not''' checked and then configure ''systemd'' with {{ic|1=HandleLidSwitch=''preferred_behaviour''}} as described in [[Power management#ACPI events]].<br />
<br />
===== Change critical battery level action =====<br />
<br />
The System Settings panel only allows the user to choose between ''Suspend'' or ''Hibernate''. To choose another option such as ''Do Nothing'' open the {{ic|dconf-editor}} and navigate to {{ic|org.gnome.settings-daemon.plugins.power}}. Edit the {{ic|"critical-battery-action"}} value to {{ic|"nothing"}}.<br />
<br />
==== Sort applications into application (app) folders ====<br />
<br />
{{Tip|The [https://github.com/prurigro/gnome-catgen gnome-catgen] ({{AUR|gnome-catgen-git}}) script allows you to manage folders through the creation of files in {{ic|~/.local/share/applications-categories}} named after each category and containing a list of the desktop files belonging to apps you'd like to have inside. Optionally, you can have it cycle through each app without a folder and input the desired category until you ctrl-c or run out of apps.}}<br />
<br />
In the '''dconf-editor''' navigate to {{ic|org.gnome.desktop.app-folders}} and set the value of {{ic|folder-children}} to an array of comma separated folder names:<br />
<br />
['Utilities', 'Sundry']<br />
<br />
Add applications using {{ic|gsettings}}:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ apps "['alacarte.desktop', 'dconf-editor.desktop']"<br />
<br />
This adds the applications {{ic|alacarte.desktop}} and {{ic|dconf-editor.desktop}} to the Sundry folder. This will also create the folder {{ic|org.gnome.desktop.app-folders.folders.Sundry}}.<br />
<br />
To name the folder (if it has no name that appears at the top of the applications):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ name "Sundry"<br />
<br />
Applications can also be sorted by their category (specified in their ''.desktop'' file):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ categories "['Office']"<br />
<br />
If certain applications matching a category are not wanted in a certain folder, exclusions can be set:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ excluded-apps "['libreoffice-draw.desktop']"<br />
<br />
For further information, refer to the [https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.app-folders.gschema.xml.in.in app-folders schema].<br />
<br />
== 提示与技巧==<br />
<br />
其他GNOME系统设置和提示。 <br />
<br />
=== 键盘 ===<br />
<br />
==== 登陆打开NumLock键 ====<br />
<br />
运行以下命令:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state on<br />
<br />
==== 热键选择====<br />
<br />
很多的快捷键可以通过系统设置菜单中更改. 例如,重新启用“显示桌面快捷键:<br />
<br />
''System settings'' > ''Keyboard'' > ''Shortcuts'' > ''Navigation'' > ''Hide all normal windows''<br />
<br />
However, certain hotkeys cannot be changed directly via system settings. In order to change these keys, use ''dconf-editor''. An example of particular note is the hotkey {{ic|Alt-}} + {{ic|`}} (the key above {{ic|Tab}} on US keyboard layouts). In GNOME Shell it is pre-configured to cycle through windows of an application, however it is also a hotkey often used in the [[Emacs]] editor. It can be changed by opening ''dconf-editor'' and modifying the ''switch-group'' key found in {{ic|org.gnome.desktop.wm.keybindings}}.<br />
<br />
It is possible to manually change the keys via an application's so-called '''accel''' map file. Where it is to be found is up to the application: For instance, Thunar's is at {{ic|~/.config/Thunar/accels.scm}}, whereas Files's is located at {{ic|~/.config/nautilus/accels}} and {{ic|~/.gnome2/accels/nautilus}} on old release.<br />
<br />
The file should contain a list of possible hotkeys, each unchanged line commented out with a leading ";" that has to be removed for a change to become active.<br />
For example to replace the hotkey used by Files to move files to the trash folder, change the line:<br />
<br />
; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete")<br />
to this:<br />
<br />
(gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete")<br />
<br />
The file is regenerated regularly so do not comment the file. The uncommented line will stay but every comment you add will be lost.<br />
<br />
==== 打开键盘开关命令 ====<br />
<br />
To have keyboard shortcut '''Alt''' + '''Shift''' switch keyboards:<br />
<br />
Open Gnome-Tweak-Tool (or Keyboard Settings, in GNOME 3.16) and set ''Typing'' > ''Modifiers-only input sources'' > ''select Alt-shift''. For more information see also the forum [https://bbs.archlinux.org/viewtopic.php?id=152127 thread].<br />
<br />
==== XkbOptions键盘选项 ====<br />
<br />
Using the '''dconf-editor''', navigate to the key named {{ic|org.gnome.desktop.input-sources.xkb-options}} and add desired XkbOptions (e.g. ''caps:swapescape'') to the list.<br />
<br />
See {{ic|/usr/share/X11/xkb/rules/xorg}} for all XkbOptions and {{ic|/usr/share/X11/xkb/symbols/*}} for the respective descriptions.<br />
<br />
{{Note|To enable the {{ic|Ctrl+Alt+Backspace}} combination to terminate Xorg, use the {{Pkg|gnome-tweak-tool}}. Within the '''Tweak Tool''', navigate to ''Typing > Key sequence to kill the X server'' and select the option {{ic|Ctrl+Alt+Backspace}} from the dropdown menu.}}<br />
<br />
==== De-bind Windows key ====<br />
<br />
默认情况下,“Windows键”将打开GNOMEshelly预览模式。 You can unbind this key by running the command below<br />
<br />
$ gsettings set org.gnome.mutter overlay-key 'Foo'<br />
<br />
=== 磁盘===<br />
<br />
GNOME提供磁盘实用程序来操作的存储驱动器设置。这是它的一些特点:<br />
<br />
* '''Enable write cache''' is a feature that most hard drives provide. Data is cached and allocated at chosen times to improve system performance. Not recommended unless the computer has a backup battery pack or is a laptop as data would be lost on power failure.<br />
: ''Settings'' > ''Drive Settings'' > ''Write Cache'' > '''On'''<br />
* '''Automatic Mount Options''' can mount drives and partitions that are GPT based - will use default, recommended options.<br />
: {{Warning|This setting erases related [[fstab]] entries}}<br />
: ''Partition Settings'' > ''Edit Mount Options'' > ''Automatic Mount Options'' > '''On'''<br />
<br />
=== 从菜单隐藏的应用程序===<br />
<br />
{{Tip|Desktop entries can be hidden by editing the {{ic|.desktop}} files themselves. See [[Desktop entries#Hide desktop entries]].}}<br />
<br />
Use the ''Main Menu'' application (provided by the {{Pkg|alacarte}} package) to hide any applications you do not wish to show in the menu.<br />
<br />
=== 截屏记录 ===<br />
<br />
GNOME features built-in screencast recording with the '''Ctrl''' + '''Shift''' + '''Alt''' + '''R''' key combination. A red circle is displayed in the bottom right corner of the screen when the recording is in progress. After the recording is finished, a file named {{ic|Screencast from %d%u-%c.webm}} is saved in the Videos directory. In order to use the screencast feature the gst plugins need to be installed.<br />
<br />
=== 截图 ===<br />
<br />
默认保存目录:<br />
<br />
$ gsettings set org.gnome.gnome-screenshot auto-save-directory file:///home/''USER''/Desktop<br />
<br />
Check the ''gnome-screenshot'' manual page for more options.<br />
<br />
===注销延迟 ===<br />
去掉注销的确认和 60 秒的延迟:<br />
这个对话框一般出现在你用状态菜单注销的时候。这个修改对于 关机 也生效。这个不是全局修改,只对使用该命令的用户生效。使用该命令立即生效。<br />
$ gsettings set org.gnome.SessionManager logout-prompt false<br />
<br />
=== 禁用动画 ===<br />
<br />
To disable Shell animations (such as "Show Applications" and the wave animation in the top left activities hot corner), run:<br />
<br />
$ gsettings set org.gnome.desktop.interface enable-animations false<br />
<br />
=== Retina (HiDPI) display support ===<br />
<br />
GNOME introduced HiDPI support in version 3.10. If your display does not provide the correct screen size through EDID, this can lead to incorrectly scaled UI elements. As a workaround you can open ''dconf-editor'' and find the key {{ic|scaling-factor}} in {{ic|org.gnome.desktop.interface}}. Set it to {{ic|1}} to get the standard scale.<br />
<br />
Also see [[HiDPI]].<br />
<br />
=== 密码和密钥 (PGP Keys) ===<br />
<br />
You can use the Passwords and Keys program (''seahorse'') to create a PGP key as it is a front end for [[GnuPG]] and installs it as dependency. This may be useful in the future (for instance if to encrypt a file). Create a key as shown below (the process may take about 10 minutes):<br />
<br />
''File'' > ''New'' > ''PGP Key'' > ''Name'' > ''Email'' > ''Defaults'' > ''Passphrase''.<br />
<br />
=== 终端 ===<br />
<br />
==== 更改默认的终端大小====<br />
<br />
新终端的默认大小可以在''编辑 > 配置文件首选项 ''中调整<br />
<br />
==== 新终端采用当前目录====<br />
<br />
By default new terminals open in the {{ic|$HOME}} directory. To have new terminals adopt the current working directory: {{ic|source /etc/profile.d/vte.sh}}. Add the command to the shell configuration to retain the behaviour.<br />
<br />
==== Pad the terminal ====<br />
<br />
To pad the terminal (create a small, invisible border between the window edges and the terminal contents) create the file below:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<nowiki><br />
VteTerminal,<br />
TerminalScreen {<br />
padding: 10px 10px 10px 10px;<br />
-VteTerminal-inner-border: 10px 10px 10px 10px;<br />
}</nowiki>}}<br />
<br />
==== 禁用光标闪烁====<br />
<br />
Since GNOME 3.8 and the migration to GSettings and DConf the key required to modify in order to disable the blinking cursor in the Terminal differs slightly in contrast to the old GConf key. To disable the blinking cursor in GNOME 3.8 and above use:<br />
<br />
$ gsettings set org.gnome.desktop.interface cursor-blink false<br />
<br />
To disable the blinking cursor in Terminal only use (make sure profile uid is correct one):<br />
<br />
$ dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/cursor-blink-mode "'off'"<br />
<br />
Note that {{ic|gnome-settings-daemon}}, from the package of the same name, must be running for this and other settings changes to take effect in GNOME applications - see [[GNOME#Configuration]].<br />
<br />
====关闭终端时,禁用确认窗口====<br />
<br />
试图关闭该窗口,而一个以root身份登录时,终端将始终显示一个确认窗口。为了避免这种情况,执行以下命令:<br />
$ gsettings set org.gnome.Terminal.Legacy.Settings confirm-close false<br />
<br />
=== 鼠标中键===<br />
<br />
By default, GNOME 3 disables middle mouse button emulation regardless of [[Xorg]] settings ('''Emulate3Buttons'''). To enable middle mouse button emulation use:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.mouse middle-button-enabled true<br />
<br />
=== 启用按钮和菜单图标===<br />
<br />
Since GTK+ 3.10, the GSettings key 'menus-have-icons' has been deprecated. Icons in buttons and menus can still be enabled by setting the following overrides:<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"<br />
<br />
=== 使用自定义的色彩和渐变色的桌面背景 ===<br />
使用自定义颜色和渐变为您的桌面背景,您首先需要设置一个透明的图片或其他不存在的图片作为您的桌面背景。例如,下面的命令将设置一个不存在的图片为背景。<br />
<br />
$ gsettings set org.gnome.desktop.background picture-uri none<br />
<br />
在这一点上,桌面背景应该是一个平坦的颜色-默认的颜色设置为深蓝色。<br />
<br />
对于不同的平面彩色你只需要改变的主要颜色设置:<br />
<br />
$ gsettings set org.gnome.desktop.background primary-color <my color><br />
where <my color> is a hex value (such as ''ffffff'' for white).<br />
<br />
对于颜色渐变,你也需要改变次要颜色设置 {{ic|org.gnome.desktop.background secondary-color}} <br />
并选择一个阴影类型。举例来说,如果你想有一个horizontal gradient,执行以下命令:<br />
$ gsettings set org.gnome.desktop.background color-shading-type horizontal<br />
<br />
如果你是使用一个透明的图片作为你的背景,你可以通过执行以下设置的透明度:<br />
$ gsettings set org.gnome.desktop.background picture-opacity <value><br />
数值在100和1之间(最大不透明度为100)。<br />
<br />
=== 渐变背景===<br />
<br />
GNOME 可以在特定的时间间隔之间的使用不同的壁纸。 这是通过创建一个XML文件,指定要使用的图片和时间间隔完成的。有关创建这些文件的详细信息,请参阅下面的 [http://www.linuxjournal.com/content/create-custom-transitioning-background-your-gnome-228-desktop article].<br />
<br />
可替代地,一些工具可用自动化过程:<br />
* {{App|mkwlppr|This script creates XML files that can act as dynamic wallpapers for GNOME by referring to multiple wallpapers.|http://pastebin.com/019G2rCy|see [http://pastebin.com/019G2rCy mkwlppr]}}<br />
* {{App|[[Wallpapoz]]|Wallpapoz is a tool that provides dynamic wallpapers for GNOME and Xfce desktops.|https://vajrasky.wordpress.com/|{{AUR|wallpapoz}}}}<br />
* {{App|CreBS|A Python/GTK application used to create and set desktop wallpaper slideshows for GNOME.|http://www.obfuscatepenguin.net/|{{AUR|crebs}}}}<br />
<br />
对于设置XML文件作为默认的背景,参阅 [[#Lock screen and background]].<br />
<br />
=== 自定义 GNOME 会话 ===<br />
<br />
It is possible to create custom GNOME sessions which use the GNOME session manager but start different sets of components ([[Openbox]] with [[tint2]] instead of GNOME Shell for example).<br />
<br />
Two files are required for a custom GNOME session: a session file in {{ic|/usr/share/gnome-session/sessions/}} which defines the components to be started and a [[desktop entry]] in {{ic|/usr/share/xsessions}} which is read by the [[display manager]]. An example session file is provided below:<br />
{{hc|/usr/share/gnome-session/sessions/gnome-openbox.session|<nowiki><br />
[GNOME Session]<br />
Name=GNOME Openbox<br />
RequiredComponents=openbox;tint2;gnome-settings-daemon;<br />
</nowiki>}}<br />
<br />
And an example desktop file:<br />
{{hc|/usr/share/xsessions/gnome-openbox.desktop|<nowiki><br />
[Desktop Entry]<br />
Name=GNOME Openbox<br />
Exec=gnome-session --session=gnome-openbox<br />
</nowiki>}}<br />
<br />
{{Note|GNOME Session calls upon the {{ic|.desktop}} files of each of the components to be started. If a component you wish to start does not provide a {{ic|.desktop}} file, you must create a suitable desktop entry in a directory such as {{ic|/usr/local/share/applications}}.}}<br />
<br />
==故障排除==<br />
<br />
=== 终端冻结 ===<br />
<br />
In the event of a Shell freeze (which might be caused by certain appearance tweaks, malfunctioning extensions or perhaps a lack of available memory) restarting the Shell by pressing {{ic|Alt}} + {{ic|F2}} and then entering '''r''' may not be possible.<br />
<br />
In this case, try switching to another TTY ('''Ctrl''' + '''Alt''' + '''F2''') and entering the following command: {{ic|pkill -HUP gnome-shell}}. It may take a few seconds before the Shell successfully restarts. Restarting the shell in this fashion should not log the user out but it is a good idea to try and ensure that all work is saved anyway.<br />
<br />
If this fails, the [[Xorg]] server will need to be restarted either by: {{ic|pkill X}} for console logins or: {{ic|systemctl restart gdm}} for GDM logins. Bear in mind that restarting the Xorg server will log the user out so try to ensure that all work is saved before attempting this.<br />
<br />
=== Incorrect application defaults ===<br />
<br />
When installing applications for the first time you may find that GNOME has the wrong application associated to a certain protocols - for instance, ''easytag'' becomes the folder handler instead of [[GNOME Files]].<br />
<br />
For GNOME Files see the following page: [[GNOME Files#Files is no longer the default file manager]].<br />
<br />
For Document Viewer, run the following command:<br />
$ xdg-mime default evince.desktop application/pdf<br />
<br />
For other applications, default handler settings are detailed on the following page: [[Default applications]].<br />
<br />
Optionally, you can [[install]] {{AUR|gnome-defaults-list}}. It will place your configuration file at {{ic|/etc/gnome/defaults.list}}.<br />
<br />
=== Tracker & Documents do not list any local files ===<br />
<br />
In order for Tracker (and, therefore, Documents) to detect your local files, they must be stored in an [http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html XDG compliant directory] (such as 'Documents' or 'Music'). For more information, see [[Xdg user directories]].<br />
<br />
You can also configure Tracker to recursively search inside specific directories such as your home directory. These settings can be made using {{ic|tracker-preferences}}.<br />
<br />
=== Unable to add accounts in Empathy and GNOME Online Accounts ===<br />
<br />
Empathy, the engine behind integrated messaging, GNOME Online Accounts, and all other system settings based on messaging accounts will not function correctly unless the {{Grp|telepathy}} group of packages or at least one of the backends ({{Pkg|telepathy-gabble}}, or {{Pkg|telepathy-haze}}, for example) is [[install]]ed. View descriptions of ''telepathy'' components on the [http://telepathy.freedesktop.org/wiki/Components freedesktop.org telepathy wiki].<br />
<br />
{{Note|[[Avahi]] daemon is required for connecting with the People Nearby account, and also in order for some desktop extensions to work correctly like [https://extensions.gnome.org/extension/746/chat-status/ Chat Status]}}<br />
<br />
=== Cannot change settings in dconf-editor ===<br />
<br />
When one cannot set settings in {{pkg|dconf}}, it is possible their dconf user settings are corrupt. In this case it is best to delete the user dconf files in {{ic|~/.config/dconf/user*}} and set the settings in dconf-editor after.<br />
<br />
=== When an extension breaks the shell ===<br />
<br />
When enabling shell extensions causes GNOME breakage, you should first remove the ''user-theme'' and ''auto-move-windows'' extensions from their installation directory.<br />
<br />
The installation directory could be one of {{ic|~/.local/share/gnome‑shell/extensions}}, {{ic|/usr/share/gnome‑shell/extensions}} or {{ic|/usr/local/share/gnome‑shell/extensions}}. Removing these two extension-containing folders may fix the breakage. Otherwise, isolate the problem extension with trial‑and‑error.<br />
<br />
Removing or adding an extension-containing folder to the aforementioned directories removes or adds the corresponding extension to your system. Details on GNOME Shell extensions are available at the [https://live.gnome.org/GnomeShell/Extensions GNOME web site.]<br />
<br />
If you have trouble with uninstalling an extension via [https://extensions.gnome.org/local/ extensions.gnome.org/local], then probably they have been installed as system-wide extensions with the {{Pkg|gnome-shell-extensions}} package. Removing the package again obviously affects all user accounts.<br />
<br />
=== 扩展在 GNOME 3 升级后不工作了===<br />
<br />
{{Note|Please bear in mind that whilst the methods below will allow you to '''try''' and activate an extension with an unsupported version of GNOME Shell, it is by no means a guarantee that the extension will work successfully. The most likely outcome of trying to activate such an extension is that GNOME Shell will crash and then restart.}}<br />
<br />
Before trying the workarounds below, check if an update is available for the extension by visiting [https://extensions.gnome.org/local extensions.gnome.org/local]. <br />
<br />
If there is no update for your current GNOME version yet, use the following command to disable version validation for extensions:<br />
$ gsettings set org.gnome.shell disable-extension-version-validation true<br />
<br />
Alternatively, you could modify the extension itself, changing the supported shell version to satisfy the version validation. See the method below.<br />
<br />
<br />
找到扩展的安装目录,可能是 {{ic|~/.local/share/gnome-shell/extensions}} 或 {{ic|/usr/share/gnome-shell/extensions}}.<br />
<br />
编辑扩展子文件夹中的每一个 '''{{ic|metadata.json}}''' <br />
<br />
{| border="0"<br />
| Insert: || {{ic|"shell-version": ["3.x"]}}<br />
|-<br />
| Instead of (for example): || {{ic|"shell-version": ["3.4"]}}<br />
|}<br />
<br />
{{ic|"3.x"}} 是最好的选择,这个表示扩展能在所有 '''''3.x''''' GNOME Shell版本下工作。<br />
<br />
=== 只有 conky 运行时键盘快捷方式不工作 ===<br />
gnome-shell 键盘快捷方式(如 Alt+F2,Alt+F1 和多媒体键快捷方式)当只有 conky 运行时不会工作。然而如果另一个程序(例如 gedit)在运行,键盘快捷方式就可以工作了。<br />
<br />
解决方式:编辑 .conkyrc <br />
<br />
own_window yes<br />
own_window_transparent yes<br />
own_window_argb_visual yes<br />
own_window_type dock<br />
own_window_class Conky<br />
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager<br />
<br />
=== Unable to apply stored configuration for monitors ===<br />
<br />
If you encounter this message try to disable the ''xrandr'' {{ic|gnome-settings-daemon plugin}}:<br />
<br />
$ dconf write /org/gnome/settings-daemon/plugins/xrandr/active false<br />
<br />
=== 一致的光标主题 ===<br />
<br />
See [[Cursor themes#Desktop environments]].<br />
<br />
=== Windows cannot be modified with Alt-Key + mouse-button ===<br />
<br />
In GNOME 3.6 and above, the mouse button modifier (the key that allows you to drag a window from a location other than the titlebar) is the {{ic|Super}} key instead of the {{ic|Alt}} key which was used in the past. The change was made in response to the following [https://bugzilla.gnome.org/show_bug.cgi?id=607797 bug report]. <br />
<br />
To change the mouse button modifier back to the {{ic|Alt}} key, execute the following:<br />
$ gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier '<Alt>' <br />
<br />
{{Note|It is not possible to change this with ''System settings'' > ''Keyboard'' > ''Shortcuts''}}<br />
<br />
=== 加载速度慢的系统图标/慢GDM登录===<br />
<br />
{{Accuracy|1=As per [https://bbs.archlinux.org/viewtopic.php?pid=1565891#p1565891], it's probably the fact that on {{Pkg|gdk-pixbuf2}} post install {{ic|gdk-pixbuf-query-loaders --update-cache}} is run which fixes the issue, not the re-installation of the package per se.}}<br />
<br />
Problems with the loading of system icons, such the ones in the title bar of Files, might be solved by [[pacman#Installing specific packages|installing]] (or re-installing) the {{Pkg|gdk-pixbuf2}} package.<br />
<br />
Re-installing the aforementioned package may also fix repeated occurrences of the "Oh no! Something has gone wrong!" error screen and/or very slow loading and login with GDM as described in the following [https://bbs.archlinux.org/viewtopic.php?pid=1414157 forum thread].<br />
<br />
=== Artifacts when maximizing windows ===<br />
<br />
Maximizing windows may cause artifacts as of GNOME 3.12.0 - see the following [https://bbs.archlinux.org/viewtopic.php?id=183617 forum thread] and [https://bugzilla.gnome.org/show_bug.cgi?id=728385 bug report]. A solution is detailed in the following section: [[#Tear-free video with Intel HD Graphics]].<br />
<br />
=== Tear-free video with Intel HD Graphics ===<br />
<br />
;Intel TearFree<br />
Enabling the [[Intel _Graphics#Tear-free_video|Xorg Intel TearFree option]] is a known workaround for tearing problems on Intel adapters. However, the way this option acts makes it redundant with the use of a compositor (it increases memory consumption and lowers performance, see [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c123 the original bug report's final comment]).<br />
<br />
;DRI3<br />
According to [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c2 this bug report], DRI3 includes the {{ic|buffer_age}} extension that allows GNOME Shell's Mutter compositor to sync windows to vblank in an efficient way. DRI3 support is not compiled in to the mesa package, so you have to recompile {{Pkg|mesa}} with {{ic|--enable-dri3}} in the {{ic|./configure}} flags (see [[ABS]]). Then enable it in the Xorg driver:<br />
<br />
{{hc|/etc/X11/xorg.conf.d/20-intel.conf|<br />
Section "Device"<br />
Identifier "Intel Graphics"<br />
Driver "intel"<br />
Option "DRI" "3"<br />
EndSection}}<br />
<br />
;Mutter tweaks<br />
{{Note|1=This workaround has been [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c0 reported] to have side effects and may not fix tearing in all cases.}}<br />
GNOME Shell's Mutter compositor has a tweak known to address tearing problems (see [https://bugzilla.gnome.org/show_bug.cgi?id=657071#c1 the original suggestion for this fix] and its mention in [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c59 the Freedesktop bug report]). To enable this tweak, append the following line to {{ic|/etc/environment}}: {{ic|1=CLUTTER_PAINT=disable-clipped-redraws:disable-culling}}. Then restart the Xorg server.<br />
<br />
=== Window opens behind other windows when using multiple monitors ===<br />
<br />
This is possibly a bug in GNOME Shell which causes new windows to open behind others. To fix this issue, one can run the following command:<br />
$ gsettings set org.gnome.shell.overrides workspaces-only-on-primary false<br />
<br />
=== 锁定按钮无法重新启用触摸板===<br />
<br />
Some laptops have a touchpad lock button that disables the touchpad so that users can type without worrying about touching the touchpad. Currently, it appears that although GNOME can lock the touchpad by pressing this button, it cannot unlock it. If the touchpad gets locked you can run the following to unlock it:<br />
<br />
$ xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1<br />
<br />
=== GNOME Shell键盘源菜单不可见 ===<br />
<br />
A menu showing the keyboard input sources (for example 'en' for an English keyboard layout) should be visible next to the status area containing icons for network, volume and power sources. If the keyboard sources menu is not visible, this is probably because you have configured your [[Xorg]] keyboard layout in a way which GNOME does not recognise.<br />
<br />
To ensure that the menu is visible, remove any Xorg keyboard configuration you might have created and set the keyboard locale using [[Keyboard_configuration_in_Xorg#Using_localectl|localectl]].<br />
<br />
Upon running the command and then logging out, you should find that the keyboard input sources menu is visible in GDM and in the GNOME Shell desktop. See [http://blogs.gnome.org/mclasen/2012/09/21/input-sources-in-gnome/ Input sources in GNOME] for more information.<br />
<br />
=== 鼠标指针丢失 ===<br />
<br />
When using a separate [[window manager]] with ''gnome-settings-daemon'', the mouse cursor may vanish. Run:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.cursor active false<br />
<br />
=== 在会话菜单中没有重启按钮时,屏幕被锁定===<br />
<br />
If [[XScreenSaver]] is installed, ensure that it is not running at startup, see [[GNOME#Startup applications]].<br />
<br />
=== pulseaudio系统原因延误GNOME和GDM ===<br />
<br />
If you are running [[PulseAudio]] in system-wide mode, the PulseAudio 7.0 upgrade breaks [[GDM]] and GNOME.<br />
See [https://bbs.archlinux.org/viewtopic.php?id=203051 this forum post] for more information.<br />
<br />
=== GNOME crashes when trying to reorder applications in the GNOME Shell Dash ===<br />
The dash is the "toolbar" that appears, by default, [[wikipedia:GNOME_Shell#Design_components|on the left]] when you click Activities. Applications can be reordered in the dash by dragging and dropping. If this fails, and/or causes GNOME to crash, try [https://bbs.archlinux.org/viewtopic.php?id=171689 changing your icon theme].<br />
<br />
== 参见 ==<br />
* [http://www.gnome.org/ 官方网站]<br />
* [http://extensions.gnome.org/ GNOME-shell扩展]<br />
* 主题、图标和壁纸:<br />
** [http://art.gnome.org/ GNOME Art]<br />
** [http://www.gnome-look.org/ GNOME Look]<br />
* GTK/GNOME 程序:<br />
** [http://www.gnomefiles.org/ GNOME Files]<br />
** [http://www.gnome.org/projects/ GNOME Project Listing]<br />
* [http://blog.fpmurphy.com/2011/03/customizing-the-gnome-3-shell.html 自定义GNOME Shell]</div>无极https://wiki.archlinux.org/index.php?title=GNOME_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416808GNOME (简体中文)2016-01-23T00:28:42Z<p>无极: </p>
<hr />
<div>[[Category:Desktop environments (简体中文)]]<br />
[[cs:GNOME]]<br />
[[de:GNOME]]<br />
[[en:GNOME]]<br />
[[es:GNOME]]<br />
[[fr:GNOME]]<br />
[[it:GNOME]]<br />
[[ja:GNOME]]<br />
[[nl:GNOME]]<br />
[[pl:GNOME]]<br />
[[pt:GNOME]]<br />
[[ru:GNOME]]<br />
[[sr:GNOME]]<br />
[[th:GNOME]]<br />
[[tr:Gnome Masaüstü Ortamı]]<br />
[[uk:GNOME]]<br />
[[zh-TW:GNOME]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Desktop environment}}<br />
{{Related|Display manager}}<br />
{{Related|Window manager}}<br />
{{Related|GTK+}}<br />
{{Related|GDM}}<br />
{{Related|GNOME Files}}<br />
{{Related|Gedit}}<br />
{{Related|Epiphany}}<br />
{{Related|GNOME Flashback}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|GNOME|2015-10-05|400254}}<br />
<br />
GNOME (pronounced ''gah-nohm'' or ''nohm'')是一个简单易用的[[Desktop environment (简体中文)|桌面环境 ]].它由[[Wikipedia:The GNOME Project|The GNOME Project]] 设计并且完全自由和开源. GNOME是[[Wikipedia:GNU Project|GNU Project]]的一部分.<br />
<br />
== 安装 ==<br />
<br />
以下两个软件包(组)均包含 GNOME 的组件:<br />
<br />
'''gnome''' 包组包含基本桌面环境和软件,以提供标准的 GNOME 体验。<br />
<br />
'''gnome-extra''' 包组包含剩余的可选工具,例如文本编辑器、压缩文件管理器、光盘烧录工具、邮件客户端、游戏、开发工具及其它非必需的软件。这些软件与 GNOME 桌面的集成很好。假如您不想安装 GNOME 全部的软件包,在安装它的时候注意看软件包描述(或者你可以先安装再删除他们)。<br />
<br />
{{Note|''mutter'' acts as a composite manager for the desktop, employing hardware graphics acceleration to provide effects aimed at reducing screen clutter. The GNOME session manager automatically detects if your video driver is capable of running GNOME Shell and if not, falls back to software rendering using ''llvmpipe''.}} <br />
<br />
=== 附加的软件包 ===<br />
<br />
上面提到的包组不包括这些包:<br />
* {{App|[[Wikipedia:GNOME Boxes|Boxes]]|A simple user interface to access [[libvirt]] virtual machines.|https://wiki.gnome.org/Apps/Boxes|{{Pkg|gnome-boxes}}}}<br />
* {{App|GNOME Initial Setup|A simple, easy, and safe way to prepare a new system.|https://github.com/GNOME/gnome-initial-setup|{{Pkg|gnome-initial-setup}}}}<br />
* {{App|GNOME PackageKit|Collection of graphical tools for PackageKit to be used in the GNOME desktop.|https://github.com/GNOME/gnome-packagekit|{{Pkg|gnome-packagekit}}}}<br />
* {{App|[[Wikipedia:Nemiver|Nemiver]]|A C/C++ debugger.|https://wiki.gnome.org/Apps/Nemiver|{{Pkg|nemiver}}}}<br />
* {{App|[[Wikipedia:GNOME Software|Software]]|Lets you install and update applications and system extensions.|https://wiki.gnome.org/Apps/Software/|{{Pkg|gnome-software}}}}<br />
<br />
== GNOME会话==<br />
<br />
GNOME 有三个可用的会话,都使用 GNOME Shell<br />
*'''GNOME''' 是默认会话, 有创新的布局<br />
*'''GNOME Classic''' 的桌面布局类似于传统的GNOME 2, using pre-activated extensions and parameters. [http://worldofgnome.org/welcome-to-gnome-3-8-flintstones-mode/] Hence it is more a customized GNOME Shell than a truly distinct mode<br />
*'''GNOME on Wayland''' GNOME Shell 在新的Wayland协议上运行. 而传统的 X 应用程序在Xwayland上运行<br />
<br />
== 运行 GNOME ==<br />
<br />
GNOME可以通过 [[display manager (简体中文)|显示管理器]]以图形方式启动,或者从控制台手动启动。 为优化桌面整合, 建议使用[[GDM (简体中文)]] (GNOME显示管理器)。<br />
注意 [[systemd (简体中文)#使用单元|启用]] 一个显示管理器(例如GDM)意味着Xorg将会以root权限运行. <br />
{{注意| 如果不使用 GDM,你将无法体验到对锁屏的原生支持,因此你不得不使用另一个屏幕锁来提供类似功能,参见[[Xmonad (简体中文)#GNOME 3 and xmonad]].}}<br />
<br />
=== 图形界面登录===<br />
<br />
可以在登录管理器中选择 ''GNOME', ''GNOME Classic'' 或 ''GNOME on Wayland'' 作为登录选项。<br />
<br />
=== 手动启动 ===<br />
<br />
* 对于标准的GNOME会话, 在{{ic|~/.xinitrc}} 中添加:{{ic|exec gnome-session}}.<br />
* 对于经典的gnome会话,在 {{ic|~/.xinitrc}} 中添加:{bc|<nowiki>export XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME<br />
export GNOME_SHELL_SESSION_MODE=classic<br />
exec gnome-session --session=gnome-classic</nowiki>}}<br />
<br />
改完{{ic|~/.xinitrc}} ,即可用{{ic|startx}} 启动Gnome (see [[xinitrc]] for additional details, such as preserving the logind session). After setting up the {{ic|~/.xinitrc}} file it can also be arranged to [[Start X at login]].<br />
<br />
{{Note|Wayland 上的Gnome需要r {{Pkg|xorg-server-xwayland}} 包, 不能使用 ''startx'' 和{{ic|~/.xinitrc}},而是要运行 {{ic|gnome-session --session&#61;gnome-wayland}}. 更多参见 [[Wayland]].}}<br />
<br />
===Wayland 中的 GNOME 应用程序===<br />
<br />
根据当前的默认情况,GNOME 应用程序会利用 XWayland,以传统 X 应用程序的方式运行。若需在 Wayland 下测试 GNOME 应用,请以命令行方式运行程序,并加上以下前缀: {{ic|env GDK_BACKEND&#61;wayland <command>}}。<br />
<br />
{{Note|可以设置全局的 Wayland 环境,使用 {{ic|env GDK_BACKEND&#61;wayland gnome-session --session&#61;gnome-wayland}}。 但是现在无法工作—— ''gnome-session'' 会立即闪退.}}<br />
<br />
请查看以下页面以了解开发进展: [https://wiki.gnome.org/Initiatives/Wayland/Applications/ GNOME Applications under Wayland].<br />
<br />
== 导览 ==<br />
<br />
您可以阅读这篇文章: [https://wiki.gnome.org/Projects/GnomeShell/CheatSheet GNOME Shell cheat sheet] 以了解如何高效地使用 GNOME shell,它展示了 GNOME shell 的特色与使用快捷键。文章内容包括怎么切换任务,使用键盘,窗口控制,使用面板,预览模式等。<br />
部分常用的快捷键:<br />
<br />
* {{ic|Super}}: 进入预览模式<br />
* {{ic|Super}} + {{ic|m}}: 显示消息托盘<br />
* {{ic|Super}} + {{ic|a}}:显示应用程序菜单<br />
* {{ic|Alt}} + {{ic|F2}}:输入命令以快速启动应用<br />
* {{ic|Alt}} + {{ic|F2}},然后输入 {{ic|r}} 或 {{ic|restart}},再 {{ic|Enter}}:重启 GNOME shell。这一条在你遇到 shell 图形界面错误时十分有用。<br />
<br />
=== 重启 GNOME shell ===<br />
<br />
当修改过界面之后你可能需要重启 GNOME shell。你可以重新登陆,不过有一个简单快捷的方法。 按 {{ic|Alt}} + {{ic|F2}} 再输入 {{ic|r}} 再 {{ic|Enter}}<br />
<br />
=== GNOME Shell 崩溃 ===<br />
<br />
一些特定的微调或者经常性重启 Shell 会导致 shell 在将要重启的时候崩溃。这个时候你必须做好心理准备,然后强制注销。有一些修改,例如在'''''GNOME Shell''''' 和 '''''fallback mode,''''' 之间切换,不能简单地使用 r 重启;必须重登陆来应用这个效果。<br />
<br />
丑话说在前面,在重启 shell 前请先把有用的文档保存(或者关闭)。虽然这不是必要的,因为窗口和文档在重启了 shell 之后应该还在。<br />
<br />
=== 遗留名称 ===<br />
{{注意|<br />
一些GNOME程序在文档和关于对话框的名称已更改,但可执行文件的名称却没有。这样的应用程序在下面表格列出.}}<br />
<br />
{{提示|在搜索栏中搜索的应用程序的遗留名称将成功返回现在的应用程序,例如搜索''nautilus''将返回''Files''.}}<br />
<br />
{| class="wikitable"<br />
! Current<br />
! Legacy<br />
|-<br />
| [[Files]]<br />
| Nautilus<br />
|-<br />
| [[GNOME Web|Web]]<br />
| Epiphany<br />
|-<br />
| Videos<br />
| Totem<br />
|-<br />
| Main Menu<br />
| Alacarte<br />
|-<br />
| Document Viewer<br />
| Evince<br />
|-<br />
| Disk Usage Analyser<br />
| Baobab<br />
|-<br />
| Image Viewer<br />
| EoG (Eye of GNOME)<br />
|-<br />
| [[GNOME Keyring|Passwords and Keys]]<br />
| Seahorse<br />
|}<br />
<br />
== 配置 ==<br />
<br />
GNOME 3 是重新设计的,但是像大多数大型软件项目一样,他是很多不同时间的部分组装起来的。他没有一个 '''无所不包''' 的配置工具。新的 ''系统设置'' 比以前的控制面板有很大的改进。 ''系统设置'' 组织得很好,但是你可能想要更深层次地改变外观。<br />
<br />
以前你所熟悉的配置工具现在有的好用,有的不好用了。有些设置选项隐藏着,不太容易找到。许多设置将会,或已经迁移到了新的工具上。你需要了解应当去哪里寻找适当的设置项,才能更好地配置 GNOME 外观。 <br />
<br />
GNOME 桌面环境依赖于一个存储配置的数据库后端(DConf)来存储 GNOME 与 GNOME 应用的设置。安装桌面环境时,GNOME 提供一套默认的配置,而各类应用程序向数据库中添加它们自己的配置。<br />
<br />
对用户来说,最基础而直观的配置方式莫过于使用 GNOME 系统设置面板(gnome-control-center),以及 GNOME 应用程序各自的首选项(preferences)面板。如果您愿意,直接在 DConf 数据库中进行修改与配置总是可行的,尤其是在某些设置选项没有暴露在用户界面的情况下,直接修改可以更改某些隐藏选项。<br />
<br />
GNOME 的这些配置通常是用户间相互独立的。以下文字仅供单用户配置所用,并没有提及更改全局配置模板的方法。<br />
<br />
=== GNOME 系统设置 ===<br />
<br />
系统设置工具包括了一些最基础的 GNOME 环境配置选项。<br />
<br />
==== 色彩设置 ====<br />
<br />
{{ic|colord}} 守护进程读取显示器的 [https://zh.wikipedia.org/wiki/EDID EDID]信息,并提取出合适的色彩配置内容。大多数情况下,自动色彩配置都是正确的,不需要额外设置;但是对于可能出现的偏差情况,例如使用较旧的显示器时,您可以将色彩配置文件放在 {{ic|~/.local/share/icc/}} 下,并在设置面板里启用。<br />
<br />
==== 日期与时间 ====<br />
<br />
如果系统已有配置好的 [https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon_(简体中文) NTP 守护进程],它同样会对 GNOME 桌面环境起作用。如果需要,您也可以手动控制进行同步。<br />
<br />
如需在顶栏显示日期,请运行:<br />
<br />
$ gsettings set org.gnome.desktop.interface clock-show-date true<br />
<br />
另外,如需在 shell 的日历中显示周数,请运行:<br />
<br />
$ gsettings set org.gnome.shell.calendar show-weekdate true<br />
<br />
当然,以上配置均可以在 {{ic|gnome-tweak-tool}} 里完成。<br />
<br />
==== 默认应用程序 ==== <br />
<br />
Upon installing GNOME for the first time, you may find that the wrong applications are handling certain protocols. For example, ''totem'' opens videos instead of a previously used [[VLC]]. Some of the associations can be set from system settings via: ''System'' > ''Details'' > ''Default applications''. <br />
<br />
For other protocols and methods see [[Default applications]] for configuration.<br />
<br />
==== 鼠标和触摸板 ====<br />
<br />
为了帮助减少触摸板的干扰,你可能希望实现以下设置:<br />
<br />
* 禁用触摸板,打字时<br />
* 禁用滚动<br />
* 禁用点击<br />
<br />
==== 网络 ====<br />
<br />
[[NetworkManager]] is the native tool of the GNOME project to control network settings from the shell. It is installed by default as a dependency for {{Pkg|tracker}} package, which is a part of {{Grp|gnome}} group, and just needs to be [[NetworkManager#Enable NetworkManager|enabled]].<br />
<br />
While any other [[List_of_applications/Internet#Network_managers|network manager]] can be used as well, NetworkManager provides the full integration via the shell network settings and a status indicator applet {{Pkg|network-manager-applet}} (not required for GNOME).<br />
<br />
==== 在线帐户 ====<br />
<br />
Backends for the GNOME messaging application {{Pkg|empathy}} as well as the GNOME Online Accounts section of the System Settings panel are provided in a separate group: {{Grp|telepathy}}. See [[#Unable to add accounts in Empathy and GNOME Online Accounts]]. Some online accounts, such as [[ownCloud]], require {{Pkg|gvfs-goa}} to be installed for full functionality in GNOME applications such as [[GNOME Files]] and GNOME Documents [https://wiki.gnome.org/ThreePointSeven/Features/Owncloud].<br />
<br />
==== 搜索 ====<br />
<br />
The GNOME shell has a search that can be quickly accessed by pressing the {{ic|Super}} key and starting to type. The {{Pkg|tracker}} package is installed by default as a part of {{Grp|gnome}} group and provides an indexing application and metadata database. It can be configured with the ''Search and Indexing'' menu item; monitor status with ''tracker-control''. It is started automatically by ''gnome-session'' when the user logs in. Indexing can be started manually with {{ic|tracker-control -s}}. Search settings can also be configured in the ''System Settings'' panel.<br />
<br />
The Tracker database can be queried using the ''tracker-sparql'' command. View its manual page {{ic|man tracker-sparql}} for more information.<br />
<br />
<br />
=== 高级设置 ===<br />
==== 外观 ====<br />
<br />
=====GTK+主题和图标主题=====<br />
除了以下所述的直接从底层修改主题的方法,您也可以使用 gnome-tweak-tool 工具进行修改。 <br />
安装一个新的主题和图标集,分别添加相关的{{ic|~/.local/share/themes}} 或者 {{ic|~/.local/share/icons}} respectively (add to {{ic|/usr/share/}} instead of {{ic|~/.local/share/}} for the themes to be available systemwide.) 他们和其他GUI设置也可以在 {{ic|~/.config/gtk-3.0/settings.ini}}中定义:<br />
<br />
{{hc|~/.config/gtk-3.0/settings.ini|<nowiki><br />
[Settings]<br />
gtk-theme-name = Adwaita<br />
# next option is applicable only if selected theme supports it<br />
gtk-application-prefer-dark-theme = true<br />
# set font name and dimension<br />
gtk-font-name = Sans 10<br />
</nowiki>}}<br />
<br />
其他主题的站点:<br />
* [http://www.deviantart.com/browse/all/customization/skins/linuxutil/desktopenv/gnome/gtk3/ DeviantArt].<br />
* [http://gnome-look.org/index.php?xcontentmode=167 gnome-look.org].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=gtk3&do_Search=Go GTK3 themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=xcursor&do_Search=Go&PP=50&SB=v&SO=d Cursor themes in the AUR].<br />
* [https://aur.archlinux.org/packages.php?O=0&K=icon-theme&do_Search=Go&PP=50&SB=v&SO=d Icon themes in the AUR].<br />
<br />
一旦安装,就可以使用 GNOME Tweak Tool或GSettings -参阅下面的GSettings命令:<br />
<br />
对于GTK+主题:<br />
$ gsettings set org.gnome.desktop.interface gtk-theme ''theme-name''<br />
<br />
对于图标主题<br />
$ gsettings set org.gnome.desktop.interface icon-theme ''theme-name''<br />
<br />
====== 全局暗色主题======<br />
<br />
GNOME will use the Adwaita light theme by default however a dark variant of this theme (called the Global Dark Theme) also exists and can be selected using the Tweak Tool or by editing the GTK+ 3 settings file - see [[GTK+#Dark theme variant]]. Some applications such as Image Viewer (''eog'') use the dark theme by default. It should be noted that the Global Dark Theme only works with GTK+ 3 applications; some GTK+ 3 applications may only have partial support for the Global Dark theme. Qt and GTK+ 2 support for the Global Dark Theme may be added in the future.<br />
<br />
===== 窗口管理器主题=====<br />
<br />
The window manager theme (the style of the window titlebars) can be set using the GNOME Tweak Tool or the following GSettings command:<br />
$ gsettings set org.gnome.desktop.wm.preferences theme ''theme-name''<br />
<br />
====== 标题栏的高度 ======<br />
<br />
{{注意|在GNOME 3.16中,Mutter不再使用metacity主题。相反,标题栏的装饰主题使用GTK+。}}<br />
<br />
改变标题栏的高度,创建以下文件,调整填充所需:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<br />
.header-bar.default-decoration {<br />
padding-top: 3px;<br />
padding-bottom: 3px;<br />
}<br />
<br />
.header-bar.default-decoration .button.titlebutton {<br />
padding-top: 2px;<br />
padding-bottom: 2px;<br />
}<br />
}}<br />
<br />
标题栏的高度也可以通过选择一个较小的字体。默认情况下,字体设置为Cantarell Bold 11。您可能希望将字体设置为较小的,例如Sans Bold 10. 你可以这样使用以下GSettings命令来完成:<br />
$ gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Sans Bold 10'<br />
<br />
====== 标题栏按钮重新排序 ======<br />
<br />
设置 GNOME 窗口管理器顺序 (Mutter, Metacity): <br />
$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'<br />
<br />
{{提示|冒号表示窗口标题栏的按钮会出现在哪一方}}<br />
<br />
====== 最大化时隐藏标题栏 ======<br />
<br />
*[[Install]] {{AUR|mutter-hide-legacy-decorations}}. It changes a default setting in the window manager, so as to automatically hide the titlebar on legacy (non-headerbar) apps when they are maximized or tiled to the side.<br />
<br />
*[[Install]] {{AUR|maximus}}. To start the application, execute ''maximus'' from a terminal. When running, the daemon will automatically maximize windows. It will undecorate maximized windows and redecorate them when they are unmaximized. If you do not want all windows to start maximized, run {{ic|maximus -m}} instead. Note that this will only work with windows decorated by the window manager; applications that use client-side decoration such as [[GNOME Files]] will not be undecorated when maximized.<br />
===== GNOME Shell主题 =====<br />
<br />
The theme of GNOME Shell itself is configurable. To use a Shell theme, firstly ensure that you have the {{Pkg|gnome-shell-extensions}} package installed. Then enable the ''User Themes'' extension, either through GNOME Tweak Tool or through the [https://extensions.gnome.org GNOME Shell Extensions] webpage. Shell themes can then be loaded and selected using the GNOME Tweak Tool.<br />
<br />
There are a number of GNOME Shell themes available [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-theme&do_Search=Go&PP=50&SB=v&SO=d in the AUR].<br />
<br />
Shell themes can also be downloaded from [http://gnome-look.org/index.php?xcontentmode=191 gnome-look.org].<br />
==== 桌面 ====<br />
<br />
各种桌面设置可以应用。<br />
<br />
===== 桌面上的图标 =====<br />
<br />
参阅 [[GNOME Files#Desktop Icons]].<br />
<br />
===== 锁屏和背景=====<br />
<br />
When setting the Desktop or Lock screen background, it is important to note that the Pictures tab will only display pictures located in {{ic|/home/''username''/Pictures}} folder. If you wish to use a picture not located in this folder, use the commands indicated below.<br />
<br />
对于桌面背景:<br />
$ gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/my/picture.jpg'<br />
<br />
对于锁屏背景<br />
$ gsettings set org.gnome.desktop.screensaver picture-uri 'file:///path/to/my/picture.jpg'<br />
====扩展 ====<br />
<br />
{{注意|通过 The GNOME Shell browser plugin(即 [https://extensions.gnome.org extensions.gnome.org])安装扩展的方法暂时无法在 Chrome/Chromium 35 或更高的版本上进行。用户应当采用其它对网页安装更兼容的浏览器进行安装,如 [[Firefox (简体中文)]] 或 [[GNOME/Web]]。}}<br />
<br />
GNOME Shell 可以使用第三方扩展来定制。这些扩展提供了一些额外的功能,如:提供一个可以一直显示的 Dock、更换 Shell 的主题,等等。<br />
<br />
名为 {{Pkg|gnome-shell-extensions}} 的软件包提供了一组由 The GNOME Project 维护,被当做 GNOME 计划的一部分的扩展,其中许多扩展被用在了 GNOME Classic 会话环境中。(最新版本的扩展你可以用他的代码 snapshot)[https://www.archlinux.org/packages/?sort=&q=gnome-shell-extension&maintainer=&last_update=&flagged=&limit=50 列表在这里]<br />
<br />
$ pacman -Ss gnome-shell-extension<br />
<br />
另外,有许多扩展被收集并托管在了[https://extensions.gnome.org extensions.gnome.org] 上。你可以在浏览器中浏览扩展列表,并轻松地一键点击来安装、管理、启用扩展。你可以在 [https://extensions.gnome.org/about/ 这里]找到有关插件的更多信息。<br />
<br />
你也可以在 [https://aur.archlinux.org/packages.php?O=0&K=gnome-shell-extension&do_Search=Go AUR]里面找到一些有用的扩展。当然,它们大多也可以在 [https://extensions.gnome.org extensions.gnome.org] 找到。一些值得一提的是:<br />
<br />
* {{AUR|gnome-shell-extension-lockkeys-git}} 一个指示 NumLock/CapsLock 激活情况的扩展。<br />
* {{AUR|gnome-shell-extension-weather-git}} 一个可以显示天气通知的扩展。<br />
* {{AUR|gnome-shell-extension-nohotcorner-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-nohotcorner-git}}}} 一个禁用“Hot Corner”功能的拓展。<br />
* {{AUR|gnome-shell-extension-insensitive-message-tray-git}}{{Broken package link|{{aur-mirror|gnome-shell-extension-insensitive-message-tray-git}}}} 使鼠标在屏幕底部激活信息托盘的行为变迟钝的拓展。<br />
*[https://extensions.gnome.org/extension/5/alternative-status-menu/ Alternative Status Menu] 让你的用户菜单里显示休眠和关机的扩展。<br />
<br />
另外,想要在屏幕底部显示一个任务栏,但又不想使用 GNOME Classic 的用户可以考虑使用 Window list 扩展 (由 {{Pkg|gnome-shell-extensions}} 提供).<br />
<br />
在安装完一个扩展之后可能需要[[#重启_GNOME_shell|重启 GNOME shell ]] 。故障排除信息参照[[#安装扩展导致GNOME停止工作|安装扩展导致GNOME停止工作]]。<br />
<br />
==== 输入法 ====<br />
<br />
GNOME集成了的通过[[IBus]]的输入法, 只有{{Pkg|ibus}}和添加想要的输入法引擎 (例如:{{Pkg|ibus-libpinyin}} for Intelligent Pinyin) 需要安装,安装后,输入法引擎可以加入GNOME的区域和语言设置键盘布局。<br />
<br />
==== 字体 ====<br />
<br />
{{Tip|If you set the ''Scaling factor'' to a value above 1.00, the Accessibility menu will be automatically enabled.}}<br />
<br />
Fonts can be set for Window titles, Interface (applications), Documents and Monospace. See the Fonts tab in the Tweak Tool for the relevant options.<br />
<br />
For hinting, RGBA will likely be desired as this fits most monitors types, and if fonts appear too blocked reduce hinting to ''Slight'' or ''None''.<br />
==== 启动应用程序====<br />
要启动登录某些应用程序, copy the relevant {{ic|.desktop}} file from {{ic|/usr/share/applications/}} to {{ic|~/.config/autostart/}}.<br />
可以使用Tweak Tool.来达到同样的效果。<br />
<br />
{{Tip|If the plus sign button in the Tweak Tool's Startup Applications section is unresponsive, try start the Tweak Tool from the terminal using the following command: {{ic|gnome-tweak-tool}}. See the following [https://bbs.archlinux.org/viewtopic.php?pid&#61;1413631#p1413631 forum thread].}}<br />
<br />
{{Note|The ''gnome-session-properties'' dialog was removed as of GNOME 3.12. It can be added back by [[install]]ing the {{AUR|gnome-session-properties}} package.}}<br />
==== 电源 ====<br />
<br />
The basic power settings that may want to be altered (these example settings assume the user is using a laptop - change them as desired):<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.power button-power ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout ''3600''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ''hibernate''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout ''1800''<br />
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type ''hibernate''<br />
$ gsettings set org.gnome.desktop.lockdown disable-lock-screen ''true''<br />
<br />
To keep a monitor active on lid close: <br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup do-nothing<br />
<br />
===== Configure behaviour on lid switch close =====<br />
<br />
The GNOME Tweak Tool, as of version 3.17.1, can optionally ''inhibit'' the ''systemd'' setting for the lid close ACPI event.[http://ftp.gnome.org/pub/GNOME/sources/gnome-tweak-tool/3.17/gnome-tweak-tool-3.17.1.news] To ''inhibit'' the setting, start the Tweak Tool and, under the power tab, check the ''Don't suspend on lid close'' option. This means that the system will do nothing on lid close instead of suspending - the default behaviour. Checking the setting creates {{ic|~/.config/autostart/ignore-lid-switch-tweak.desktop}} which will autostart the Tweak Tool's inhibitor.<br />
<br />
If you do not want the system to suspend or do nothing on lid close, you will need to ensure that the setting described above is '''not''' checked and then configure ''systemd'' with {{ic|1=HandleLidSwitch=''preferred_behaviour''}} as described in [[Power management#ACPI events]].<br />
<br />
===== Change critical battery level action =====<br />
<br />
The System Settings panel only allows the user to choose between ''Suspend'' or ''Hibernate''. To choose another option such as ''Do Nothing'' open the {{ic|dconf-editor}} and navigate to {{ic|org.gnome.settings-daemon.plugins.power}}. Edit the {{ic|"critical-battery-action"}} value to {{ic|"nothing"}}.<br />
<br />
==== Sort applications into application (app) folders ====<br />
<br />
{{Tip|The [https://github.com/prurigro/gnome-catgen gnome-catgen] ({{AUR|gnome-catgen-git}}) script allows you to manage folders through the creation of files in {{ic|~/.local/share/applications-categories}} named after each category and containing a list of the desktop files belonging to apps you'd like to have inside. Optionally, you can have it cycle through each app without a folder and input the desired category until you ctrl-c or run out of apps.}}<br />
<br />
In the '''dconf-editor''' navigate to {{ic|org.gnome.desktop.app-folders}} and set the value of {{ic|folder-children}} to an array of comma separated folder names:<br />
<br />
['Utilities', 'Sundry']<br />
<br />
Add applications using {{ic|gsettings}}:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ apps "['alacarte.desktop', 'dconf-editor.desktop']"<br />
<br />
This adds the applications {{ic|alacarte.desktop}} and {{ic|dconf-editor.desktop}} to the Sundry folder. This will also create the folder {{ic|org.gnome.desktop.app-folders.folders.Sundry}}.<br />
<br />
To name the folder (if it has no name that appears at the top of the applications):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ name "Sundry"<br />
<br />
Applications can also be sorted by their category (specified in their ''.desktop'' file):<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ categories "['Office']"<br />
<br />
If certain applications matching a category are not wanted in a certain folder, exclusions can be set:<br />
<br />
$ gsettings set org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Sundry/ excluded-apps "['libreoffice-draw.desktop']"<br />
<br />
For further information, refer to the [https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.app-folders.gschema.xml.in.in app-folders schema].<br />
<br />
== 提示与技巧==<br />
<br />
其他GNOME系统设置和提示。 <br />
<br />
=== 键盘 ===<br />
<br />
==== 登陆打开NumLock键 ====<br />
<br />
运行以下命令:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state on<br />
<br />
==== 热键选择====<br />
<br />
很多的快捷键可以通过系统设置菜单中更改. 例如,重新启用“显示桌面快捷键:<br />
<br />
''System settings'' > ''Keyboard'' > ''Shortcuts'' > ''Navigation'' > ''Hide all normal windows''<br />
<br />
However, certain hotkeys cannot be changed directly via system settings. In order to change these keys, use ''dconf-editor''. An example of particular note is the hotkey {{ic|Alt-}} + {{ic|`}} (the key above {{ic|Tab}} on US keyboard layouts). In GNOME Shell it is pre-configured to cycle through windows of an application, however it is also a hotkey often used in the [[Emacs]] editor. It can be changed by opening ''dconf-editor'' and modifying the ''switch-group'' key found in {{ic|org.gnome.desktop.wm.keybindings}}.<br />
<br />
It is possible to manually change the keys via an application's so-called '''accel''' map file. Where it is to be found is up to the application: For instance, Thunar's is at {{ic|~/.config/Thunar/accels.scm}}, whereas Files's is located at {{ic|~/.config/nautilus/accels}} and {{ic|~/.gnome2/accels/nautilus}} on old release.<br />
<br />
The file should contain a list of possible hotkeys, each unchanged line commented out with a leading ";" that has to be removed for a change to become active.<br />
For example to replace the hotkey used by Files to move files to the trash folder, change the line:<br />
<br />
; (gtk_accel_path "<Actions>/DirViewActions/Trash" "<Primary>Delete")<br />
to this:<br />
<br />
(gtk_accel_path "<Actions>/DirViewActions/Trash" "Delete")<br />
<br />
The file is regenerated regularly so do not comment the file. The uncommented line will stay but every comment you add will be lost.<br />
<br />
==== 打开键盘开关命令 ====<br />
<br />
To have keyboard shortcut '''Alt''' + '''Shift''' switch keyboards:<br />
<br />
Open Gnome-Tweak-Tool (or Keyboard Settings, in GNOME 3.16) and set ''Typing'' > ''Modifiers-only input sources'' > ''select Alt-shift''. For more information see also the forum [https://bbs.archlinux.org/viewtopic.php?id=152127 thread].<br />
<br />
==== XkbOptions键盘选项 ====<br />
<br />
Using the '''dconf-editor''', navigate to the key named {{ic|org.gnome.desktop.input-sources.xkb-options}} and add desired XkbOptions (e.g. ''caps:swapescape'') to the list.<br />
<br />
See {{ic|/usr/share/X11/xkb/rules/xorg}} for all XkbOptions and {{ic|/usr/share/X11/xkb/symbols/*}} for the respective descriptions.<br />
<br />
{{Note|To enable the {{ic|Ctrl+Alt+Backspace}} combination to terminate Xorg, use the {{Pkg|gnome-tweak-tool}}. Within the '''Tweak Tool''', navigate to ''Typing > Key sequence to kill the X server'' and select the option {{ic|Ctrl+Alt+Backspace}} from the dropdown menu.}}<br />
<br />
==== De-bind Windows key ====<br />
<br />
默认情况下,“Windows键”将打开GNOMEshelly预览模式。 You can unbind this key by running the command below<br />
<br />
$ gsettings set org.gnome.mutter overlay-key 'Foo'<br />
<br />
=== 磁盘===<br />
<br />
GNOME提供磁盘实用程序来操作的存储驱动器设置。这是它的一些特点:<br />
<br />
* '''Enable write cache''' is a feature that most hard drives provide. Data is cached and allocated at chosen times to improve system performance. Not recommended unless the computer has a backup battery pack or is a laptop as data would be lost on power failure.<br />
: ''Settings'' > ''Drive Settings'' > ''Write Cache'' > '''On'''<br />
* '''Automatic Mount Options''' can mount drives and partitions that are GPT based - will use default, recommended options.<br />
: {{Warning|This setting erases related [[fstab]] entries}}<br />
: ''Partition Settings'' > ''Edit Mount Options'' > ''Automatic Mount Options'' > '''On'''<br />
<br />
=== 从菜单隐藏的应用程序===<br />
<br />
{{Tip|Desktop entries can be hidden by editing the {{ic|.desktop}} files themselves. See [[Desktop entries#Hide desktop entries]].}}<br />
<br />
Use the ''Main Menu'' application (provided by the {{Pkg|alacarte}} package) to hide any applications you do not wish to show in the menu.<br />
<br />
=== 截屏记录 ===<br />
<br />
GNOME features built-in screencast recording with the '''Ctrl''' + '''Shift''' + '''Alt''' + '''R''' key combination. A red circle is displayed in the bottom right corner of the screen when the recording is in progress. After the recording is finished, a file named {{ic|Screencast from %d%u-%c.webm}} is saved in the Videos directory. In order to use the screencast feature the gst plugins need to be installed.<br />
<br />
=== 截图 ===<br />
<br />
默认保存目录:<br />
<br />
$ gsettings set org.gnome.gnome-screenshot auto-save-directory file:///home/''USER''/Desktop<br />
<br />
Check the ''gnome-screenshot'' manual page for more options.<br />
<br />
===注销延迟 ===<br />
去掉注销的确认和 60 秒的延迟:<br />
这个对话框一般出现在你用状态菜单注销的时候。这个修改对于 关机 也生效。这个不是全局修改,只对使用该命令的用户生效。使用该命令立即生效。<br />
$ gsettings set org.gnome.SessionManager logout-prompt false<br />
<br />
=== 禁用动画 ===<br />
<br />
To disable Shell animations (such as "Show Applications" and the wave animation in the top left activities hot corner), run:<br />
<br />
$ gsettings set org.gnome.desktop.interface enable-animations false<br />
<br />
=== Retina (HiDPI) display support ===<br />
<br />
GNOME introduced HiDPI support in version 3.10. If your display does not provide the correct screen size through EDID, this can lead to incorrectly scaled UI elements. As a workaround you can open ''dconf-editor'' and find the key {{ic|scaling-factor}} in {{ic|org.gnome.desktop.interface}}. Set it to {{ic|1}} to get the standard scale.<br />
<br />
Also see [[HiDPI]].<br />
<br />
=== 密码和密钥 (PGP Keys) ===<br />
<br />
You can use the Passwords and Keys program (''seahorse'') to create a PGP key as it is a front end for [[GnuPG]] and installs it as dependency. This may be useful in the future (for instance if to encrypt a file). Create a key as shown below (the process may take about 10 minutes):<br />
<br />
''File'' > ''New'' > ''PGP Key'' > ''Name'' > ''Email'' > ''Defaults'' > ''Passphrase''.<br />
<br />
=== 终端 ===<br />
<br />
==== 更改默认的终端大小====<br />
<br />
新终端的默认大小可以在''编辑 > 配置文件首选项 ''中调整<br />
<br />
==== 新终端采用当前目录====<br />
<br />
By default new terminals open in the {{ic|$HOME}} directory. To have new terminals adopt the current working directory: {{ic|source /etc/profile.d/vte.sh}}. Add the command to the shell configuration to retain the behaviour.<br />
<br />
==== Pad the terminal ====<br />
<br />
To pad the terminal (create a small, invisible border between the window edges and the terminal contents) create the file below:<br />
<br />
{{hc|~/.config/gtk-3.0/gtk.css|<nowiki><br />
VteTerminal,<br />
TerminalScreen {<br />
padding: 10px 10px 10px 10px;<br />
-VteTerminal-inner-border: 10px 10px 10px 10px;<br />
}</nowiki>}}<br />
<br />
==== 禁用光标闪烁====<br />
<br />
Since GNOME 3.8 and the migration to GSettings and DConf the key required to modify in order to disable the blinking cursor in the Terminal differs slightly in contrast to the old GConf key. To disable the blinking cursor in GNOME 3.8 and above use:<br />
<br />
$ gsettings set org.gnome.desktop.interface cursor-blink false<br />
<br />
To disable the blinking cursor in Terminal only use (make sure profile uid is correct one):<br />
<br />
$ dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/cursor-blink-mode "'off'"<br />
<br />
Note that {{ic|gnome-settings-daemon}}, from the package of the same name, must be running for this and other settings changes to take effect in GNOME applications - see [[GNOME#Configuration]].<br />
<br />
====关闭终端时,禁用确认窗口====<br />
<br />
试图关闭该窗口,而一个以root身份登录时,终端将始终显示一个确认窗口。为了避免这种情况,执行以下命令:<br />
$ gsettings set org.gnome.Terminal.Legacy.Settings confirm-close false<br />
<br />
=== 鼠标中键===<br />
<br />
By default, GNOME 3 disables middle mouse button emulation regardless of [[Xorg]] settings ('''Emulate3Buttons'''). To enable middle mouse button emulation use:<br />
<br />
$ gsettings set org.gnome.settings-daemon.peripherals.mouse middle-button-enabled true<br />
<br />
=== 启用按钮和菜单图标===<br />
<br />
Since GTK+ 3.10, the GSettings key 'menus-have-icons' has been deprecated. Icons in buttons and menus can still be enabled by setting the following overrides:<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"<br />
<br />
=== 使用自定义的色彩和渐变色的桌面背景 ===<br />
使用自定义颜色和渐变为您的桌面背景,您首先需要设置一个透明的图片或其他不存在的图片作为您的桌面背景。例如,下面的命令将设置一个不存在的图片为背景。<br />
<br />
$ gsettings set org.gnome.desktop.background picture-uri none<br />
<br />
在这一点上,桌面背景应该是一个平坦的颜色-默认的颜色设置为深蓝色。<br />
<br />
对于不同的平面彩色你只需要改变的主要颜色设置:<br />
<br />
$ gsettings set org.gnome.desktop.background primary-color <my color><br />
where <my color> is a hex value (such as ''ffffff'' for white).<br />
<br />
对于颜色渐变,你也需要改变次要颜色设置 {{ic|org.gnome.desktop.background secondary-color}} <br />
并选择一个阴影类型。举例来说,如果你想有一个horizontal gradient,执行以下命令:<br />
$ gsettings set org.gnome.desktop.background color-shading-type horizontal<br />
<br />
如果你是使用一个透明的图片作为你的背景,你可以通过执行以下设置的透明度:<br />
$ gsettings set org.gnome.desktop.background picture-opacity <value><br />
数值在100和1之间(最大不透明度为100)。<br />
<br />
=== 渐变背景===<br />
<br />
GNOME 可以在特定的时间间隔之间的使用不同的壁纸。 这是通过创建一个XML文件,指定要使用的图片和时间间隔完成的。有关创建这些文件的详细信息,请参阅下面的 [http://www.linuxjournal.com/content/create-custom-transitioning-background-your-gnome-228-desktop article].<br />
<br />
可替代地,一些工具可用自动化过程:<br />
* {{App|mkwlppr|This script creates XML files that can act as dynamic wallpapers for GNOME by referring to multiple wallpapers.|http://pastebin.com/019G2rCy|see [http://pastebin.com/019G2rCy mkwlppr]}}<br />
* {{App|[[Wallpapoz]]|Wallpapoz is a tool that provides dynamic wallpapers for GNOME and Xfce desktops.|https://vajrasky.wordpress.com/|{{AUR|wallpapoz}}}}<br />
* {{App|CreBS|A Python/GTK application used to create and set desktop wallpaper slideshows for GNOME.|http://www.obfuscatepenguin.net/|{{AUR|crebs}}}}<br />
<br />
对于设置XML文件作为默认的背景,参阅 [[#Lock screen and background]].<br />
<br />
=== 自定义 GNOME 会话 ===<br />
<br />
It is possible to create custom GNOME sessions which use the GNOME session manager but start different sets of components ([[Openbox]] with [[tint2]] instead of GNOME Shell for example).<br />
<br />
Two files are required for a custom GNOME session: a session file in {{ic|/usr/share/gnome-session/sessions/}} which defines the components to be started and a [[desktop entry]] in {{ic|/usr/share/xsessions}} which is read by the [[display manager]]. An example session file is provided below:<br />
{{hc|/usr/share/gnome-session/sessions/gnome-openbox.session|<nowiki><br />
[GNOME Session]<br />
Name=GNOME Openbox<br />
RequiredComponents=openbox;tint2;gnome-settings-daemon;<br />
</nowiki>}}<br />
<br />
And an example desktop file:<br />
{{hc|/usr/share/xsessions/gnome-openbox.desktop|<nowiki><br />
[Desktop Entry]<br />
Name=GNOME Openbox<br />
Exec=gnome-session --session=gnome-openbox<br />
</nowiki>}}<br />
<br />
{{Note|GNOME Session calls upon the {{ic|.desktop}} files of each of the components to be started. If a component you wish to start does not provide a {{ic|.desktop}} file, you must create a suitable desktop entry in a directory such as {{ic|/usr/local/share/applications}}.}}<br />
<br />
==故障排除==<br />
<br />
=== 终端冻结 ===<br />
<br />
In the event of a Shell freeze (which might be caused by certain appearance tweaks, malfunctioning extensions or perhaps a lack of available memory) restarting the Shell by pressing {{ic|Alt}} + {{ic|F2}} and then entering '''r''' may not be possible.<br />
<br />
In this case, try switching to another TTY ('''Ctrl''' + '''Alt''' + '''F2''') and entering the following command: {{ic|pkill -HUP gnome-shell}}. It may take a few seconds before the Shell successfully restarts. Restarting the shell in this fashion should not log the user out but it is a good idea to try and ensure that all work is saved anyway.<br />
<br />
If this fails, the [[Xorg]] server will need to be restarted either by: {{ic|pkill X}} for console logins or: {{ic|systemctl restart gdm}} for GDM logins. Bear in mind that restarting the Xorg server will log the user out so try to ensure that all work is saved before attempting this.<br />
<br />
=== Incorrect application defaults ===<br />
<br />
When installing applications for the first time you may find that GNOME has the wrong application associated to a certain protocols - for instance, ''easytag'' becomes the folder handler instead of [[GNOME Files]].<br />
<br />
For GNOME Files see the following page: [[GNOME Files#Files is no longer the default file manager]].<br />
<br />
For Document Viewer, run the following command:<br />
$ xdg-mime default evince.desktop application/pdf<br />
<br />
For other applications, default handler settings are detailed on the following page: [[Default applications]].<br />
<br />
Optionally, you can [[install]] {{AUR|gnome-defaults-list}}. It will place your configuration file at {{ic|/etc/gnome/defaults.list}}.<br />
<br />
=== Tracker & Documents do not list any local files ===<br />
<br />
In order for Tracker (and, therefore, Documents) to detect your local files, they must be stored in an [http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html XDG compliant directory] (such as 'Documents' or 'Music'). For more information, see [[Xdg user directories]].<br />
<br />
You can also configure Tracker to recursively search inside specific directories such as your home directory. These settings can be made using {{ic|tracker-preferences}}.<br />
<br />
=== Unable to add accounts in Empathy and GNOME Online Accounts ===<br />
<br />
Empathy, the engine behind integrated messaging, GNOME Online Accounts, and all other system settings based on messaging accounts will not function correctly unless the {{Grp|telepathy}} group of packages or at least one of the backends ({{Pkg|telepathy-gabble}}, or {{Pkg|telepathy-haze}}, for example) is [[install]]ed. View descriptions of ''telepathy'' components on the [http://telepathy.freedesktop.org/wiki/Components freedesktop.org telepathy wiki].<br />
<br />
{{Note|[[Avahi]] daemon is required for connecting with the People Nearby account, and also in order for some desktop extensions to work correctly like [https://extensions.gnome.org/extension/746/chat-status/ Chat Status]}}<br />
<br />
=== Cannot change settings in dconf-editor ===<br />
<br />
When one cannot set settings in {{pkg|dconf}}, it is possible their dconf user settings are corrupt. In this case it is best to delete the user dconf files in {{ic|~/.config/dconf/user*}} and set the settings in dconf-editor after.<br />
<br />
=== When an extension breaks the shell ===<br />
<br />
When enabling shell extensions causes GNOME breakage, you should first remove the ''user-theme'' and ''auto-move-windows'' extensions from their installation directory.<br />
<br />
The installation directory could be one of {{ic|~/.local/share/gnome‑shell/extensions}}, {{ic|/usr/share/gnome‑shell/extensions}} or {{ic|/usr/local/share/gnome‑shell/extensions}}. Removing these two extension-containing folders may fix the breakage. Otherwise, isolate the problem extension with trial‑and‑error.<br />
<br />
Removing or adding an extension-containing folder to the aforementioned directories removes or adds the corresponding extension to your system. Details on GNOME Shell extensions are available at the [https://live.gnome.org/GnomeShell/Extensions GNOME web site.]<br />
<br />
If you have trouble with uninstalling an extension via [https://extensions.gnome.org/local/ extensions.gnome.org/local], then probably they have been installed as system-wide extensions with the {{Pkg|gnome-shell-extensions}} package. Removing the package again obviously affects all user accounts.<br />
<br />
=== 扩展在 GNOME 3 升级后不工作了===<br />
<br />
{{Note|Please bear in mind that whilst the methods below will allow you to '''try''' and activate an extension with an unsupported version of GNOME Shell, it is by no means a guarantee that the extension will work successfully. The most likely outcome of trying to activate such an extension is that GNOME Shell will crash and then restart.}}<br />
<br />
Before trying the workarounds below, check if an update is available for the extension by visiting [https://extensions.gnome.org/local extensions.gnome.org/local]. <br />
<br />
If there is no update for your current GNOME version yet, use the following command to disable version validation for extensions:<br />
$ gsettings set org.gnome.shell disable-extension-version-validation true<br />
<br />
Alternatively, you could modify the extension itself, changing the supported shell version to satisfy the version validation. See the method below.<br />
<br />
<br />
找到扩展的安装目录,可能是 {{ic|~/.local/share/gnome-shell/extensions}} 或 {{ic|/usr/share/gnome-shell/extensions}}.<br />
<br />
编辑扩展子文件夹中的每一个 '''{{ic|metadata.json}}''' <br />
<br />
{| border="0"<br />
| Insert: || {{ic|"shell-version": ["3.x"]}}<br />
|-<br />
| Instead of (for example): || {{ic|"shell-version": ["3.4"]}}<br />
|}<br />
<br />
{{ic|"3.x"}} 是最好的选择,这个表示扩展能在所有 '''''3.x''''' GNOME Shell版本下工作。<br />
<br />
=== 只有 conky 运行时键盘快捷方式不工作 ===<br />
gnome-shell 键盘快捷方式(如 Alt+F2,Alt+F1 和多媒体键快捷方式)当只有 conky 运行时不会工作。然而如果另一个程序(例如 gedit)在运行,键盘快捷方式就可以工作了。<br />
<br />
解决方式:编辑 .conkyrc <br />
<br />
own_window yes<br />
own_window_transparent yes<br />
own_window_argb_visual yes<br />
own_window_type dock<br />
own_window_class Conky<br />
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager<br />
<br />
=== Unable to apply stored configuration for monitors ===<br />
<br />
If you encounter this message try to disable the ''xrandr'' {{ic|gnome-settings-daemon plugin}}:<br />
<br />
$ dconf write /org/gnome/settings-daemon/plugins/xrandr/active false<br />
<br />
=== 一致的光标主题 ===<br />
<br />
See [[Cursor themes#Desktop environments]].<br />
<br />
=== Windows cannot be modified with Alt-Key + mouse-button ===<br />
<br />
In GNOME 3.6 and above, the mouse button modifier (the key that allows you to drag a window from a location other than the titlebar) is the {{ic|Super}} key instead of the {{ic|Alt}} key which was used in the past. The change was made in response to the following [https://bugzilla.gnome.org/show_bug.cgi?id=607797 bug report]. <br />
<br />
To change the mouse button modifier back to the {{ic|Alt}} key, execute the following:<br />
$ gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier '<Alt>' <br />
<br />
{{Note|It is not possible to change this with ''System settings'' > ''Keyboard'' > ''Shortcuts''}}<br />
<br />
=== 加载速度慢的系统图标/慢GDM登录===<br />
<br />
{{Accuracy|1=As per [https://bbs.archlinux.org/viewtopic.php?pid=1565891#p1565891], it's probably the fact that on {{Pkg|gdk-pixbuf2}} post install {{ic|gdk-pixbuf-query-loaders --update-cache}} is run which fixes the issue, not the re-installation of the package per se.}}<br />
<br />
Problems with the loading of system icons, such the ones in the title bar of Files, might be solved by [[pacman#Installing specific packages|installing]] (or re-installing) the {{Pkg|gdk-pixbuf2}} package.<br />
<br />
Re-installing the aforementioned package may also fix repeated occurrences of the "Oh no! Something has gone wrong!" error screen and/or very slow loading and login with GDM as described in the following [https://bbs.archlinux.org/viewtopic.php?pid=1414157 forum thread].<br />
<br />
=== Artifacts when maximizing windows ===<br />
<br />
Maximizing windows may cause artifacts as of GNOME 3.12.0 - see the following [https://bbs.archlinux.org/viewtopic.php?id=183617 forum thread] and [https://bugzilla.gnome.org/show_bug.cgi?id=728385 bug report]. A solution is detailed in the following section: [[#Tear-free video with Intel HD Graphics]].<br />
<br />
=== Tear-free video with Intel HD Graphics ===<br />
<br />
;Intel TearFree<br />
Enabling the [[Intel _Graphics#Tear-free_video|Xorg Intel TearFree option]] is a known workaround for tearing problems on Intel adapters. However, the way this option acts makes it redundant with the use of a compositor (it increases memory consumption and lowers performance, see [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c123 the original bug report's final comment]).<br />
<br />
;DRI3<br />
According to [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c2 this bug report], DRI3 includes the {{ic|buffer_age}} extension that allows GNOME Shell's Mutter compositor to sync windows to vblank in an efficient way. DRI3 support is not compiled in to the mesa package, so you have to recompile {{Pkg|mesa}} with {{ic|--enable-dri3}} in the {{ic|./configure}} flags (see [[ABS]]). Then enable it in the Xorg driver:<br />
<br />
{{hc|/etc/X11/xorg.conf.d/20-intel.conf|<br />
Section "Device"<br />
Identifier "Intel Graphics"<br />
Driver "intel"<br />
Option "DRI" "3"<br />
EndSection}}<br />
<br />
;Mutter tweaks<br />
{{Note|1=This workaround has been [https://bugzilla.gnome.org/show_bug.cgi?id=711028#c0 reported] to have side effects and may not fix tearing in all cases.}}<br />
GNOME Shell's Mutter compositor has a tweak known to address tearing problems (see [https://bugzilla.gnome.org/show_bug.cgi?id=657071#c1 the original suggestion for this fix] and its mention in [https://bugs.freedesktop.org/show_bug.cgi?id=37686#c59 the Freedesktop bug report]). To enable this tweak, append the following line to {{ic|/etc/environment}}: {{ic|1=CLUTTER_PAINT=disable-clipped-redraws:disable-culling}}. Then restart the Xorg server.<br />
<br />
=== Window opens behind other windows when using multiple monitors ===<br />
<br />
This is possibly a bug in GNOME Shell which causes new windows to open behind others. To fix this issue, one can run the following command:<br />
$ gsettings set org.gnome.shell.overrides workspaces-only-on-primary false<br />
<br />
=== 锁定按钮无法重新启用触摸板===<br />
<br />
Some laptops have a touchpad lock button that disables the touchpad so that users can type without worrying about touching the touchpad. Currently, it appears that although GNOME can lock the touchpad by pressing this button, it cannot unlock it. If the touchpad gets locked you can run the following to unlock it:<br />
<br />
$ xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1<br />
<br />
=== GNOME Shell键盘源菜单不可见 ===<br />
<br />
A menu showing the keyboard input sources (for example 'en' for an English keyboard layout) should be visible next to the status area containing icons for network, volume and power sources. If the keyboard sources menu is not visible, this is probably because you have configured your [[Xorg]] keyboard layout in a way which GNOME does not recognise.<br />
<br />
To ensure that the menu is visible, remove any Xorg keyboard configuration you might have created and set the keyboard locale using [[Keyboard_configuration_in_Xorg#Using_localectl|localectl]].<br />
<br />
Upon running the command and then logging out, you should find that the keyboard input sources menu is visible in GDM and in the GNOME Shell desktop. See [http://blogs.gnome.org/mclasen/2012/09/21/input-sources-in-gnome/ Input sources in GNOME] for more information.<br />
<br />
=== 鼠标指针丢失 ===<br />
<br />
When using a separate [[window manager]] with ''gnome-settings-daemon'', the mouse cursor may vanish. Run:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.cursor active false<br />
<br />
=== 在会话菜单中没有重启按钮时,屏幕被锁定===<br />
<br />
If [[XScreenSaver]] is installed, ensure that it is not running at startup, see [[GNOME#Startup applications]].<br />
<br />
=== pulseaudio系统原因延误GNOME和GDM ===<br />
<br />
If you are running [[PulseAudio]] in system-wide mode, the PulseAudio 7.0 upgrade breaks [[GDM]] and GNOME.<br />
See [https://bbs.archlinux.org/viewtopic.php?id=203051 this forum post] for more information.<br />
<br />
=== GNOME crashes when trying to reorder applications in the GNOME Shell Dash ===<br />
The dash is the "toolbar" that appears, by default, [[wikipedia:GNOME_Shell#Design_components|on the left]] when you click Activities. Applications can be reordered in the dash by dragging and dropping. If this fails, and/or causes GNOME to crash, try [https://bbs.archlinux.org/viewtopic.php?id=171689 changing your icon theme].<br />
<br />
== 参见 ==<br />
* [http://www.gnome.org/ 官方网站]<br />
* [http://extensions.gnome.org/ GNOME-shell扩展]<br />
* 主题、图标和壁纸:<br />
** [http://art.gnome.org/ GNOME Art]<br />
** [http://www.gnome-look.org/ GNOME Look]<br />
* GTK/GNOME 程序:<br />
** [http://www.gnomefiles.org/ GNOME Files]<br />
** [http://www.gnome.org/projects/ GNOME Project Listing]<br />
* [http://blog.fpmurphy.com/2011/03/customizing-the-gnome-3-shell.html 自定义GNOME Shell]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416492PHP (简体中文)2016-01-21T05:30:07Z<p>无极: /* 拓展 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
一些常用的PHP扩展也可以在官方库发现:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|不要编辑{{ic|/etc/php/php.ini}}, 拓展的启停可在 {{ic|/etc/php/conf.d}} 中设置,如: (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
如果你想使用POSIX多线程需要pthreads拓展 。To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
可在 [[PHP pthreads extension]] 页面找到指令介绍。<br />
<br />
=== mcrypt ===<br />
<br />
如果想用 {{ic|mcrypt}} 模块, 安装 {{Pkg|php-mcrypt}} 以及在{{ic|/etc/php/php.ini}}中注释掉下面这行:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416491PHP (简体中文)2016-01-21T05:19:44Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416490PHP (简体中文)2016-01-21T05:18:59Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416489PHP (简体中文)2016-01-21T05:18:00Z<p>无极: /* 配置 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{Tips| Prior to 22 November 2015, 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416488PHP (简体中文)2016-01-21T05:17:22Z<p>无极: </p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP]是一种广泛使用的通用脚本语言,特别适合于Web开发,可嵌入到HTML。<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
虽然PHP可以独立运行,它通常用于HTTP服务器如: [[Apache HTTP Server]], [[nginx]] 和 [[lighttpd]].<br />
<br />
使用命令:“{{ic|php -S localhost:8000 -t public_html/}} ”可以独立运行PHP。 见 [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
主要PHP配置位于 {{ic|/etc/php/php.ini}}.<br />
<br />
* I建议在{{ic|/etc/php/php.ini}} 中设置所在时区([https://secure.php.net/manual/en/timezones.php list of timezones]) 。如下:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* 如果你想调试PHP时显示错误,在{{ic|/etc/php/php.ini}}中将{{ic|display_errors}} 设为 {{ic|On}}:<br />
<br />
display_errors=On<br />
<br />
{{建议| Prior to 22 November 2015, 保持{{Pkg|php-composer}} 的配置文件在单独的文件夹中,如: {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416487PHP (简体中文)2016-01-21T05:04:43Z<p>无极: /* 缓存 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== 缓存 ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416486PHP (简体中文)2016-01-21T05:03:07Z<p>无极: /* 故障排除 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== 故障排除 ==<br />
<br />
=== PHP Fatal error: 'ZipArchive' 类找不到 ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416485PHP (简体中文)2016-01-21T05:00:59Z<p>无极: /* 参见 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== 参见 ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416484PHP (简体中文)2016-01-21T05:00:03Z<p>无极: /* 开发工具 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== 开发工具 ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416483PHP (简体中文)2016-01-21T04:58:33Z<p>无极: /* E拓展 */</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== 拓展==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416482PHP (简体中文)2016-01-21T03:50:57Z<p>无极: </p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== 配置==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416319PHP (简体中文)2016-01-20T14:44:36Z<p>无极: </p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
{{translateme (简体中文)}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416318PHP (简体中文)2016-01-20T14:40:09Z<p>无极: Created page with "Category:简体中文 Category:Programming languages(简体中文) de:PHP es:PHP fr:Lamp it:PHP ja:PHP ru:PHP sr:PHP zh-CN:PHP {{Re..."</p>
<hr />
<div>[[Category:简体中文]]<br />
[[Category:Programming languages(简体中文)]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== 安装 ==<br />
<br />
[[安装]] 从[[官方源]]安装{{Pkg|php}} 。<br />
<br />
注意:要想像纯CGI那样运行PHP,你需要安装 {{Pkg|php-cgi}} 。<br />
<br />
== 运行 ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP&diff=416317PHP2016-01-20T14:35:44Z<p>无极: </p>
<hr />
<div>[[Category:Programming languages]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh-CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|php}} package from the [[official repositories]].<br />
<br />
Note that to run PHP scripts as plain CGI, you need the {{Pkg|php-cgi}} package.<br />
<br />
== Running ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP&diff=416316PHP2016-01-20T14:34:36Z<p>无极: </p>
<hr />
<div>[[Category:Programming languages]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|php}} package from the [[official repositories]].<br />
<br />
Note that to run PHP scripts as plain CGI, you need the {{Pkg|php-cgi}} package.<br />
<br />
== Running ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP&diff=416313PHP2016-01-20T14:28:34Z<p>无极: </p>
<hr />
<div>[[Category:Programming languages]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh_CN:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|php}} package from the [[official repositories]].<br />
<br />
Note that to run PHP scripts as plain CGI, you need the {{Pkg|php-cgi}} package.<br />
<br />
== Running ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP&diff=416312PHP2016-01-20T14:24:51Z<p>无极: </p>
<hr />
<div>[[Category:Programming languages]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|php}} package from the [[official repositories]].<br />
<br />
Note that to run PHP scripts as plain CGI, you need the {{Pkg|php-cgi}} package.<br />
<br />
== Running ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=PHP&diff=416311PHP2016-01-20T14:23:57Z<p>无极: </p>
<hr />
<div>[[Category:Programming languages]]<br />
[[de:PHP]]<br />
[[es:PHP]]<br />
[[fr:Lamp]]<br />
[[it:PHP]]<br />
[[ja:PHP]]<br />
[[ru:PHP]]<br />
[[sr:PHP]]<br />
[[zh:PHP]]<br />
{{Related articles start}}<br />
{{Related|Pdepend}}<br />
{{Related|Php-codesniffer-drupal}}<br />
{{Related|PhpMetrics}}<br />
{{Related|PHPLOC}}<br />
{{Related|PhpDox}}<br />
{{Related articles end}}<br />
<br />
[http://www.php.net/ PHP] is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|php}} package from the [[official repositories]].<br />
<br />
Note that to run PHP scripts as plain CGI, you need the {{Pkg|php-cgi}} package.<br />
<br />
== Running ==<br />
<br />
While PHP can be run standalone, it is typically used with http servers such as [[Apache HTTP Server]], [[nginx]] and [[lighttpd]].<br />
<br />
To run PHP standalone issue the {{ic|php -S localhost:8000 -t public_html/}} command. See [https://secure.php.net/manual/en/features.commandline.webserver.php documentation].<br />
<br />
== Configuration ==<br />
<br />
The main PHP configuration file is well-documented and located at {{ic|/etc/php/php.ini}}.<br />
<br />
* It is recommended to set your timezone ([https://secure.php.net/manual/en/timezones.php list of timezones]) in {{ic|/etc/php/php.ini}} like so:<br />
<br />
date.timezone = Europe/Berlin<br />
<br />
* If you want to display errors to debug your PHP code, change {{ic|display_errors}} to {{ic|On}} in {{ic|/etc/php/php.ini}}:<br />
<br />
display_errors=On<br />
<br />
{{Tip| Prior to 22 November 2015, {{Pkg|php-composer}} kept its settings in a separate file in {{ic|/usr/share/php-composer/php.ini}} }}<br />
<br />
== Extensions ==<br />
<br />
A number of commonly used PHP extensions can also be found in the official repositories:<br />
<br />
$ pacman -Ss php-<br />
<br />
{{Tip|Instead of editing {{ic|/etc/php/php.ini}}, a extension may be enabled/configured in the {{ic|/etc/php/conf.d}} directory instead (e.g. {{ic|/etc/php/conf.d/gd.ini}})}}<br />
<br />
=== gd ===<br />
<br />
For {{Pkg|php-gd}} uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=gd.so<br />
<br />
=== imagemagick ===<br />
<br />
For {{Pkg|imagemagick}} run {{ic|# pecl install imagick}}. The ''pecl'' binary is included in the {{AUR|php-pear}} package. Then add<br />
<br />
extension=imagick.so<br />
<br />
to {{ic|/etc/php/php.ini}}.<br />
<br />
=== pthreads ===<br />
<br />
If you wish to have POSIX multi-threading you will need the pthreads extension. To install the pthreads (http://pecl.php.net/package/pthreads) extension using {{ic|pecl}} you are required to use a compiled version of PHP with the the thread safety support flag {{ic|--enable-maintainer-zts}}. Currently the most clean way to do this would be to rebuild the original package with the flag.<br />
<br />
Instruction can be found on the [[PHP pthreads extension]] page.<br />
<br />
=== mcrypt ===<br />
<br />
If you want the {{ic|mcrypt}} module, install {{Pkg|php-mcrypt}} and uncomment the line in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=mcrypt.so<br />
<br />
=== PCNTL ===<br />
<br />
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives the power to PHP to mess things up really bad. So it is a PHP extension that cannot be loaded like other more convenient extension. This is because of the great power it gives to PHP. To enable it (by default it is disabled) PCNTL has to be compiled into PHP.<br />
<br />
=== MySQL/MariaDB ===<br />
<br />
Install and configure MySQL/MariaDB as described in [[MariaDB]].<br />
<br />
Uncomment [https://secure.php.net/manual/en/mysqlinfo.api.choosing.php the following lines] in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_mysql.so<br />
extension=mysqli.so<br />
<br />
{{Warning|{{ic|mysql.so}} was [https://secure.php.net/manual/en/migration70.removed-exts-sapis.php removed] in PHP 7.0.}}<br />
<br />
You can add minor privileged MySQL users for your web scripts. You might also want to edit {{ic|/etc/mysql/my.cnf}} and uncomment the {{ic|skip-networking}} line so the MySQL server is only accessible by the localhost. You have to restart MySQL for changes to take effect.<br />
<br />
{{Tip|You may want to install a tool like [[phpMyAdmin]], [[Adminer]] or {{Pkg|mysql-workbench}} to work with your databases.}}<br />
<br />
=== PostgreSQL ===<br />
<br />
Install and configure [[PostgreSQL]], then install the {{pkg|php-pgsql}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_pgsql.so<br />
extension=pgsql.so<br />
<br />
=== Sqlite ===<br />
<br />
Install and configure [[SQLite]], then install the {{pkg|php-sqlite}} package and uncomment the following lines in {{ic|/etc/php/php.ini}}:<br />
<br />
extension=pdo_sqlite.so<br />
extension=sqlite3.so<br />
<br />
== Caching ==<br />
<br />
There are two kinds of caching in PHP: ''opcode''/''bytecode'' caching and ''userland''/''user data'' caching. Both allow for substantial gains in applications speed, and therefore should be enabled wherever possible.<br />
<br />
* [[wikipedia:Zend Opcache|Zend OPCache]] provides only ''opcode'' caching.<br />
* [https://github.com/krakjoe/apcu/ APCu] provides only ''userland'' caching.<br />
<br />
For optimal caching, you should enable '''both'''. To do this, follow ''both'' [[#OPCache]] ''and'' [[#APCu]].<br />
<br />
=== OPCache ===<br />
<br />
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your [[#Configuration|PHP configuration file]]:<br />
{{hc|/etc/php/php.ini|2=zend_extension=opcache.so}}<br />
<br />
A list of its options and suggested settings can be found in its [https://secure.php.net/manual/en/book.opcache.php official entry] on the PHP website.<br />
<br />
{{Warning|If you choose to apply the [https://secure.php.net/manual/en/opcache.installation.php#opcache.installation.recommended suggested settings] its manual offers, be sure to read carefully [https://secure.php.net/manual/en/opcache.installation.php#114567 the first comment] below those instructions as well. In some configurations those settings result in errors such as {{ic|zend_mm_heap corrupted}} being produced.}}<br />
<br />
=== APCu ===<br />
<br />
APCu can be installed with the {{Pkg|php-apcu}} package. You can then enable it by uncommenting the following line in {{ic|/etc/php/conf.d/apcu.ini}}, or adding it to your [[#Configuration|PHP configuration file]]:<br />
<br />
extension=apcu.so<br />
<br />
Its author recommends a few [https://github.com/krakjoe/apcu/blob/master/INSTALL suggested settings], among which:<br />
* {{ic|1=apc.enabled=1}} and {{ic|1=apc.shm_size=32M}} are not really required as they represent the [https://secure.php.net/manual/en/apc.configuration.php default values];<br />
* {{ic|1=apc.ttl=7200}} on the other hand seems [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.ttl rather beneficial];<br />
* finally, {{ic|1=apc.enable_cli=1}}, which although [https://secure.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli not recommended] by the manual may be required by some software such as [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 ownCloud].<br />
<br />
{{Tip|You can add those settings either to APCu's own {{ic|/etc/php/conf.d/apcu.ini}} '''or''' directly to your [[#Configuration|PHP configuration file]]. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.}}<br />
<br />
== Development tools ==<br />
<br />
=== Aptana Studio ===<br />
<br />
[http://www.aptana.com/products/studio3.html Aptana Studio] is an IDE for programming in PHP and web development. It can be installed with the {{AUR|aptana-studio}} package. Does not have a PHP debugger as of version 3.2.2.<br />
<br />
=== Eclipse PDT ===<br />
<br />
[http://www.eclipse.org/pdt/ Eclipse PDT] is the PHP variant of Eclipse. It can be installed with the {{Pkg|eclipse-php}} package. See [[Eclipse]] for more information.<br />
<br />
You would need other plugins for JavaScript support and DB query.<br />
<br />
=== Komodo ===<br />
<br />
[http://komodoide.com/ Komodo] is an IDE with good integration for PHP+HTML+JavaScript. [http://komodoide.com/komodo-edit/ Komodo Edit] is a free editor-only variant.<br />
<br />
=== Netbeans ===<br />
<br />
A complete IDE for many languages including PHP. Includes features like debugging, refactoring, code tempalting, autocomplete, XML features, and web design and development functionalities (very good CSS autocomplete functionality and PHP/JavaScript code notifications/tips). Install it with the {{Pkg|netbeans}} package.<br />
<br />
=== PhpStorm ===<br />
<br />
[[Wikipedia:PhpStorm|JetBrains PhpStorm]] is a commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. It can be installed with the {{AUR|phpstorm}} package, or with {{AUR|phpstorm-eap}} for the 30-day trial version. You can get a free license for education from Jetbrains.[https://www.jetbrains.com/student/]<br />
<br />
=== Zend Studio ===<br />
<br />
[http://www.zend.com/products/studio/ Zend Studio] is the official PHP IDE, based on eclipse. The IDE has autocomplete, advanced code formatting, WYSIWYG html editor, refactoring, and all the eclipse features such as db access and version control integration and whatever you can get from other eclipse plugins. You can install it with the {{AUR|zendstudio}} package.<br />
<br />
== Troubleshooting ==<br />
<br />
=== PHP Fatal error: Class 'ZipArchive' not found ===<br />
<br />
Ensure the zip extension is enabled.<br />
{{hc|$ grep zip /etc/php/php.ini|2=<br />
extension=zip.so}}<br />
<br />
=== /etc/php/php.ini not parsed ===<br />
<br />
If your {{ic|php.ini}} is not parsed, the ini file is named after the sapi it is using. For instance, if you are using uwsgi, the file would be called {{ic|/etc/php/php-uwsgi.ini}}. If you are using cli, it is {{ic|/etc/php/php-cli.ini}}.<br />
<br />
=== PHP Warning: PHP Startup: ''<module>'': Unable to initialize module ===<br />
<br />
When running {{ic|php}}, this error indicates that the aforementioned module is out of date. This will rarely happen in Arch Linux, since maintainers make sure core PHP and all modules be only available in compatible versions.<br />
<br />
This might happen in conjunction with a module compiled from the [[AUR]]. You usually could confirm this by looking at the dates of the files {{ic|/usr/lib/php/modules/}}.<br />
<br />
To fix, find a compatible update for your module, probably by looking up the [[AUR]] using its common name.<br />
<br />
If it applies, flag the outdated [[AUR]] package as ''outdated''.<br />
<br />
== See also ==<br />
<br />
* [http://www.php.net/ PHP Official Website]</div>无极https://wiki.archlinux.org/index.php?title=Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416309Pacman (简体中文)2016-01-20T14:00:49Z<p>无极: /* 安装软件包 */</p>
<hr />
<div>{{DISPLAYTITLE:pacman}}<br />
[[Category:Package management (简体中文)]]<br />
[[ar:Pacman]]<br />
[[cs:Pacman]]<br />
[[da:Pacman]]<br />
[[de:Pacman]]<br />
[[el:Pacman]]<br />
[[en:Pacman]]<br />
[[es:Pacman]]<br />
[[fa:Pacman]]<br />
[[fr:Pacman]]<br />
[[id:Pacman]]<br />
[[it:Pacman]]<br />
[[ja:Pacman]]<br />
[[ko:Pacman]]<br />
[[nl:Pacman]]<br />
[[pl:Pacman]]<br />
[[pt:Pacman]]<br />
[[ro:Pacman]]<br />
[[ru:Pacman]]<br />
[[sr:Pacman]]<br />
[[sv:Pacman]]<br />
[[tr:pacman]]<br />
[[uk:Pacman]]<br />
[[zh-tw:Pacman]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Creating packages (简体中文)}}<br />
{{Related|Downgrading packages}}<br />
{{Related|pacman/Package signing}}<br />
{{Related|pacman/Pacnew and Pacsave}}<br />
{{Related|pacman/Rosetta}}<br />
{{Related|pacman/Tips and tricks}}<br />
{{Related|FAQ#Package Management}}<br />
{{Related|System maintenance (简体中文)}}<br />
{{Related|Arch Build System (简体中文)}}<br />
{{Related|Official repositories (简体中文)}}<br />
{{Related|Arch User Repository (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|pacman|2015-01-02|413745}}<br />
[https://archlinux.org/pacman/ pacman][[Wikipedia:Package management system|软件包管理器]]是 Arch Linux 的一大亮点。它将一个简单的二进制包格式和易用的构建系统结合了起来(参见[[makepkg]]和[[ABS]])。不管软件包是来自官方的 Arch 库还是用户自己创建,''pacman'' 都能方便得管理。<br />
<br />
''pacman'' 通过和主服务器同步软件包列表来进行系统更新,这使得注重安全的系统管理员的维护工作成为轻而易举的事情。这种服务器/客户端模式可以使用一条命令就下载/安装软件包,同时安装必需的依赖包。<br />
<br />
''pacman'' 用 C 语言编写,使用 {{ic|.pkg.tar.xz}} 打包格式。<br />
<br />
{{小贴士|{{Pkg|pacman}} 软件包还提供了其它有用工具,例如'''makepkg'''、'''pactree'''、'''vercomp'''、 [[checkupdates]]等。可以通过 {{Ic|pacman -Ql pacman <nowiki>|</nowiki> grep bin}} 获取工具列表。}}<br />
<br />
==用法==<br />
<br />
下面只是一个可执行操作的小部分示范,''pacman'' 的其他示例请阅读[https://www.archlinux.org/pacman/pacman.8.html man pacman]。<br />
<br />
{{Tip|使用过其它发行版的用户,可以参考 [[Pacman Rosetta]] 中的对比.}}<br />
<br />
===安装软件包===<br />
<br />
{{注意|软件包通常有很多[[PKGBUILD#optdepends|可选依赖]], 它们为软件提供额外功能, 并不强制要求安装它们。 安装软件时, ''pacman'' 将会输出它的可选依赖, 但是这个输出不会在 {{ic|pacman.log}}中;当你想浏览已安装软件的可选依赖时可以[[#查询软件数据库]] ,同时得到关于可选依赖的简短描述。}}<br />
<br />
{{警告|1=未[[#升级软件包|更新]]系统前,'''不要'''在安装软件包时更新软件包数据库({{ic|pacman -Sy ''package_name''}}),否则会有依赖问题。参见[[#不支持部分升级]]和 https://bbs.archlinux.org/viewtopic.php?id=89328.}}<br />
<br />
====安装指定的包====<br />
安装或者升级单个软件包,或者一列软件包(包含依赖包),使用如下命令:<br />
<br />
# pacman -S package_name1 package_name2 ...<br />
<br />
用正则表达式安装多个软件包(参见 [[pacman tips (简体中文)#巧用 Bash 语法|pacman 小贴士]]和[https://bbs.archlinux.org/viewtopic.php?id=7179 这个帖子]):<br />
<br />
# pacman -S $(pacman -Ssq package_regex)<br />
<br />
有时候在不同的软件仓库中,一个软件包有多个版本(比如[extra]和[testing])。可以选择一个来安装:<br />
<br />
# pacman -S extra/package_name<br />
<br />
====安装包组====<br />
<br />
一些包属于一个可以同时安装的[[Creating_packages#Meta_packages_and_groups|软件包组]]。例如,运行下面的命令<br />
<br />
# pacman -S gnome<br />
<br />
会提醒用户选择 {{ic|gnome}} 内需要安装的包。<br />
<br />
有的包组包含大量的软件包,有时用户只需其中几个。除了逐一键入序号外,pacman 还支持选择或排除某个区间内的的软件包:<br />
<br />
Enter a selection (default=all): 1-10 15<br />
<br />
这将选中序号 1 至 10 和 15 的软件包。而<br />
<br />
Enter a selection (default=all): ^5-8 ^2<br />
<br />
将会选中除了序号 5 至 8 和 2 之外的所有软件包。<br />
<br />
想要查看哪些包属于 gnome 组,运行:<br />
<br />
# pacman -Sg gnome<br />
<br />
也可以访问 https://www.archlinux.org/groups/ 查看可用的包组。<br />
<br />
{{注意|如果列表中的包已经安装在系统中,它会被重新安装,即使它已经是最新的。可以用 {{ic|--needed}} 选项覆盖这种行为。}}<br />
<br />
===删除软件包===<br />
<br />
删除单个软件包,保留其全部已经安装的依赖关系<br />
<br />
pacman -R package_name<br />
<br />
删除指定软件包,及其所有没有被其他已安装软件包使用的依赖关系:<br />
<br />
pacman -Rs package_name<br />
<br />
要删除软件包和所有依赖这个软件包的程序:<br />
<br />
# pacman -Rsc package_name<br />
<br />
{{警告|此操作是递归的,请小心检查,可能会一次删除大量的软件包。}}<br />
<br />
要删除软件包,但是不删除依赖这个软件包的其他程序:<br />
<br />
# pacman -Rdd package_name<br />
<br />
''pacman'' 删除某些程序时会备份重要配置文件,在其后面加上*.pacsave扩展名。-n 选项可以删除这些文件:<br />
<br />
pacman -Rn package_name<br />
pacman -Rsn package_name<br />
<br />
{{注意|''pacman'' 不会删除软件自己创建的文件(例如主目录中的 {{ic|.dot}} 文件不会被删除。}}<br />
<br />
=== 升级软件包 ===<br />
<br />
建议所有用户都 [[System_maintenance#Upgrading the system|经常性的更新系统]],系统长时间不更新更容易出问题。在论坛提问题的时候,一般假定您的系统已经升级到最新状态。Arch 只支持系统完整升级,[[System maintenance#Partial upgrades are unsupported|不支持部分升级]]。<br />
<br />
建议升级前访问 [https://www.archlinux.org/ Arch Linux 主页]查看最新消息(或订阅 [https://www.archlinux.org/feeds/news/ RSS],或订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-announce/ arch-announce 邮件列表],或关注 [https://twitter.com/archlinux @archlinux]。如果升级需要不寻常的用户介入(无法简单地按照 ''pacman'' 的输出信息处理),总会给出合适的方法。有时候系统更新需要进行一些手动调整,请不要在重要任务前进行系统更新。<br />
<br />
一个 ''pacman'' 命令就可以升级整个系统。花费的时间取决于系统有多老。这个命令会同步非本地(local)软件仓库并升级系统的软件包:<br />
<br />
# pacman -Syu<br />
<br />
''pacman'' 是强大的软件包管理工具,但是不会做所有的事情。遵循[[Arch Linux (简体中文)|Arch 之道]],用户需要负责维护自己的系统。'''执行系统升级时,请务必阅读 ''pacman'' 输出的所有信息。'''如果用户修改过的配置文件需要更新,新的配置文件会被保存为 {{ic|.pacnew}} 文件以免覆盖了用户的配置。''pacman'' 会提醒用户合并新旧文件。这些文件需要手动干预。在升级或删除软件包后,应该立即着手处理。参见 [[Pacnew and Pacsave files (简体中文)|Pacnew 和 pacsave 文件]]。<br />
<br />
{{小贴士| ''pacman'' 输出会记录到 {{ic|/var/log/pacman.log}}。}}<br />
<br />
如果遇到问题,无法按照给出方法解决。请搜索下论坛,很有可能已经有人遇到并解决了。<br />
<br />
===查询包数据库===<br />
<br />
''pacman'' 使用 -Q 参数查询本地软件包数据库。参见:<br />
$ pacman -Q --help<br />
<br />
使用 -S 参数来查询远程同步的数据库。参见:<br />
$ pacman -S --help<br />
<br />
''pacman'' 可以在包数据库中查询软件包,查询位置包含了软件包的名字和描述:<br />
<br />
$ pacman -Ss ''string1'' ''string2'' ...<br />
<br />
要查询已安装的软件包:<br />
<br />
$ pacman -Qs ''string1'' ''string2'' ...<br />
<br />
显示软件包的详尽的信息:<br />
<br />
$ pacman -Si ''package_name''<br />
<br />
查询本地安装包的详细信息:<br />
<br />
$ pacman -Qi ''package_name''<br />
<br />
使用两个 {{ic|-i}} 将同时显示备份文件和修改状态:<br />
<br />
$ pacman -Qii ''package_name''<br />
<br />
要获取已安装软件包所包含文件的列表:<br />
<br />
$ pacman -Ql ''package_name''<br />
<br />
未安装的软件包使用 [[pkgfile (简体中文)|pkgfile]]。<br />
<br />
检查软件包安装的文件是否都存在:<br />
<br />
$ pacman -Qk ''package_name''<br />
<br />
查询数据库获取某个文件属于哪个软件包:<br />
<br />
$ pacman -Qo ''/path/to/file_name''<br />
<br />
要罗列所有不再作为依赖的软件包(孤立orphans):<br />
<br />
$ pacman -Qdt<br />
<br />
要罗列所有明确安装而且不被其它包依赖的软件包:<br />
<br />
$ pacman -Qet<br />
<br />
要显示软件包的依赖树:<br />
<br />
$ pactree ''package_name''<br />
<br />
检查一个''安装''的软件包被那些包依赖,可以使用 {{ic|-r}}:<br />
<br />
$ pactree -r ''package_name''<br />
<br />
=== 数据库结构 ===<br />
<br />
pacman数据库通常位于 {{ic|/var/lib/pacman/sync}}. 对于每一个在{{ic|/etc/pacman.conf}}中指定的软件仓库, 这里都有一个一致的数据库。数据库文件夹里每个tar.gz文件都包含着一个仓库的软件包信息。例如{{Pkg|which}} 包:<br />
<br />
{{bc|<br />
% tree which-2.20-6 <br />
which-2.20-6<nowiki><br />
|-- depends<br />
`-- desc</nowiki><br />
}}<br />
<br />
这个 {{ic|depends}} 项列出了该软件的依赖包, 而{{ic|desc}}有该包的介绍,例如文件大小和MD5值 。<br />
<br />
=== 清理软件包缓存 ===<br />
<br />
''pacman'' 将下载的软件包保存在 {{ic|/var/cache/pacman/pkg/}} 并且不会自动移除旧的和未安装版本的软件包,因此需要手动清理,以免该文件夹过于庞大。<br />
<br />
使用内建选项即可清除未安装软件包的缓存:<br />
<br />
# pacman -Sc<br />
<br />
{{警告|<br />
* 仅在确定当前安装的软件包足够稳定且不需要[[Downgrading packages (简体中文)|降级]]时才执行清理。旧版本的软件包被清理后,如果需要,只能从其他地方如 [[Arch Linux Archive (简体中文)]]获取了。<br />
* {{ic|pacman -Scc}} 可以清理所有缓存,但这样 pacman 在重装软件包时就只能重新下载了。除非空间不足,否则不应这么做。<br />
}}<br />
<br />
由于以上种种局限,建议使用专门的脚本去处理清理哪些、清理多少缓存:<br />
<br />
{{Pkg|pacman}} 提供的 ''paccache'' 命令默认会删除近3个版本前的软件包<br />
<br />
# paccache -r<br />
<br />
但是此命令不会检查某一个包是否安装了,因此会遗留未安装的包。再运行下面命令可解决此问题。<br />
<br />
# paccache -ruk0<br />
<br />
更多功能参见{{ic|paccache -h}}。<br />
<br />
''paccache'',还可以使用 [[Arch User Repository (简体中文)|Arch User Repository]] 中的 {{AUR|pkgcacheclean}}:{{bc|# pkgcacheclean}}<br />
<br />
===其它命令===<br />
<br />
升级系统时安装其他软件包:<br />
<br />
# pacman -Syu ''package_name1'' ''package_name2'' ...<br />
<br />
下载包而不安装它:<br />
# pacman -Sw package_name<br />
<br />
安装一个'''本地'''包(不从源里下载):<br />
# pacman -U /path/to/package/package_name-version.pkg.tar.xz<br />
<br />
要将本地包保存至缓存,可执行:<br />
# pacman -U file://path/to/package/package_name-version.pkg.tar.xz<br />
<br />
安装一个'''远程'''包(不在 ''pacman'' 配置的源里面):<br />
# pacman -U <nowiki>http://www.example.com/repo/example.pkg.tar.xz</nowiki><br />
<br />
要禁用 {{ic|-S}}, {{ic|-U}} 和 {{ic|-R}} 动作,可以使用 {{ic|-p}} 选项.<br />
<br />
''pacman'' 会列出需要安装和删除的软件,并在执行动作前要求需要的权限。<br />
<br />
==配置==<br />
''pacman'' 的配置文件位于{{ic|/etc/pacman.conf}}。 [https://www.archlinux.org/pacman/pacman.conf.5.html man pacman.conf] 可以查看配置文件的进一步信息。<br />
<br />
===通用选项===<br />
<br />
通用选项都在{{Ic|[options]}}段。阅读 man 手册或者查看默认的 pacman.conf 可以获得有关信息和用法。<br />
<br />
==== 彩色输出 ====<br />
Pacman 具有颜色选项,取消 "Color" 行的注释即可.<br />
<br />
====不升级软件包====<br />
<br />
如果由于某种原因,用户不希望升级某个软件包,可以加入内容如下:<br />
IgnorePkg = 软件包名<br />
<br />
多软件包可以用空格隔开,也可是用 glob 模式。如果只打算忽略一次升级,可以使用 {{ic|--ignore}} 选项。<br />
<br />
忽略了的软件包可通过 {{ic|pacman -S}} 升级。<br />
<br />
====不升级软件包组====<br />
<br />
和软件包一样,也可以不升级某个软件包组:<br />
IgnoreGroup = gnome<br />
<br />
==== 跳过软件包文件 ====<br />
要跳过某些文件夹的安装,可以将它们放到 {{Ic|NoExtract}} 中,例如不想安装 [[systemd]] unit 文件:<br />
<br />
NoExtract=usr/lib/systemd/system/*<br />
<br />
通过下面命令可以产生类似 {{AUR|localepurge}} 的效果:<br />
<br />
NoExtract = usr/share/help/* !usr/share/help/en*<br />
NoExtract = usr/share/locale/* !usr/share/locale/en*<br />
NoExtract = usr/share/man/* !usr/share/man/man*<br />
NoExtract = usr/share/vim/vim74/lang/*<br />
<br />
后面的规则覆盖前面的规则,加上 {{ic|!}} 可以取消跳过效果,这样可以只安装需要语言的本地化文件。<br />
<br />
===软件仓库===<br />
这部分定义使用的软件仓库,在 {{ic|/etc/pacman.conf}} 中引用,可以直接设置或者从其它文件包含。<br />
<br />
所有官方软件仓库都使用同一个包含了'{{ic|$repo}}' 的 {{ic|/etc/pacman.d/mirrorlist}}文件,因此只需要维护一个列表。<br />
下面例子中使用[[official repositories|官方软件仓库]],用 mirrorlist 设定[[mirrors|镜像]]的一个范例。<br />
<br />
{{bc|<nowiki><br />
#[testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[core]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
[extra]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
#[community-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[community]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
# 如果打算在 x86_64 系统上运行32位软件,启用 multilib 软件仓库。<br />
<br />
#[multilib-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
#[multilib]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
# 自定义软件仓库实例,如何创建软件仓库参见 pacman man手册页。<br />
#[custom]<br />
#SigLevel = Optional TrustAll<br />
#Server = file:///home/custompkgs<br />
</nowiki>}}<br />
<br />
{{警告|使用 {{ic|[testing]}} 仓库的时候要谨慎,这个仓库里面开发比较活跃,可能导致某些软件包不能工作。推荐使用 {{ic|[testing]}} 的用户订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-dev-public arch-dev-public 邮件列表]以获得最新信息。}}<br />
<br />
=== 软件包的安全性 ===<br />
<br />
''pacman'' 4 支持软件包签名。语句 {{ic|1=SigLevel = Required DatabaseOptional}} 将启用全局签名验证,但会被每个软件仓库的 {{ic|SigLevel}} 行所覆盖。详情参见 [[pacman-key (简体中文)|pacman-key]].<br />
<br />
=== 一般注意事项 ===<br />
{{警告|小心使用 {{ic|--force}} 开关。使用不当会造成大问题。 请''只''在 Arch 新闻里要求这么做的时候才用。}}<br />
<br />
''pacman'' 附带了许多实用工具能让系统使用更加便捷。所有工具功能都能通过 {{ic|--help}} 开关查看。运行:<br />
$ pacman -Ql pacman | awk -F"[/ ]" '/\/usr\/bin/ {print $5}'<br />
查看完整列表<br />
<br />
== 问题解决 ==<br />
<br />
=== 升级时遇到问题: "file exists in filesystem"(conflicting files)! ===<br />
<br />
如果碰到[https://bbs.archlinux.org/viewtopic.php?id=56373 这个帖子]的错误:<br />
<br />
error: could not prepare transaction<br />
error: failed to commit transaction (conflicting files)<br />
package: /path/to/file exists in filesystem<br />
Errors occurred, no packages were upgraded.<br />
<br />
发生了什么事: ''pacman'' 检测到文件冲突,而且按照设计,''pacman'' 不会覆盖文件。这是设计功能,不是缺陷。<br />
<br />
先用 ({{Ic|pacman -Qo 文件的完整路径}} 检查哪个软件包提供了文件。如果是其它软件包,请[[Reporting bug guidelines|报告问题]]。如果不是其它软件包提供,将已经存在的文件重命名并重新升级。如果一切顺利,可以删掉备份文件。<br />
<br />
如果是通过 {{Ic|make install}} 等非 pacman 方式安装的软件,安装的文件不属于任何软件包!需要先手动删除这些文件,这样就可以正常安装软件了。[[pacman tips#Identify_files_not_owned_by_any_package|不属于任何软件包的文件列表]]一文中提供了查找这些文件的脚本。<br />
<br />
每一个安装的软件包都会提供一个 {{ic|/var/lib/pacman/local/''$package-$version''/files}} 文件,包含此软件包的元数据。如果文件损坏或者丢失,将会导致升级时出现{{ic|file exists in filesystem}} 错误。此错误通常只会影响一个软件包,除了手动删除或移动所有的问题文件,可以作为特例使用{{ic|pacman -S --force $package}}让 ''pacman'' 强制覆盖这些文件。<br />
<br />
{{警告|{{ic|--force}} 选项非常危险,建议在 Arch 新闻中明确通知的时候才使用它,否则可能导致系统无法启动。}}<br />
<br />
=== "failed to commit transaction (invalid or corrupted package" 错误 ===<br />
<br />
看看{{Ic|/var/cache/pacman/pkg}}中是否有{{Ic|*.part}}结尾的文件,它们是没有完全下载的文件,删除它们并重新执行更新。这些程序一般是自定义的{{Ic|XferCommand}} 下载命令造成的。<br />
<br />
# find /var/cache/pacman/pkg/ -iname "*.part" -exec rm {} \;<br />
<br />
=== "error: failed to init transaction (unable to lock database)" 错误 ===<br />
<br />
''pacman'' 在更新软件包数据库前,比如安装软件包时会创建一个文件锁 {{ic|/var/lib/pacman/db.lck}}。该文件会阻止其他 ''pacman'' 实例在同一时间修改软件包数据库。如果 ''pacman'' 在更新数据库时收到干扰,旧锁会一直存在。如果确认 ''pacman'' 没有在运行,那么删掉文件锁:<br />
<br />
# rm /var/lib/pacman/db.lck<br />
<br />
=== 安装时无法获取软件包 ===<br />
<br />
错误内容包含:{{ic|Not found in sync db}}, {{ic|Target not found}} 或 {{ic|Failed retrieving file}}.<br />
<br />
首先确认软件包确实存在(并注意错别字)。如果确认软件包存在,可能本地数据库过时了或者软件仓库没有配置好,试试 {{ic|pacman -Syyu}} 强制数据库更新和升级。<br />
<br />
也有可能包含该软件包的软件仓库没有启动。例如,该软件包可能在 ''multilib'' 仓库里,但该仓库没有在 ''pacman.conf'' 中启用。<br />
<br />
参阅[[FAQ#Why is there only a single version of each shared library in the official repositories?]].<br />
<br />
=== pacman 重复升级同一个包 ===<br />
{{注意|''pacman'' 版本 3.4 在遇到重复条目时会显示错误,因此这个问题过时了。}}<br />
<br />
这是因为在 {{ic|/var/lib/pacman/local/}} 有重复的条目,例如有两个 {{ic|linux}} 条目。{{ic|pacman -Qi}} 输出正确的版本,但是 {{ic|pacman -Qu}} 识别了旧版本,因此尝试升级。<br />
<br />
解决方法:删除 {{ic|/var/lib/pacman/local/}} 中多余的条目。<br />
<br />
=== 我需要有一个指定文件的包。我怎么知道谁提供了这个文件? ===<br />
<br />
安装 [[pkgfile]],它使用一个单独的数据库保存所有文件的软件包归属。<br />
<br />
=== pacman 完全坏掉,如何修复? ===<br />
<br />
如果 ''pacman'' 完全坏掉不能使用,需要手动下载或构建需要的软件包({{Pkg|openssl}}, {{Pkg|libarchive}}, {{Pkg|libfetch}}{{Broken package link|package not found}}, 和 {{Pkg|pacman}}) 并解压到根目录。''pacman'' 会和默认配置文件一起恢复。之后,用 ''pacman'' 重新安装这些软件包以保证数据库的完整性。<br />
<br />
=== pacman 更新时崩溃! ===<br />
<br />
如果 ''pacman'' 在删除、重新安装或更新软件包时 "数据库写入" 出错:<br />
# 从 Arch 安装媒体启动,最好用最新的安装媒体<br />
# 挂载根文件系统,通过 {{ic|df -h}} 确认根文件目录包含足够的空间<br />
# 如果系统使用默认的数据库目录位置,可以通过root用户执行下面命令{{ic|1=pacman --root=/mnt --cachedir=/mnt/var/cache/pacman/pkg -Syyu}}<br />
# 更新之后,可以通过下面命令确认是否还存在损坏的包:{{ic|find /mnt/usr/lib -size 0}} <br />
# 通过下面命令重新安装依然损坏的软件包:{{ic|1=pacman --root /mnt --cachedir=/mnt/var/cache/pacman/pkg -S ''package''}}.<br />
<br />
=== pacman crashes the official installation media ===<br />
<br />
The official installation media (ISO) before version 10.2015 are not setup to be updated itself at runtime. Running {{ic|pacman -Syu}} from a booted install media console may crash unexpectedly any time, as soon as memory is depleted. This happens because the install media image build reports an arbitrary capacity (of 32GB) to pacman, regardless of available free memory.[https://bugs.archlinux.org/task/45618#comment137346] At the same time the ISO reserves only a low static memory allotment for operations ({{ic|/run/archiso/cowspace}} of {{ic|256MB}} RAM) of the live system, in order to allow installation on machines with low resources. If the machine has more RAM available, you can override the allotment by setting the {{ic|1=cow_spacesize=}} kernel option for the ISO manually, e.g. {{ic|1=cow_spacesize=2GB}}. <br />
<br />
If you use the install media to update an installed system, you simply have to use the {{ic|1=--root=}} option along with a {{ic|1=--cachedir=}} path to point pacman to available real storage. For example, see [[#pacman crashes during an upgrade]]. <br />
<br />
If you ''require'' an install media with persistent dataspace, the [[Archiso]] build script can be used to create one along with its [https://projects.archlinux.org/archiso.git/tree/docs/README.bootparams boot options].<br />
<br />
=== 升级系统重启后,出现"unable to find root device"错误,无法登陆 ===<br />
<br />
很有可能 initramfs 在内核升级时损坏,例如错误的使用 ''pacman'' 的 {{ic|--force}} 选项。有两个选择:<br />
<br />
==== Fallback 启动项 ====<br />
<br />
{{Tip|如果删除了此启动项,可以在启动时进入启动加载器的手动模式,将 initramfs 修改为 {{ic|initramfs-linux-fallback.img}} 继续启动。}}<br />
<br />
如果系统可以启动,运行如下命令可以生产原始内核 {{Pkg|linux}} 的 initramfs:<br />
<br />
{{bc|# mkinitcpio -p linux}}<br />
<br />
==== Chroot 修复 ====<br />
如果上面方法不行,请下载 2012 年之后发布的安装程序进行启动,执行:<br />
<br />
{{bc|<nowiki><br />
# mount /dev/sdxY /mnt #Your root partition.<br />
# mount /dev/sdxZ /mnt/boot #If you use a separate /boot partition.<br />
# arch-chroot /mnt<br />
# pacman -Syu mkinitcpio systemd-tools linux</nowiki>}}<br />
<br />
重新安装内核({{Pkg|linux}} 软件包)将会自动运行 {{ic|mkinitcpio -p linux}} 重新生成 initramfs 镜像,不需要单独生成。<br />
<br />
之后建议执行 {{ic|exit}}, {{ic|umount /mnt/{boot,} }} 然后 {{ic|reboot}}.<br />
<br />
{{Note|如果无法进入 arch-chroot 或 chroot 环境,但是需要重新安装软件包,可以使用 pacman -r /mnt -Syu foo bar }}<br />
<br />
=== Signature from "User <email@gmail.com>" is unknown trust, installation failed ===<br />
<br />
查看[[pacman-key#Resetting all the keys]]. 或试试:<br />
* 更新已知密钥:{{ic|pacman-key --refresh-keys}};<br />
* 手动升级{{ic|archlinux-keyring}}软件包:{{ic|pacman -S archlinux-keyring}}.<br />
<br />
=== Request on importing PGP keys ===<br />
<br />
If [[Installation guide|installing]] Arch with an outdated ISO, you are likely prompted to import PGP keys. Agree to download the key to proceed. If you are unable to add the PGP key successfully, update the keyring or upgrade {{Pkg|archlinux-keyring}} (see [[#Signature from "User <email@gmail.com>" is unknown trust, installation failed|above]]).<br />
<br />
=== 不停看到错误 "PackageName: signature from "User <email@archlinux.org>" is invalid" ===<br />
<br />
When the system time is faulty, signing keys are considered expired (or invalid) and signature checks on packages will fail with the following error:<br />
<br />
error: PackageName: signature from "User <email@archlinux.org>" is invalid<br />
error: failed to commit transaction (invalid or corrupted package (PGP signature))<br />
Errors occured, no packages were upgraded. <br />
<br />
Make sure to correct the [[time]], for example with {{ic|ntpd -qg}} run as root, and run {{ic|hwclock -w}} as root before subsequent installations or upgrades.<br />
<br />
=== 'warning: current locale is invalid; using default "C" locale' 错误 ===<br />
<br />
错误信息已经很明确了,locale 设置不正确,请阅读[[Locale]]进行设置。<br />
<br />
=== pacman不使用我的代理设置 ===<br />
<br />
正确设置环境变量({{ic|$http_proxy}}, {{ic|$ftp_proxy}} etc.)如果使用[[sudo]],需要让 sudo [[sudo#Environment variables (Outdated?)|将这些变量传递给 pacman]].<br />
<br />
=== 如何重装所有包并保留安装和依赖信息? ===<br />
重装所有软件包:{{ic|pacman -S $(pacman -Qnq)}}({{ic|-S}} 选项会保留安装缘由)。<br />
<br />
接着需要重装外来包(不在官方仓库里的软件包)。外来包可通过{{ic|pacman -Qmq}}查看。<br />
<br />
=== "Cannot open shared object file" error ===<br />
<br />
It looks like previous ''pacman'' transaction removed or corrupted shared libraries needed for pacman itself.<br />
<br />
To recover from this situation you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the ''pacman'' cache ({{ic|/var/cache/pacman/pkg/}}). Unpack required shared library to the filesystem. This will allow to run ''pacman''.<br />
<br />
Now you need to [[#Installing specific packages|reinstall]] the broken package. Note that you need to use {{ic|--force}} flag as you just unpacked system files and ''pacman'' does not know about it. ''pacman'' will correctly replace our shared library file with one from package.<br />
<br />
That's it. Update the rest of the system.<br />
<br />
=== Freeze of package downloads ===<br />
<br />
Some issues have been reported regarding network problems that prevent ''pacman'' from updating/synchronizing repositories. [https://bbs.archlinux.org/viewtopic.php?id&#61;68944] [https://bbs.archlinux.org/viewtopic.php?id&#61;65728] When installing Arch Linux natively, these issues have been resolved by replacing the default ''pacman'' file downloader with an alternative (see [[Improve pacman performance]] for more details). When installing Arch Linux as a guest OS in [[VirtualBox]], this issue has also been addressed by using ''Host interface'' instead of ''NAT'' in the machine properties.<br />
<br />
=== Failed retrieving file 'core.db' from mirror ===<br />
<br />
If you receive this error message with correct [[mirrors]], try setting a different [[Resolv.conf|name server]].<br />
<br />
== 参见 ==<br />
* [https://www.archlinux.org/pacman/libalpm.3.html libalpm(3) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.8.html pacman(8) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.conf.5.html pacman.conf(5) Manual Page]<br />
* [https://www.archlinux.org/pacman/repo-add.8.html repo-add(8) Manual Page]</div>无极https://wiki.archlinux.org/index.php?title=Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416308Pacman (简体中文)2016-01-20T13:59:29Z<p>无极: /* 安装软件包 */</p>
<hr />
<div>{{DISPLAYTITLE:pacman}}<br />
[[Category:Package management (简体中文)]]<br />
[[ar:Pacman]]<br />
[[cs:Pacman]]<br />
[[da:Pacman]]<br />
[[de:Pacman]]<br />
[[el:Pacman]]<br />
[[en:Pacman]]<br />
[[es:Pacman]]<br />
[[fa:Pacman]]<br />
[[fr:Pacman]]<br />
[[id:Pacman]]<br />
[[it:Pacman]]<br />
[[ja:Pacman]]<br />
[[ko:Pacman]]<br />
[[nl:Pacman]]<br />
[[pl:Pacman]]<br />
[[pt:Pacman]]<br />
[[ro:Pacman]]<br />
[[ru:Pacman]]<br />
[[sr:Pacman]]<br />
[[sv:Pacman]]<br />
[[tr:pacman]]<br />
[[uk:Pacman]]<br />
[[zh-tw:Pacman]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Creating packages (简体中文)}}<br />
{{Related|Downgrading packages}}<br />
{{Related|pacman/Package signing}}<br />
{{Related|pacman/Pacnew and Pacsave}}<br />
{{Related|pacman/Rosetta}}<br />
{{Related|pacman/Tips and tricks}}<br />
{{Related|FAQ#Package Management}}<br />
{{Related|System maintenance (简体中文)}}<br />
{{Related|Arch Build System (简体中文)}}<br />
{{Related|Official repositories (简体中文)}}<br />
{{Related|Arch User Repository (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|pacman|2015-01-02|413745}}<br />
[https://archlinux.org/pacman/ pacman][[Wikipedia:Package management system|软件包管理器]]是 Arch Linux 的一大亮点。它将一个简单的二进制包格式和易用的构建系统结合了起来(参见[[makepkg]]和[[ABS]])。不管软件包是来自官方的 Arch 库还是用户自己创建,''pacman'' 都能方便得管理。<br />
<br />
''pacman'' 通过和主服务器同步软件包列表来进行系统更新,这使得注重安全的系统管理员的维护工作成为轻而易举的事情。这种服务器/客户端模式可以使用一条命令就下载/安装软件包,同时安装必需的依赖包。<br />
<br />
''pacman'' 用 C 语言编写,使用 {{ic|.pkg.tar.xz}} 打包格式。<br />
<br />
{{小贴士|{{Pkg|pacman}} 软件包还提供了其它有用工具,例如'''makepkg'''、'''pactree'''、'''vercomp'''、 [[checkupdates]]等。可以通过 {{Ic|pacman -Ql pacman <nowiki>|</nowiki> grep bin}} 获取工具列表。}}<br />
<br />
==用法==<br />
<br />
下面只是一个可执行操作的小部分示范,''pacman'' 的其他示例请阅读[https://www.archlinux.org/pacman/pacman.8.html man pacman]。<br />
<br />
{{Tip|使用过其它发行版的用户,可以参考 [[Pacman Rosetta]] 中的对比.}}<br />
<br />
===安装软件包===<br />
<br />
{{注意|软件包通常有很多[[PKGBUILD#optdepends|可选依赖]], 它们为软件提供额外功能, 并不强制要求安装它们。 安装软件时, ''pacman'' 将会输出它的可选依赖, 但是这个输出不会在 {{ic|pacman.log}}中: r当你想浏览已安装软件的可选依赖时可以[[#查询软件数据库]] ,同时得到关于可选依赖的简短描述。}}<br />
<br />
{{警告|1=未[[#升级软件包|更新]]系统前,'''不要'''在安装软件包时更新软件包数据库({{ic|pacman -Sy ''package_name''}}),否则会有依赖问题。参见[[#不支持部分升级]]和 https://bbs.archlinux.org/viewtopic.php?id=89328.}}<br />
<br />
====安装指定的包====<br />
安装或者升级单个软件包,或者一列软件包(包含依赖包),使用如下命令:<br />
<br />
# pacman -S package_name1 package_name2 ...<br />
<br />
用正则表达式安装多个软件包(参见 [[pacman tips (简体中文)#巧用 Bash 语法|pacman 小贴士]]和[https://bbs.archlinux.org/viewtopic.php?id=7179 这个帖子]):<br />
<br />
# pacman -S $(pacman -Ssq package_regex)<br />
<br />
有时候在不同的软件仓库中,一个软件包有多个版本(比如[extra]和[testing])。可以选择一个来安装:<br />
<br />
# pacman -S extra/package_name<br />
<br />
====安装包组====<br />
<br />
一些包属于一个可以同时安装的[[Creating_packages#Meta_packages_and_groups|软件包组]]。例如,运行下面的命令<br />
<br />
# pacman -S gnome<br />
<br />
会提醒用户选择 {{ic|gnome}} 内需要安装的包。<br />
<br />
有的包组包含大量的软件包,有时用户只需其中几个。除了逐一键入序号外,pacman 还支持选择或排除某个区间内的的软件包:<br />
<br />
Enter a selection (default=all): 1-10 15<br />
<br />
这将选中序号 1 至 10 和 15 的软件包。而<br />
<br />
Enter a selection (default=all): ^5-8 ^2<br />
<br />
将会选中除了序号 5 至 8 和 2 之外的所有软件包。<br />
<br />
想要查看哪些包属于 gnome 组,运行:<br />
<br />
# pacman -Sg gnome<br />
<br />
也可以访问 https://www.archlinux.org/groups/ 查看可用的包组。<br />
<br />
{{注意|如果列表中的包已经安装在系统中,它会被重新安装,即使它已经是最新的。可以用 {{ic|--needed}} 选项覆盖这种行为。}}<br />
<br />
===删除软件包===<br />
<br />
删除单个软件包,保留其全部已经安装的依赖关系<br />
<br />
pacman -R package_name<br />
<br />
删除指定软件包,及其所有没有被其他已安装软件包使用的依赖关系:<br />
<br />
pacman -Rs package_name<br />
<br />
要删除软件包和所有依赖这个软件包的程序:<br />
<br />
# pacman -Rsc package_name<br />
<br />
{{警告|此操作是递归的,请小心检查,可能会一次删除大量的软件包。}}<br />
<br />
要删除软件包,但是不删除依赖这个软件包的其他程序:<br />
<br />
# pacman -Rdd package_name<br />
<br />
''pacman'' 删除某些程序时会备份重要配置文件,在其后面加上*.pacsave扩展名。-n 选项可以删除这些文件:<br />
<br />
pacman -Rn package_name<br />
pacman -Rsn package_name<br />
<br />
{{注意|''pacman'' 不会删除软件自己创建的文件(例如主目录中的 {{ic|.dot}} 文件不会被删除。}}<br />
<br />
=== 升级软件包 ===<br />
<br />
建议所有用户都 [[System_maintenance#Upgrading the system|经常性的更新系统]],系统长时间不更新更容易出问题。在论坛提问题的时候,一般假定您的系统已经升级到最新状态。Arch 只支持系统完整升级,[[System maintenance#Partial upgrades are unsupported|不支持部分升级]]。<br />
<br />
建议升级前访问 [https://www.archlinux.org/ Arch Linux 主页]查看最新消息(或订阅 [https://www.archlinux.org/feeds/news/ RSS],或订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-announce/ arch-announce 邮件列表],或关注 [https://twitter.com/archlinux @archlinux]。如果升级需要不寻常的用户介入(无法简单地按照 ''pacman'' 的输出信息处理),总会给出合适的方法。有时候系统更新需要进行一些手动调整,请不要在重要任务前进行系统更新。<br />
<br />
一个 ''pacman'' 命令就可以升级整个系统。花费的时间取决于系统有多老。这个命令会同步非本地(local)软件仓库并升级系统的软件包:<br />
<br />
# pacman -Syu<br />
<br />
''pacman'' 是强大的软件包管理工具,但是不会做所有的事情。遵循[[Arch Linux (简体中文)|Arch 之道]],用户需要负责维护自己的系统。'''执行系统升级时,请务必阅读 ''pacman'' 输出的所有信息。'''如果用户修改过的配置文件需要更新,新的配置文件会被保存为 {{ic|.pacnew}} 文件以免覆盖了用户的配置。''pacman'' 会提醒用户合并新旧文件。这些文件需要手动干预。在升级或删除软件包后,应该立即着手处理。参见 [[Pacnew and Pacsave files (简体中文)|Pacnew 和 pacsave 文件]]。<br />
<br />
{{小贴士| ''pacman'' 输出会记录到 {{ic|/var/log/pacman.log}}。}}<br />
<br />
如果遇到问题,无法按照给出方法解决。请搜索下论坛,很有可能已经有人遇到并解决了。<br />
<br />
===查询包数据库===<br />
<br />
''pacman'' 使用 -Q 参数查询本地软件包数据库。参见:<br />
$ pacman -Q --help<br />
<br />
使用 -S 参数来查询远程同步的数据库。参见:<br />
$ pacman -S --help<br />
<br />
''pacman'' 可以在包数据库中查询软件包,查询位置包含了软件包的名字和描述:<br />
<br />
$ pacman -Ss ''string1'' ''string2'' ...<br />
<br />
要查询已安装的软件包:<br />
<br />
$ pacman -Qs ''string1'' ''string2'' ...<br />
<br />
显示软件包的详尽的信息:<br />
<br />
$ pacman -Si ''package_name''<br />
<br />
查询本地安装包的详细信息:<br />
<br />
$ pacman -Qi ''package_name''<br />
<br />
使用两个 {{ic|-i}} 将同时显示备份文件和修改状态:<br />
<br />
$ pacman -Qii ''package_name''<br />
<br />
要获取已安装软件包所包含文件的列表:<br />
<br />
$ pacman -Ql ''package_name''<br />
<br />
未安装的软件包使用 [[pkgfile (简体中文)|pkgfile]]。<br />
<br />
检查软件包安装的文件是否都存在:<br />
<br />
$ pacman -Qk ''package_name''<br />
<br />
查询数据库获取某个文件属于哪个软件包:<br />
<br />
$ pacman -Qo ''/path/to/file_name''<br />
<br />
要罗列所有不再作为依赖的软件包(孤立orphans):<br />
<br />
$ pacman -Qdt<br />
<br />
要罗列所有明确安装而且不被其它包依赖的软件包:<br />
<br />
$ pacman -Qet<br />
<br />
要显示软件包的依赖树:<br />
<br />
$ pactree ''package_name''<br />
<br />
检查一个''安装''的软件包被那些包依赖,可以使用 {{ic|-r}}:<br />
<br />
$ pactree -r ''package_name''<br />
<br />
=== 数据库结构 ===<br />
<br />
pacman数据库通常位于 {{ic|/var/lib/pacman/sync}}. 对于每一个在{{ic|/etc/pacman.conf}}中指定的软件仓库, 这里都有一个一致的数据库。数据库文件夹里每个tar.gz文件都包含着一个仓库的软件包信息。例如{{Pkg|which}} 包:<br />
<br />
{{bc|<br />
% tree which-2.20-6 <br />
which-2.20-6<nowiki><br />
|-- depends<br />
`-- desc</nowiki><br />
}}<br />
<br />
这个 {{ic|depends}} 项列出了该软件的依赖包, 而{{ic|desc}}有该包的介绍,例如文件大小和MD5值 。<br />
<br />
=== 清理软件包缓存 ===<br />
<br />
''pacman'' 将下载的软件包保存在 {{ic|/var/cache/pacman/pkg/}} 并且不会自动移除旧的和未安装版本的软件包,因此需要手动清理,以免该文件夹过于庞大。<br />
<br />
使用内建选项即可清除未安装软件包的缓存:<br />
<br />
# pacman -Sc<br />
<br />
{{警告|<br />
* 仅在确定当前安装的软件包足够稳定且不需要[[Downgrading packages (简体中文)|降级]]时才执行清理。旧版本的软件包被清理后,如果需要,只能从其他地方如 [[Arch Linux Archive (简体中文)]]获取了。<br />
* {{ic|pacman -Scc}} 可以清理所有缓存,但这样 pacman 在重装软件包时就只能重新下载了。除非空间不足,否则不应这么做。<br />
}}<br />
<br />
由于以上种种局限,建议使用专门的脚本去处理清理哪些、清理多少缓存:<br />
<br />
{{Pkg|pacman}} 提供的 ''paccache'' 命令默认会删除近3个版本前的软件包<br />
<br />
# paccache -r<br />
<br />
但是此命令不会检查某一个包是否安装了,因此会遗留未安装的包。再运行下面命令可解决此问题。<br />
<br />
# paccache -ruk0<br />
<br />
更多功能参见{{ic|paccache -h}}。<br />
<br />
''paccache'',还可以使用 [[Arch User Repository (简体中文)|Arch User Repository]] 中的 {{AUR|pkgcacheclean}}:{{bc|# pkgcacheclean}}<br />
<br />
===其它命令===<br />
<br />
升级系统时安装其他软件包:<br />
<br />
# pacman -Syu ''package_name1'' ''package_name2'' ...<br />
<br />
下载包而不安装它:<br />
# pacman -Sw package_name<br />
<br />
安装一个'''本地'''包(不从源里下载):<br />
# pacman -U /path/to/package/package_name-version.pkg.tar.xz<br />
<br />
要将本地包保存至缓存,可执行:<br />
# pacman -U file://path/to/package/package_name-version.pkg.tar.xz<br />
<br />
安装一个'''远程'''包(不在 ''pacman'' 配置的源里面):<br />
# pacman -U <nowiki>http://www.example.com/repo/example.pkg.tar.xz</nowiki><br />
<br />
要禁用 {{ic|-S}}, {{ic|-U}} 和 {{ic|-R}} 动作,可以使用 {{ic|-p}} 选项.<br />
<br />
''pacman'' 会列出需要安装和删除的软件,并在执行动作前要求需要的权限。<br />
<br />
==配置==<br />
''pacman'' 的配置文件位于{{ic|/etc/pacman.conf}}。 [https://www.archlinux.org/pacman/pacman.conf.5.html man pacman.conf] 可以查看配置文件的进一步信息。<br />
<br />
===通用选项===<br />
<br />
通用选项都在{{Ic|[options]}}段。阅读 man 手册或者查看默认的 pacman.conf 可以获得有关信息和用法。<br />
<br />
==== 彩色输出 ====<br />
Pacman 具有颜色选项,取消 "Color" 行的注释即可.<br />
<br />
====不升级软件包====<br />
<br />
如果由于某种原因,用户不希望升级某个软件包,可以加入内容如下:<br />
IgnorePkg = 软件包名<br />
<br />
多软件包可以用空格隔开,也可是用 glob 模式。如果只打算忽略一次升级,可以使用 {{ic|--ignore}} 选项。<br />
<br />
忽略了的软件包可通过 {{ic|pacman -S}} 升级。<br />
<br />
====不升级软件包组====<br />
<br />
和软件包一样,也可以不升级某个软件包组:<br />
IgnoreGroup = gnome<br />
<br />
==== 跳过软件包文件 ====<br />
要跳过某些文件夹的安装,可以将它们放到 {{Ic|NoExtract}} 中,例如不想安装 [[systemd]] unit 文件:<br />
<br />
NoExtract=usr/lib/systemd/system/*<br />
<br />
通过下面命令可以产生类似 {{AUR|localepurge}} 的效果:<br />
<br />
NoExtract = usr/share/help/* !usr/share/help/en*<br />
NoExtract = usr/share/locale/* !usr/share/locale/en*<br />
NoExtract = usr/share/man/* !usr/share/man/man*<br />
NoExtract = usr/share/vim/vim74/lang/*<br />
<br />
后面的规则覆盖前面的规则,加上 {{ic|!}} 可以取消跳过效果,这样可以只安装需要语言的本地化文件。<br />
<br />
===软件仓库===<br />
这部分定义使用的软件仓库,在 {{ic|/etc/pacman.conf}} 中引用,可以直接设置或者从其它文件包含。<br />
<br />
所有官方软件仓库都使用同一个包含了'{{ic|$repo}}' 的 {{ic|/etc/pacman.d/mirrorlist}}文件,因此只需要维护一个列表。<br />
下面例子中使用[[official repositories|官方软件仓库]],用 mirrorlist 设定[[mirrors|镜像]]的一个范例。<br />
<br />
{{bc|<nowiki><br />
#[testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[core]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
[extra]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
#[community-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[community]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
# 如果打算在 x86_64 系统上运行32位软件,启用 multilib 软件仓库。<br />
<br />
#[multilib-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
#[multilib]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
# 自定义软件仓库实例,如何创建软件仓库参见 pacman man手册页。<br />
#[custom]<br />
#SigLevel = Optional TrustAll<br />
#Server = file:///home/custompkgs<br />
</nowiki>}}<br />
<br />
{{警告|使用 {{ic|[testing]}} 仓库的时候要谨慎,这个仓库里面开发比较活跃,可能导致某些软件包不能工作。推荐使用 {{ic|[testing]}} 的用户订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-dev-public arch-dev-public 邮件列表]以获得最新信息。}}<br />
<br />
=== 软件包的安全性 ===<br />
<br />
''pacman'' 4 支持软件包签名。语句 {{ic|1=SigLevel = Required DatabaseOptional}} 将启用全局签名验证,但会被每个软件仓库的 {{ic|SigLevel}} 行所覆盖。详情参见 [[pacman-key (简体中文)|pacman-key]].<br />
<br />
=== 一般注意事项 ===<br />
{{警告|小心使用 {{ic|--force}} 开关。使用不当会造成大问题。 请''只''在 Arch 新闻里要求这么做的时候才用。}}<br />
<br />
''pacman'' 附带了许多实用工具能让系统使用更加便捷。所有工具功能都能通过 {{ic|--help}} 开关查看。运行:<br />
$ pacman -Ql pacman | awk -F"[/ ]" '/\/usr\/bin/ {print $5}'<br />
查看完整列表<br />
<br />
== 问题解决 ==<br />
<br />
=== 升级时遇到问题: "file exists in filesystem"(conflicting files)! ===<br />
<br />
如果碰到[https://bbs.archlinux.org/viewtopic.php?id=56373 这个帖子]的错误:<br />
<br />
error: could not prepare transaction<br />
error: failed to commit transaction (conflicting files)<br />
package: /path/to/file exists in filesystem<br />
Errors occurred, no packages were upgraded.<br />
<br />
发生了什么事: ''pacman'' 检测到文件冲突,而且按照设计,''pacman'' 不会覆盖文件。这是设计功能,不是缺陷。<br />
<br />
先用 ({{Ic|pacman -Qo 文件的完整路径}} 检查哪个软件包提供了文件。如果是其它软件包,请[[Reporting bug guidelines|报告问题]]。如果不是其它软件包提供,将已经存在的文件重命名并重新升级。如果一切顺利,可以删掉备份文件。<br />
<br />
如果是通过 {{Ic|make install}} 等非 pacman 方式安装的软件,安装的文件不属于任何软件包!需要先手动删除这些文件,这样就可以正常安装软件了。[[pacman tips#Identify_files_not_owned_by_any_package|不属于任何软件包的文件列表]]一文中提供了查找这些文件的脚本。<br />
<br />
每一个安装的软件包都会提供一个 {{ic|/var/lib/pacman/local/''$package-$version''/files}} 文件,包含此软件包的元数据。如果文件损坏或者丢失,将会导致升级时出现{{ic|file exists in filesystem}} 错误。此错误通常只会影响一个软件包,除了手动删除或移动所有的问题文件,可以作为特例使用{{ic|pacman -S --force $package}}让 ''pacman'' 强制覆盖这些文件。<br />
<br />
{{警告|{{ic|--force}} 选项非常危险,建议在 Arch 新闻中明确通知的时候才使用它,否则可能导致系统无法启动。}}<br />
<br />
=== "failed to commit transaction (invalid or corrupted package" 错误 ===<br />
<br />
看看{{Ic|/var/cache/pacman/pkg}}中是否有{{Ic|*.part}}结尾的文件,它们是没有完全下载的文件,删除它们并重新执行更新。这些程序一般是自定义的{{Ic|XferCommand}} 下载命令造成的。<br />
<br />
# find /var/cache/pacman/pkg/ -iname "*.part" -exec rm {} \;<br />
<br />
=== "error: failed to init transaction (unable to lock database)" 错误 ===<br />
<br />
''pacman'' 在更新软件包数据库前,比如安装软件包时会创建一个文件锁 {{ic|/var/lib/pacman/db.lck}}。该文件会阻止其他 ''pacman'' 实例在同一时间修改软件包数据库。如果 ''pacman'' 在更新数据库时收到干扰,旧锁会一直存在。如果确认 ''pacman'' 没有在运行,那么删掉文件锁:<br />
<br />
# rm /var/lib/pacman/db.lck<br />
<br />
=== 安装时无法获取软件包 ===<br />
<br />
错误内容包含:{{ic|Not found in sync db}}, {{ic|Target not found}} 或 {{ic|Failed retrieving file}}.<br />
<br />
首先确认软件包确实存在(并注意错别字)。如果确认软件包存在,可能本地数据库过时了或者软件仓库没有配置好,试试 {{ic|pacman -Syyu}} 强制数据库更新和升级。<br />
<br />
也有可能包含该软件包的软件仓库没有启动。例如,该软件包可能在 ''multilib'' 仓库里,但该仓库没有在 ''pacman.conf'' 中启用。<br />
<br />
参阅[[FAQ#Why is there only a single version of each shared library in the official repositories?]].<br />
<br />
=== pacman 重复升级同一个包 ===<br />
{{注意|''pacman'' 版本 3.4 在遇到重复条目时会显示错误,因此这个问题过时了。}}<br />
<br />
这是因为在 {{ic|/var/lib/pacman/local/}} 有重复的条目,例如有两个 {{ic|linux}} 条目。{{ic|pacman -Qi}} 输出正确的版本,但是 {{ic|pacman -Qu}} 识别了旧版本,因此尝试升级。<br />
<br />
解决方法:删除 {{ic|/var/lib/pacman/local/}} 中多余的条目。<br />
<br />
=== 我需要有一个指定文件的包。我怎么知道谁提供了这个文件? ===<br />
<br />
安装 [[pkgfile]],它使用一个单独的数据库保存所有文件的软件包归属。<br />
<br />
=== pacman 完全坏掉,如何修复? ===<br />
<br />
如果 ''pacman'' 完全坏掉不能使用,需要手动下载或构建需要的软件包({{Pkg|openssl}}, {{Pkg|libarchive}}, {{Pkg|libfetch}}{{Broken package link|package not found}}, 和 {{Pkg|pacman}}) 并解压到根目录。''pacman'' 会和默认配置文件一起恢复。之后,用 ''pacman'' 重新安装这些软件包以保证数据库的完整性。<br />
<br />
=== pacman 更新时崩溃! ===<br />
<br />
如果 ''pacman'' 在删除、重新安装或更新软件包时 "数据库写入" 出错:<br />
# 从 Arch 安装媒体启动,最好用最新的安装媒体<br />
# 挂载根文件系统,通过 {{ic|df -h}} 确认根文件目录包含足够的空间<br />
# 如果系统使用默认的数据库目录位置,可以通过root用户执行下面命令{{ic|1=pacman --root=/mnt --cachedir=/mnt/var/cache/pacman/pkg -Syyu}}<br />
# 更新之后,可以通过下面命令确认是否还存在损坏的包:{{ic|find /mnt/usr/lib -size 0}} <br />
# 通过下面命令重新安装依然损坏的软件包:{{ic|1=pacman --root /mnt --cachedir=/mnt/var/cache/pacman/pkg -S ''package''}}.<br />
<br />
=== pacman crashes the official installation media ===<br />
<br />
The official installation media (ISO) before version 10.2015 are not setup to be updated itself at runtime. Running {{ic|pacman -Syu}} from a booted install media console may crash unexpectedly any time, as soon as memory is depleted. This happens because the install media image build reports an arbitrary capacity (of 32GB) to pacman, regardless of available free memory.[https://bugs.archlinux.org/task/45618#comment137346] At the same time the ISO reserves only a low static memory allotment for operations ({{ic|/run/archiso/cowspace}} of {{ic|256MB}} RAM) of the live system, in order to allow installation on machines with low resources. If the machine has more RAM available, you can override the allotment by setting the {{ic|1=cow_spacesize=}} kernel option for the ISO manually, e.g. {{ic|1=cow_spacesize=2GB}}. <br />
<br />
If you use the install media to update an installed system, you simply have to use the {{ic|1=--root=}} option along with a {{ic|1=--cachedir=}} path to point pacman to available real storage. For example, see [[#pacman crashes during an upgrade]]. <br />
<br />
If you ''require'' an install media with persistent dataspace, the [[Archiso]] build script can be used to create one along with its [https://projects.archlinux.org/archiso.git/tree/docs/README.bootparams boot options].<br />
<br />
=== 升级系统重启后,出现"unable to find root device"错误,无法登陆 ===<br />
<br />
很有可能 initramfs 在内核升级时损坏,例如错误的使用 ''pacman'' 的 {{ic|--force}} 选项。有两个选择:<br />
<br />
==== Fallback 启动项 ====<br />
<br />
{{Tip|如果删除了此启动项,可以在启动时进入启动加载器的手动模式,将 initramfs 修改为 {{ic|initramfs-linux-fallback.img}} 继续启动。}}<br />
<br />
如果系统可以启动,运行如下命令可以生产原始内核 {{Pkg|linux}} 的 initramfs:<br />
<br />
{{bc|# mkinitcpio -p linux}}<br />
<br />
==== Chroot 修复 ====<br />
如果上面方法不行,请下载 2012 年之后发布的安装程序进行启动,执行:<br />
<br />
{{bc|<nowiki><br />
# mount /dev/sdxY /mnt #Your root partition.<br />
# mount /dev/sdxZ /mnt/boot #If you use a separate /boot partition.<br />
# arch-chroot /mnt<br />
# pacman -Syu mkinitcpio systemd-tools linux</nowiki>}}<br />
<br />
重新安装内核({{Pkg|linux}} 软件包)将会自动运行 {{ic|mkinitcpio -p linux}} 重新生成 initramfs 镜像,不需要单独生成。<br />
<br />
之后建议执行 {{ic|exit}}, {{ic|umount /mnt/{boot,} }} 然后 {{ic|reboot}}.<br />
<br />
{{Note|如果无法进入 arch-chroot 或 chroot 环境,但是需要重新安装软件包,可以使用 pacman -r /mnt -Syu foo bar }}<br />
<br />
=== Signature from "User <email@gmail.com>" is unknown trust, installation failed ===<br />
<br />
查看[[pacman-key#Resetting all the keys]]. 或试试:<br />
* 更新已知密钥:{{ic|pacman-key --refresh-keys}};<br />
* 手动升级{{ic|archlinux-keyring}}软件包:{{ic|pacman -S archlinux-keyring}}.<br />
<br />
=== Request on importing PGP keys ===<br />
<br />
If [[Installation guide|installing]] Arch with an outdated ISO, you are likely prompted to import PGP keys. Agree to download the key to proceed. If you are unable to add the PGP key successfully, update the keyring or upgrade {{Pkg|archlinux-keyring}} (see [[#Signature from "User <email@gmail.com>" is unknown trust, installation failed|above]]).<br />
<br />
=== 不停看到错误 "PackageName: signature from "User <email@archlinux.org>" is invalid" ===<br />
<br />
When the system time is faulty, signing keys are considered expired (or invalid) and signature checks on packages will fail with the following error:<br />
<br />
error: PackageName: signature from "User <email@archlinux.org>" is invalid<br />
error: failed to commit transaction (invalid or corrupted package (PGP signature))<br />
Errors occured, no packages were upgraded. <br />
<br />
Make sure to correct the [[time]], for example with {{ic|ntpd -qg}} run as root, and run {{ic|hwclock -w}} as root before subsequent installations or upgrades.<br />
<br />
=== 'warning: current locale is invalid; using default "C" locale' 错误 ===<br />
<br />
错误信息已经很明确了,locale 设置不正确,请阅读[[Locale]]进行设置。<br />
<br />
=== pacman不使用我的代理设置 ===<br />
<br />
正确设置环境变量({{ic|$http_proxy}}, {{ic|$ftp_proxy}} etc.)如果使用[[sudo]],需要让 sudo [[sudo#Environment variables (Outdated?)|将这些变量传递给 pacman]].<br />
<br />
=== 如何重装所有包并保留安装和依赖信息? ===<br />
重装所有软件包:{{ic|pacman -S $(pacman -Qnq)}}({{ic|-S}} 选项会保留安装缘由)。<br />
<br />
接着需要重装外来包(不在官方仓库里的软件包)。外来包可通过{{ic|pacman -Qmq}}查看。<br />
<br />
=== "Cannot open shared object file" error ===<br />
<br />
It looks like previous ''pacman'' transaction removed or corrupted shared libraries needed for pacman itself.<br />
<br />
To recover from this situation you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the ''pacman'' cache ({{ic|/var/cache/pacman/pkg/}}). Unpack required shared library to the filesystem. This will allow to run ''pacman''.<br />
<br />
Now you need to [[#Installing specific packages|reinstall]] the broken package. Note that you need to use {{ic|--force}} flag as you just unpacked system files and ''pacman'' does not know about it. ''pacman'' will correctly replace our shared library file with one from package.<br />
<br />
That's it. Update the rest of the system.<br />
<br />
=== Freeze of package downloads ===<br />
<br />
Some issues have been reported regarding network problems that prevent ''pacman'' from updating/synchronizing repositories. [https://bbs.archlinux.org/viewtopic.php?id&#61;68944] [https://bbs.archlinux.org/viewtopic.php?id&#61;65728] When installing Arch Linux natively, these issues have been resolved by replacing the default ''pacman'' file downloader with an alternative (see [[Improve pacman performance]] for more details). When installing Arch Linux as a guest OS in [[VirtualBox]], this issue has also been addressed by using ''Host interface'' instead of ''NAT'' in the machine properties.<br />
<br />
=== Failed retrieving file 'core.db' from mirror ===<br />
<br />
If you receive this error message with correct [[mirrors]], try setting a different [[Resolv.conf|name server]].<br />
<br />
== 参见 ==<br />
* [https://www.archlinux.org/pacman/libalpm.3.html libalpm(3) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.8.html pacman(8) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.conf.5.html pacman.conf(5) Manual Page]<br />
* [https://www.archlinux.org/pacman/repo-add.8.html repo-add(8) Manual Page]</div>无极https://wiki.archlinux.org/index.php?title=Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416306Pacman (简体中文)2016-01-20T13:47:19Z<p>无极: /* 数据库结构 */</p>
<hr />
<div>{{DISPLAYTITLE:pacman}}<br />
[[Category:Package management (简体中文)]]<br />
[[ar:Pacman]]<br />
[[cs:Pacman]]<br />
[[da:Pacman]]<br />
[[de:Pacman]]<br />
[[el:Pacman]]<br />
[[en:Pacman]]<br />
[[es:Pacman]]<br />
[[fa:Pacman]]<br />
[[fr:Pacman]]<br />
[[id:Pacman]]<br />
[[it:Pacman]]<br />
[[ja:Pacman]]<br />
[[ko:Pacman]]<br />
[[nl:Pacman]]<br />
[[pl:Pacman]]<br />
[[pt:Pacman]]<br />
[[ro:Pacman]]<br />
[[ru:Pacman]]<br />
[[sr:Pacman]]<br />
[[sv:Pacman]]<br />
[[tr:pacman]]<br />
[[uk:Pacman]]<br />
[[zh-tw:Pacman]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Creating packages (简体中文)}}<br />
{{Related|Downgrading packages}}<br />
{{Related|pacman/Package signing}}<br />
{{Related|pacman/Pacnew and Pacsave}}<br />
{{Related|pacman/Rosetta}}<br />
{{Related|pacman/Tips and tricks}}<br />
{{Related|FAQ#Package Management}}<br />
{{Related|System maintenance (简体中文)}}<br />
{{Related|Arch Build System (简体中文)}}<br />
{{Related|Official repositories (简体中文)}}<br />
{{Related|Arch User Repository (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|pacman|2015-01-02|413745}}<br />
[https://archlinux.org/pacman/ pacman][[Wikipedia:Package management system|软件包管理器]]是 Arch Linux 的一大亮点。它将一个简单的二进制包格式和易用的构建系统结合了起来(参见[[makepkg]]和[[ABS]])。不管软件包是来自官方的 Arch 库还是用户自己创建,''pacman'' 都能方便得管理。<br />
<br />
''pacman'' 通过和主服务器同步软件包列表来进行系统更新,这使得注重安全的系统管理员的维护工作成为轻而易举的事情。这种服务器/客户端模式可以使用一条命令就下载/安装软件包,同时安装必需的依赖包。<br />
<br />
''pacman'' 用 C 语言编写,使用 {{ic|.pkg.tar.xz}} 打包格式。<br />
<br />
{{小贴士|{{Pkg|pacman}} 软件包还提供了其它有用工具,例如'''makepkg'''、'''pactree'''、'''vercomp'''、 [[checkupdates]]等。可以通过 {{Ic|pacman -Ql pacman <nowiki>|</nowiki> grep bin}} 获取工具列表。}}<br />
<br />
==用法==<br />
<br />
下面只是一个可执行操作的小部分示范,''pacman'' 的其他示例请阅读[https://www.archlinux.org/pacman/pacman.8.html man pacman]。<br />
<br />
{{Tip|使用过其它发行版的用户,可以参考 [[Pacman Rosetta]] 中的对比.}}<br />
<br />
===安装软件包===<br />
<br />
{{Note|Packages often have a series of [[PKGBUILD#optdepends|optional dependencies]] which are packages that provide additional functionality to the application, albeit not strictly required for running it. When installing a package, ''pacman'' will list its optional dependencies among the output messages, but they will not be found in {{ic|pacman.log}}: refer to [[#Querying package databases]] when you want to view the optional dependencies of an already installed package, together with short descriptions of their functionality.}}<br />
<br />
{{Warning|1=未[[#升级软件包|更新]]系统前,'''不要'''在安装软件包时更新软件包数据库({{ic|pacman -Sy ''package_name''}}),否则会有依赖问题。参见[[#不支持部分升级]]和 https://bbs.archlinux.org/viewtopic.php?id=89328.}}<br />
<br />
====安装指定的包====<br />
安装或者升级单个软件包,或者一列软件包(包含依赖包),使用如下命令:<br />
<br />
# pacman -S package_name1 package_name2 ...<br />
<br />
用正则表达式安装多个软件包(参见 [[pacman tips (简体中文)#巧用 Bash 语法|pacman 小贴士]]和[https://bbs.archlinux.org/viewtopic.php?id=7179 这个帖子]):<br />
<br />
# pacman -S $(pacman -Ssq package_regex)<br />
<br />
有时候在不同的软件仓库中,一个软件包有多个版本(比如[extra]和[testing])。可以选择一个来安装:<br />
<br />
# pacman -S extra/package_name<br />
<br />
====安装包组====<br />
<br />
一些包属于一个可以同时安装的[[Creating_packages#Meta_packages_and_groups|软件包组]]。例如,运行下面的命令<br />
<br />
# pacman -S gnome<br />
<br />
会提醒用户选择 {{ic|gnome}} 内需要安装的包。<br />
<br />
有的包组包含大量的软件包,有时用户只需其中几个。除了逐一键入序号外,pacman 还支持选择或排除某个区间内的的软件包:<br />
<br />
Enter a selection (default=all): 1-10 15<br />
<br />
这将选中序号 1 至 10 和 15 的软件包。而<br />
<br />
Enter a selection (default=all): ^5-8 ^2<br />
<br />
将会选中除了序号 5 至 8 和 2 之外的所有软件包。<br />
<br />
想要查看哪些包属于 gnome 组,运行:<br />
<br />
# pacman -Sg gnome<br />
<br />
也可以访问 https://www.archlinux.org/groups/ 查看可用的包组。<br />
<br />
{{注意|如果列表中的包已经安装在系统中,它会被重新安装,即使它已经是最新的。可以用 {{ic|--needed}} 选项覆盖这种行为。}}<br />
<br />
===删除软件包===<br />
<br />
删除单个软件包,保留其全部已经安装的依赖关系<br />
<br />
pacman -R package_name<br />
<br />
删除指定软件包,及其所有没有被其他已安装软件包使用的依赖关系:<br />
<br />
pacman -Rs package_name<br />
<br />
要删除软件包和所有依赖这个软件包的程序:<br />
<br />
# pacman -Rsc package_name<br />
<br />
{{警告|此操作是递归的,请小心检查,可能会一次删除大量的软件包。}}<br />
<br />
要删除软件包,但是不删除依赖这个软件包的其他程序:<br />
<br />
# pacman -Rdd package_name<br />
<br />
''pacman'' 删除某些程序时会备份重要配置文件,在其后面加上*.pacsave扩展名。-n 选项可以删除这些文件:<br />
<br />
pacman -Rn package_name<br />
pacman -Rsn package_name<br />
<br />
{{注意|''pacman'' 不会删除软件自己创建的文件(例如主目录中的 {{ic|.dot}} 文件不会被删除。}}<br />
<br />
=== 升级软件包 ===<br />
<br />
建议所有用户都 [[System_maintenance#Upgrading the system|经常性的更新系统]],系统长时间不更新更容易出问题。在论坛提问题的时候,一般假定您的系统已经升级到最新状态。Arch 只支持系统完整升级,[[System maintenance#Partial upgrades are unsupported|不支持部分升级]]。<br />
<br />
建议升级前访问 [https://www.archlinux.org/ Arch Linux 主页]查看最新消息(或订阅 [https://www.archlinux.org/feeds/news/ RSS],或订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-announce/ arch-announce 邮件列表],或关注 [https://twitter.com/archlinux @archlinux]。如果升级需要不寻常的用户介入(无法简单地按照 ''pacman'' 的输出信息处理),总会给出合适的方法。有时候系统更新需要进行一些手动调整,请不要在重要任务前进行系统更新。<br />
<br />
一个 ''pacman'' 命令就可以升级整个系统。花费的时间取决于系统有多老。这个命令会同步非本地(local)软件仓库并升级系统的软件包:<br />
<br />
# pacman -Syu<br />
<br />
''pacman'' 是强大的软件包管理工具,但是不会做所有的事情。遵循[[Arch Linux (简体中文)|Arch 之道]],用户需要负责维护自己的系统。'''执行系统升级时,请务必阅读 ''pacman'' 输出的所有信息。'''如果用户修改过的配置文件需要更新,新的配置文件会被保存为 {{ic|.pacnew}} 文件以免覆盖了用户的配置。''pacman'' 会提醒用户合并新旧文件。这些文件需要手动干预。在升级或删除软件包后,应该立即着手处理。参见 [[Pacnew and Pacsave files (简体中文)|Pacnew 和 pacsave 文件]]。<br />
<br />
{{小贴士| ''pacman'' 输出会记录到 {{ic|/var/log/pacman.log}}。}}<br />
<br />
如果遇到问题,无法按照给出方法解决。请搜索下论坛,很有可能已经有人遇到并解决了。<br />
<br />
===查询包数据库===<br />
<br />
''pacman'' 使用 -Q 参数查询本地软件包数据库。参见:<br />
$ pacman -Q --help<br />
<br />
使用 -S 参数来查询远程同步的数据库。参见:<br />
$ pacman -S --help<br />
<br />
''pacman'' 可以在包数据库中查询软件包,查询位置包含了软件包的名字和描述:<br />
<br />
$ pacman -Ss ''string1'' ''string2'' ...<br />
<br />
要查询已安装的软件包:<br />
<br />
$ pacman -Qs ''string1'' ''string2'' ...<br />
<br />
显示软件包的详尽的信息:<br />
<br />
$ pacman -Si ''package_name''<br />
<br />
查询本地安装包的详细信息:<br />
<br />
$ pacman -Qi ''package_name''<br />
<br />
使用两个 {{ic|-i}} 将同时显示备份文件和修改状态:<br />
<br />
$ pacman -Qii ''package_name''<br />
<br />
要获取已安装软件包所包含文件的列表:<br />
<br />
$ pacman -Ql ''package_name''<br />
<br />
未安装的软件包使用 [[pkgfile (简体中文)|pkgfile]]。<br />
<br />
检查软件包安装的文件是否都存在:<br />
<br />
$ pacman -Qk ''package_name''<br />
<br />
查询数据库获取某个文件属于哪个软件包:<br />
<br />
$ pacman -Qo ''/path/to/file_name''<br />
<br />
要罗列所有不再作为依赖的软件包(孤立orphans):<br />
<br />
$ pacman -Qdt<br />
<br />
要罗列所有明确安装而且不被其它包依赖的软件包:<br />
<br />
$ pacman -Qet<br />
<br />
要显示软件包的依赖树:<br />
<br />
$ pactree ''package_name''<br />
<br />
检查一个''安装''的软件包被那些包依赖,可以使用 {{ic|-r}}:<br />
<br />
$ pactree -r ''package_name''<br />
<br />
=== 数据库结构 ===<br />
<br />
pacman数据库通常位于 {{ic|/var/lib/pacman/sync}}. 对于每一个在{{ic|/etc/pacman.conf}}中指定的软件仓库, 这里都有一个一致的数据库。数据库文件夹里每个tar.gz文件都包含着一个仓库的软件包信息。例如{{Pkg|which}} 包:<br />
<br />
{{bc|<br />
% tree which-2.20-6 <br />
which-2.20-6<nowiki><br />
|-- depends<br />
`-- desc</nowiki><br />
}}<br />
<br />
这个 {{ic|depends}} 项列出了该软件的依赖包, 而{{ic|desc}}有该包的介绍,例如文件大小和MD5值 。<br />
<br />
=== 清理软件包缓存 ===<br />
<br />
''pacman'' 将下载的软件包保存在 {{ic|/var/cache/pacman/pkg/}} 并且不会自动移除旧的和未安装版本的软件包,因此需要手动清理,以免该文件夹过于庞大。<br />
<br />
使用内建选项即可清除未安装软件包的缓存:<br />
<br />
# pacman -Sc<br />
<br />
{{警告|<br />
* 仅在确定当前安装的软件包足够稳定且不需要[[Downgrading packages (简体中文)|降级]]时才执行清理。旧版本的软件包被清理后,如果需要,只能从其他地方如 [[Arch Linux Archive (简体中文)]]获取了。<br />
* {{ic|pacman -Scc}} 可以清理所有缓存,但这样 pacman 在重装软件包时就只能重新下载了。除非空间不足,否则不应这么做。<br />
}}<br />
<br />
由于以上种种局限,建议使用专门的脚本去处理清理哪些、清理多少缓存:<br />
<br />
{{Pkg|pacman}} 提供的 ''paccache'' 命令默认会删除近3个版本前的软件包<br />
<br />
# paccache -r<br />
<br />
但是此命令不会检查某一个包是否安装了,因此会遗留未安装的包。再运行下面命令可解决此问题。<br />
<br />
# paccache -ruk0<br />
<br />
更多功能参见{{ic|paccache -h}}。<br />
<br />
''paccache'',还可以使用 [[Arch User Repository (简体中文)|Arch User Repository]] 中的 {{AUR|pkgcacheclean}}:{{bc|# pkgcacheclean}}<br />
<br />
===其它命令===<br />
<br />
升级系统时安装其他软件包:<br />
<br />
# pacman -Syu ''package_name1'' ''package_name2'' ...<br />
<br />
下载包而不安装它:<br />
# pacman -Sw package_name<br />
<br />
安装一个'''本地'''包(不从源里下载):<br />
# pacman -U /path/to/package/package_name-version.pkg.tar.xz<br />
<br />
要将本地包保存至缓存,可执行:<br />
# pacman -U file://path/to/package/package_name-version.pkg.tar.xz<br />
<br />
安装一个'''远程'''包(不在 ''pacman'' 配置的源里面):<br />
# pacman -U <nowiki>http://www.example.com/repo/example.pkg.tar.xz</nowiki><br />
<br />
要禁用 {{ic|-S}}, {{ic|-U}} 和 {{ic|-R}} 动作,可以使用 {{ic|-p}} 选项.<br />
<br />
''pacman'' 会列出需要安装和删除的软件,并在执行动作前要求需要的权限。<br />
<br />
==配置==<br />
''pacman'' 的配置文件位于{{ic|/etc/pacman.conf}}。 [https://www.archlinux.org/pacman/pacman.conf.5.html man pacman.conf] 可以查看配置文件的进一步信息。<br />
<br />
===通用选项===<br />
<br />
通用选项都在{{Ic|[options]}}段。阅读 man 手册或者查看默认的 pacman.conf 可以获得有关信息和用法。<br />
<br />
==== 彩色输出 ====<br />
Pacman 具有颜色选项,取消 "Color" 行的注释即可.<br />
<br />
====不升级软件包====<br />
<br />
如果由于某种原因,用户不希望升级某个软件包,可以加入内容如下:<br />
IgnorePkg = 软件包名<br />
<br />
多软件包可以用空格隔开,也可是用 glob 模式。如果只打算忽略一次升级,可以使用 {{ic|--ignore}} 选项。<br />
<br />
忽略了的软件包可通过 {{ic|pacman -S}} 升级。<br />
<br />
====不升级软件包组====<br />
<br />
和软件包一样,也可以不升级某个软件包组:<br />
IgnoreGroup = gnome<br />
<br />
==== 跳过软件包文件 ====<br />
要跳过某些文件夹的安装,可以将它们放到 {{Ic|NoExtract}} 中,例如不想安装 [[systemd]] unit 文件:<br />
<br />
NoExtract=usr/lib/systemd/system/*<br />
<br />
通过下面命令可以产生类似 {{AUR|localepurge}} 的效果:<br />
<br />
NoExtract = usr/share/help/* !usr/share/help/en*<br />
NoExtract = usr/share/locale/* !usr/share/locale/en*<br />
NoExtract = usr/share/man/* !usr/share/man/man*<br />
NoExtract = usr/share/vim/vim74/lang/*<br />
<br />
后面的规则覆盖前面的规则,加上 {{ic|!}} 可以取消跳过效果,这样可以只安装需要语言的本地化文件。<br />
<br />
===软件仓库===<br />
这部分定义使用的软件仓库,在 {{ic|/etc/pacman.conf}} 中引用,可以直接设置或者从其它文件包含。<br />
<br />
所有官方软件仓库都使用同一个包含了'{{ic|$repo}}' 的 {{ic|/etc/pacman.d/mirrorlist}}文件,因此只需要维护一个列表。<br />
下面例子中使用[[official repositories|官方软件仓库]],用 mirrorlist 设定[[mirrors|镜像]]的一个范例。<br />
<br />
{{bc|<nowiki><br />
#[testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[core]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
[extra]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
#[community-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
[community]<br />
SigLevel = PackageRequired<br />
Include = /etc/pacman.d/mirrorlist<br />
<br />
# 如果打算在 x86_64 系统上运行32位软件,启用 multilib 软件仓库。<br />
<br />
#[multilib-testing]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
#[multilib]<br />
#SigLevel = PackageRequired<br />
#Include = /etc/pacman.d/mirrorlist<br />
<br />
# 自定义软件仓库实例,如何创建软件仓库参见 pacman man手册页。<br />
#[custom]<br />
#SigLevel = Optional TrustAll<br />
#Server = file:///home/custompkgs<br />
</nowiki>}}<br />
<br />
{{警告|使用 {{ic|[testing]}} 仓库的时候要谨慎,这个仓库里面开发比较活跃,可能导致某些软件包不能工作。推荐使用 {{ic|[testing]}} 的用户订阅 [https://mailman.archlinux.org/mailman/listinfo/arch-dev-public arch-dev-public 邮件列表]以获得最新信息。}}<br />
<br />
=== 软件包的安全性 ===<br />
<br />
''pacman'' 4 支持软件包签名。语句 {{ic|1=SigLevel = Required DatabaseOptional}} 将启用全局签名验证,但会被每个软件仓库的 {{ic|SigLevel}} 行所覆盖。详情参见 [[pacman-key (简体中文)|pacman-key]].<br />
<br />
=== 一般注意事项 ===<br />
{{警告|小心使用 {{ic|--force}} 开关。使用不当会造成大问题。 请''只''在 Arch 新闻里要求这么做的时候才用。}}<br />
<br />
''pacman'' 附带了许多实用工具能让系统使用更加便捷。所有工具功能都能通过 {{ic|--help}} 开关查看。运行:<br />
$ pacman -Ql pacman | awk -F"[/ ]" '/\/usr\/bin/ {print $5}'<br />
查看完整列表<br />
<br />
== 问题解决 ==<br />
<br />
=== 升级时遇到问题: "file exists in filesystem"(conflicting files)! ===<br />
<br />
如果碰到[https://bbs.archlinux.org/viewtopic.php?id=56373 这个帖子]的错误:<br />
<br />
error: could not prepare transaction<br />
error: failed to commit transaction (conflicting files)<br />
package: /path/to/file exists in filesystem<br />
Errors occurred, no packages were upgraded.<br />
<br />
发生了什么事: ''pacman'' 检测到文件冲突,而且按照设计,''pacman'' 不会覆盖文件。这是设计功能,不是缺陷。<br />
<br />
先用 ({{Ic|pacman -Qo 文件的完整路径}} 检查哪个软件包提供了文件。如果是其它软件包,请[[Reporting bug guidelines|报告问题]]。如果不是其它软件包提供,将已经存在的文件重命名并重新升级。如果一切顺利,可以删掉备份文件。<br />
<br />
如果是通过 {{Ic|make install}} 等非 pacman 方式安装的软件,安装的文件不属于任何软件包!需要先手动删除这些文件,这样就可以正常安装软件了。[[pacman tips#Identify_files_not_owned_by_any_package|不属于任何软件包的文件列表]]一文中提供了查找这些文件的脚本。<br />
<br />
每一个安装的软件包都会提供一个 {{ic|/var/lib/pacman/local/''$package-$version''/files}} 文件,包含此软件包的元数据。如果文件损坏或者丢失,将会导致升级时出现{{ic|file exists in filesystem}} 错误。此错误通常只会影响一个软件包,除了手动删除或移动所有的问题文件,可以作为特例使用{{ic|pacman -S --force $package}}让 ''pacman'' 强制覆盖这些文件。<br />
<br />
{{警告|{{ic|--force}} 选项非常危险,建议在 Arch 新闻中明确通知的时候才使用它,否则可能导致系统无法启动。}}<br />
<br />
=== "failed to commit transaction (invalid or corrupted package" 错误 ===<br />
<br />
看看{{Ic|/var/cache/pacman/pkg}}中是否有{{Ic|*.part}}结尾的文件,它们是没有完全下载的文件,删除它们并重新执行更新。这些程序一般是自定义的{{Ic|XferCommand}} 下载命令造成的。<br />
<br />
# find /var/cache/pacman/pkg/ -iname "*.part" -exec rm {} \;<br />
<br />
=== "error: failed to init transaction (unable to lock database)" 错误 ===<br />
<br />
''pacman'' 在更新软件包数据库前,比如安装软件包时会创建一个文件锁 {{ic|/var/lib/pacman/db.lck}}。该文件会阻止其他 ''pacman'' 实例在同一时间修改软件包数据库。如果 ''pacman'' 在更新数据库时收到干扰,旧锁会一直存在。如果确认 ''pacman'' 没有在运行,那么删掉文件锁:<br />
<br />
# rm /var/lib/pacman/db.lck<br />
<br />
=== 安装时无法获取软件包 ===<br />
<br />
错误内容包含:{{ic|Not found in sync db}}, {{ic|Target not found}} 或 {{ic|Failed retrieving file}}.<br />
<br />
首先确认软件包确实存在(并注意错别字)。如果确认软件包存在,可能本地数据库过时了或者软件仓库没有配置好,试试 {{ic|pacman -Syyu}} 强制数据库更新和升级。<br />
<br />
也有可能包含该软件包的软件仓库没有启动。例如,该软件包可能在 ''multilib'' 仓库里,但该仓库没有在 ''pacman.conf'' 中启用。<br />
<br />
参阅[[FAQ#Why is there only a single version of each shared library in the official repositories?]].<br />
<br />
=== pacman 重复升级同一个包 ===<br />
{{注意|''pacman'' 版本 3.4 在遇到重复条目时会显示错误,因此这个问题过时了。}}<br />
<br />
这是因为在 {{ic|/var/lib/pacman/local/}} 有重复的条目,例如有两个 {{ic|linux}} 条目。{{ic|pacman -Qi}} 输出正确的版本,但是 {{ic|pacman -Qu}} 识别了旧版本,因此尝试升级。<br />
<br />
解决方法:删除 {{ic|/var/lib/pacman/local/}} 中多余的条目。<br />
<br />
=== 我需要有一个指定文件的包。我怎么知道谁提供了这个文件? ===<br />
<br />
安装 [[pkgfile]],它使用一个单独的数据库保存所有文件的软件包归属。<br />
<br />
=== pacman 完全坏掉,如何修复? ===<br />
<br />
如果 ''pacman'' 完全坏掉不能使用,需要手动下载或构建需要的软件包({{Pkg|openssl}}, {{Pkg|libarchive}}, {{Pkg|libfetch}}{{Broken package link|package not found}}, 和 {{Pkg|pacman}}) 并解压到根目录。''pacman'' 会和默认配置文件一起恢复。之后,用 ''pacman'' 重新安装这些软件包以保证数据库的完整性。<br />
<br />
=== pacman 更新时崩溃! ===<br />
<br />
如果 ''pacman'' 在删除、重新安装或更新软件包时 "数据库写入" 出错:<br />
# 从 Arch 安装媒体启动,最好用最新的安装媒体<br />
# 挂载根文件系统,通过 {{ic|df -h}} 确认根文件目录包含足够的空间<br />
# 如果系统使用默认的数据库目录位置,可以通过root用户执行下面命令{{ic|1=pacman --root=/mnt --cachedir=/mnt/var/cache/pacman/pkg -Syyu}}<br />
# 更新之后,可以通过下面命令确认是否还存在损坏的包:{{ic|find /mnt/usr/lib -size 0}} <br />
# 通过下面命令重新安装依然损坏的软件包:{{ic|1=pacman --root /mnt --cachedir=/mnt/var/cache/pacman/pkg -S ''package''}}.<br />
<br />
=== pacman crashes the official installation media ===<br />
<br />
The official installation media (ISO) before version 10.2015 are not setup to be updated itself at runtime. Running {{ic|pacman -Syu}} from a booted install media console may crash unexpectedly any time, as soon as memory is depleted. This happens because the install media image build reports an arbitrary capacity (of 32GB) to pacman, regardless of available free memory.[https://bugs.archlinux.org/task/45618#comment137346] At the same time the ISO reserves only a low static memory allotment for operations ({{ic|/run/archiso/cowspace}} of {{ic|256MB}} RAM) of the live system, in order to allow installation on machines with low resources. If the machine has more RAM available, you can override the allotment by setting the {{ic|1=cow_spacesize=}} kernel option for the ISO manually, e.g. {{ic|1=cow_spacesize=2GB}}. <br />
<br />
If you use the install media to update an installed system, you simply have to use the {{ic|1=--root=}} option along with a {{ic|1=--cachedir=}} path to point pacman to available real storage. For example, see [[#pacman crashes during an upgrade]]. <br />
<br />
If you ''require'' an install media with persistent dataspace, the [[Archiso]] build script can be used to create one along with its [https://projects.archlinux.org/archiso.git/tree/docs/README.bootparams boot options].<br />
<br />
=== 升级系统重启后,出现"unable to find root device"错误,无法登陆 ===<br />
<br />
很有可能 initramfs 在内核升级时损坏,例如错误的使用 ''pacman'' 的 {{ic|--force}} 选项。有两个选择:<br />
<br />
==== Fallback 启动项 ====<br />
<br />
{{Tip|如果删除了此启动项,可以在启动时进入启动加载器的手动模式,将 initramfs 修改为 {{ic|initramfs-linux-fallback.img}} 继续启动。}}<br />
<br />
如果系统可以启动,运行如下命令可以生产原始内核 {{Pkg|linux}} 的 initramfs:<br />
<br />
{{bc|# mkinitcpio -p linux}}<br />
<br />
==== Chroot 修复 ====<br />
如果上面方法不行,请下载 2012 年之后发布的安装程序进行启动,执行:<br />
<br />
{{bc|<nowiki><br />
# mount /dev/sdxY /mnt #Your root partition.<br />
# mount /dev/sdxZ /mnt/boot #If you use a separate /boot partition.<br />
# arch-chroot /mnt<br />
# pacman -Syu mkinitcpio systemd-tools linux</nowiki>}}<br />
<br />
重新安装内核({{Pkg|linux}} 软件包)将会自动运行 {{ic|mkinitcpio -p linux}} 重新生成 initramfs 镜像,不需要单独生成。<br />
<br />
之后建议执行 {{ic|exit}}, {{ic|umount /mnt/{boot,} }} 然后 {{ic|reboot}}.<br />
<br />
{{Note|如果无法进入 arch-chroot 或 chroot 环境,但是需要重新安装软件包,可以使用 pacman -r /mnt -Syu foo bar }}<br />
<br />
=== Signature from "User <email@gmail.com>" is unknown trust, installation failed ===<br />
<br />
查看[[pacman-key#Resetting all the keys]]. 或试试:<br />
* 更新已知密钥:{{ic|pacman-key --refresh-keys}};<br />
* 手动升级{{ic|archlinux-keyring}}软件包:{{ic|pacman -S archlinux-keyring}}.<br />
<br />
=== Request on importing PGP keys ===<br />
<br />
If [[Installation guide|installing]] Arch with an outdated ISO, you are likely prompted to import PGP keys. Agree to download the key to proceed. If you are unable to add the PGP key successfully, update the keyring or upgrade {{Pkg|archlinux-keyring}} (see [[#Signature from "User <email@gmail.com>" is unknown trust, installation failed|above]]).<br />
<br />
=== 不停看到错误 "PackageName: signature from "User <email@archlinux.org>" is invalid" ===<br />
<br />
When the system time is faulty, signing keys are considered expired (or invalid) and signature checks on packages will fail with the following error:<br />
<br />
error: PackageName: signature from "User <email@archlinux.org>" is invalid<br />
error: failed to commit transaction (invalid or corrupted package (PGP signature))<br />
Errors occured, no packages were upgraded. <br />
<br />
Make sure to correct the [[time]], for example with {{ic|ntpd -qg}} run as root, and run {{ic|hwclock -w}} as root before subsequent installations or upgrades.<br />
<br />
=== 'warning: current locale is invalid; using default "C" locale' 错误 ===<br />
<br />
错误信息已经很明确了,locale 设置不正确,请阅读[[Locale]]进行设置。<br />
<br />
=== pacman不使用我的代理设置 ===<br />
<br />
正确设置环境变量({{ic|$http_proxy}}, {{ic|$ftp_proxy}} etc.)如果使用[[sudo]],需要让 sudo [[sudo#Environment variables (Outdated?)|将这些变量传递给 pacman]].<br />
<br />
=== 如何重装所有包并保留安装和依赖信息? ===<br />
重装所有软件包:{{ic|pacman -S $(pacman -Qnq)}}({{ic|-S}} 选项会保留安装缘由)。<br />
<br />
接着需要重装外来包(不在官方仓库里的软件包)。外来包可通过{{ic|pacman -Qmq}}查看。<br />
<br />
=== "Cannot open shared object file" error ===<br />
<br />
It looks like previous ''pacman'' transaction removed or corrupted shared libraries needed for pacman itself.<br />
<br />
To recover from this situation you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the ''pacman'' cache ({{ic|/var/cache/pacman/pkg/}}). Unpack required shared library to the filesystem. This will allow to run ''pacman''.<br />
<br />
Now you need to [[#Installing specific packages|reinstall]] the broken package. Note that you need to use {{ic|--force}} flag as you just unpacked system files and ''pacman'' does not know about it. ''pacman'' will correctly replace our shared library file with one from package.<br />
<br />
That's it. Update the rest of the system.<br />
<br />
=== Freeze of package downloads ===<br />
<br />
Some issues have been reported regarding network problems that prevent ''pacman'' from updating/synchronizing repositories. [https://bbs.archlinux.org/viewtopic.php?id&#61;68944] [https://bbs.archlinux.org/viewtopic.php?id&#61;65728] When installing Arch Linux natively, these issues have been resolved by replacing the default ''pacman'' file downloader with an alternative (see [[Improve pacman performance]] for more details). When installing Arch Linux as a guest OS in [[VirtualBox]], this issue has also been addressed by using ''Host interface'' instead of ''NAT'' in the machine properties.<br />
<br />
=== Failed retrieving file 'core.db' from mirror ===<br />
<br />
If you receive this error message with correct [[mirrors]], try setting a different [[Resolv.conf|name server]].<br />
<br />
== 参见 ==<br />
* [https://www.archlinux.org/pacman/libalpm.3.html libalpm(3) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.8.html pacman(8) Manual Page]<br />
* [https://www.archlinux.org/pacman/pacman.conf.5.html pacman.conf(5) Manual Page]<br />
* [https://www.archlinux.org/pacman/repo-add.8.html repo-add(8) Manual Page]</div>无极https://wiki.archlinux.org/index.php?title=VirtualBox_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=416302VirtualBox (简体中文)2016-01-20T12:31:25Z<p>无极: /* 加载VirtualBox的内核模块 */</p>
<hr />
<div>[[Category:Emulators (简体中文)]]<br />
[[Category:Virtualization (简体中文)]]<br />
[[cs:VirtualBox]]<br />
[[de:VirtualBox]]<br />
[[el:VirtualBox]]<br />
[[en:VirtualBox]]<br />
[[es:VirtualBox]]<br />
[[fr:VirtualBox]]<br />
[[hu:VirtualBox]]<br />
[[it:VirtualBox]]<br />
[[ja:VirtualBox]]<br />
[[pt:VirtualBox]]<br />
[[ru:VirtualBox]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|:Category:Hypervisors}}<br />
{{Related|VirtualBox Extras}}<br />
{{Related|PhpVirtualBox}}<br />
{{Related|VirtualBox Arch Linux Guest On Physical Drive}}<br />
{{Related|Installing Arch Linux from VirtualBox}}<br />
{{Related|Moving an existing install into (or out of) a virtual machine}}<br />
{{Related articles end}}<br />
{{Translateme (简体中文)}}<br />
{{TranslationStatus (简体中文)|VirtualBox|2015-7-29|389392}}<br />
'''VirtualBox''' 是类似 [[VMware]] 的虚拟 PC 模拟器,处于不断的开发中。使用 [[Qt]] 图形界面,提供了无界面运行和 [[Wikipedia:SDL|SDL]] 命令行工具进行运行管理。它包含'''guest additions'''为一些虚拟系统提供附加功能,包括文件共享、剪贴板和图形加速,支持 “无缝” 窗口整合模式。<br />
<br />
[[Wikipedia:Virtualbox]]<br />
<br />
==在arch linux的安装步骤==<br />
为了启动的VirtualBox虚拟机在您的Arch Linux中,按照下列安装步骤。<br />
<br />
=== 安装基本软件包 ===<br />
<br />
[[pacman (简体中文)|安装]] GPL 版本的 {{Pkg|virtualbox}} 软件包。作为依赖安装的 {{pkg|virtualbox-host-modules}} 包含了archlinux 默认内核使用的模块。<br />
<br />
如果使用{{pkg|linux-lts}}内核,需要安装{{pkg|virtualbox-host-modules-lts}}.<br />
<br />
要使用基于 [[Qt]] 的 {{ic|VirtualBox}} 命令,需要安装 {{Pkg|qt4}} 软件包。如果使用简单的基于 SDL 的 {{ic|VBoxSDL}} 命令或者 {{ic|VBoxHeadless}} 命令,则不需要安装 {{Pkg|qt4}}。<br />
<br />
=== 安装VirtualBox内核模块===<br />
<br />
Next, to fully virtualize your guest installation, VirtualBox provides the following [[kernel modules]]: {{ic|vboxdrv}}, {{ic|vboxnetadp}}, {{ic|vboxnetflt}}, and {{ic|vboxpci}}. These must be added to your host kernel.<br />
<br />
The binary compatibility of kernel modules depends on the API of the kernel against which they have been compiled. The problem with the Linux kernel is that these interfaces might not be the same from one kernel version to another. In order to avoid compatibility problems and subtle bugs, each time the Linux kernel is upgraded, it is advised to recompile the kernel modules against the Linux kernel version that has just been installed. This is what Arch Linux packagers actually do with the VirtualBox kernel modules packages: each time a new Arch Linux kernel is released, the Virtualbox modules are upgraded accordingly.<br />
<br />
Therefore, if you are using a kernel from the [[official repositories]] or a custom one (self-compiled or installed from the [[AUR]]), the kernel module package you will need to install will thus vary.<br />
<br />
==== 运行官方内核的主机 ====<br />
<br />
* 如果你使用的是 {{Pkg|linux}} 内核, 当你安装 {{pkg|virtualbox-host-modules}} 软件包的时候,需要安装{{Pkg|virtualbox}} package.<br />
* 如果你使用的是 LTS 稳定内核 ({{pkg|linux-lts}}), 你需要安装 {{pkg|virtualbox-host-modules-lts}} 软件包。 {{Pkg|virtualbox-host-modules}} 现在可以移除。<br />
* 如果你使用的是 {{aur|linux-ck}} kernel, 需要构建 {{aur|virtualbox-ck-host-modules}} 软件包。<br />
<br />
==== 定制内核的主机====<br />
<br />
{{Merge|Dynamic Kernel Module Support|The general tips on DKMS usage do not belong on this page.}}<br />
<br />
If you use or intend to use a self-compiled kernel from sources, you have to know that VirtualBox does not require any virtualization modules (e.g. virtuo, kvm,...). The VirtualBox kernel modules provide all the necessary for VirtualBox to work properly. You can thus disable in your kernel ''.config'' file these virtualization modules if you do not use other hypervisors like Xen, KVM or QEMU.<br />
<br />
The {{ic|virtualbox-host-modules}} package works fine with custom kernels of the same version of the Arch Linux stock kernel such as {{AUR|linux-ck}}. Since the {{ic|virtualbox-host-modules}} comes with the official Arch Linux kernel ({{Pkg|linux}}) as a dependency and if you do not use that kernel, install {{Pkg|virtualbox-host-dkms}} instead.<br />
<br />
If you are using a custom kernel which is not of the same version of the Arch Linux stock one, you will have to install the {{Pkg|virtualbox-host-dkms}} too. The latter comes bundled with the source of the VirtualBox kernel modules that will be compiled to generate these modules for your kernel.<br />
<br />
As the {{Pkg|virtualbox-host-dkms}} package requires compilation, make sure you have the kernel headers corresponding to your custom kernel version to prevent this error from happening {{ic|Your kernel headers for kernel ''your custom kernel version'' cannot be found at /usr/lib/modules/''your custom kernel version''/build or /usr/lib/modules/''your custom kernel version''/source}}.<br />
* If you use a self-compiled kernel and have used {{ic|make modules_install}} to install its modules, folders {{ic|/usr/lib/modules/''your custom kernel version''/build}} and {{ic|(...)/source}} will be symlinked to your kernel sources. These will act as the kernel headers you need. If you have not removed these kernel sources yet, you have nothing to do.<br />
* If you use a custom kernel from [[AUR]], make sure the package {{Pkg|linux-headers}} is installed.<br />
<br />
一旦{{Pkg|virtualbox-host-dkms}} 安装完成后,只要用下面命令生成内核模块:<br />
# dkms install vboxhost/<virtualbox-host-source 版本> -k <你的自制内核模块版本>/<你的架构><br />
<br />
{{Tip|懒人做法是键入以下命令:<br />
{{bc|<nowiki># dkms install vboxhost/$(pacman -Q virtualbox|awk '{print $2}'|sed 's/\-.\+//') -k $(uname -rm|sed 's/\ /\//')</nowiki>}}<br />
}}<br />
<br />
To automatically recompile the VirtualBox kernel modules when their sources get upgraded (i.e. when the {{Pkg|virtualbox-host-dkms}} package gets upgraded) and avoid to type again the above {{ic|dkms install}} command manually afterwards, enable the {{ic|dkms}} service with:<br />
# systemctl enable dkms.service<br />
<br />
If this service is not enabled while the {{Pkg|virtualbox-host-dkms}} package is being updated, the VirtualBox modules will not be updated and you will have to type in manually the {{ic|dkms install}} command described above to compile the latest version of the Virtualbox kernel modules. If you do not want to type in manually this command, if the {{ic|dkms}} service is automatically loaded at startup, you just need to reboot and your VirtualBox modules will be recompiled silently.<br />
<br />
However, if you want to keep this daemon disabled, you can use an [[mkinitcpio|initramfs hook]] that will automatically trigger the {{ic|dkms install}} command described above at boot time. This will require a reboot to recompile the VirtualBox modules. To enable this hook, install the {{AUR|vboxhost-hook}} package and add {{ic|vboxhost}} to your HOOKS array in {{ic|/etc/mkinitcpio.conf}}. Again, make sure the right linux headers are available for the new kernel otherwise the compilation will fail.<br />
<br />
{{Tip|Like the {{ic|dkms}} command, the {{ic|vboxhost}} hook will tell you if anything goes wrong during the recompilation of the VirtualBox modules.}}<br />
<br />
===加载VirtualBox的内核模块===<br />
<br />
VirtualBox 在 Linux 上运行需要使用自己的[[kernel modules|内核模块]],包括一个必须的 '''vboxdrv'''。这个模块必须在虚拟机运行前启动。如果需要,可以在 Arch Linux 启动时自动加载。<br />
<br />
手动加载模块:<br />
# modprobe vboxdrv<br />
<br />
若要启动时加载 VirtualBox 驱动,在 {{ic|/etc/[[Kernel_modules#Loading|modules-load.d]]}} 创建 {{ic|*.conf}} 文件 (例如:{{ic|virtualbox.conf}}),包括所有应加载的模块:<br />
{{hc|/etc/modules-load.d/virtualbox.conf|<br />
vboxdrv}}<br />
<br />
{{Note|You may need to update the kernel modules db in order to avoid 'no such file or directory' error when loading vboxdrv. Run: {{ic|depmod -a}}.}}<br />
<br />
启动 VirtualBox 图形管理员:<br />
<br />
$VirtualBox<br />
<br />
以下模块是可选的,但建议选上如果您不想在进行一些高级配置时被打扰(如下): {{ic|vboxnetadp}}, {{ic|vboxnetflt}} 和{{ic|vboxpci}}.<br />
<br />
* {{ic|vboxnetadp}} 和{{ic|vboxnetflt}} 都是需要的当你使用网桥时 [https://www.virtualbox.org/manual/ch06.html#network_bridged bridged] or [https://www.virtualbox.org/manual/ch06.html#network_hostonly host-only networking] feature. More precisely, {{ic|vboxnetadp}} is needed to create the host interface in the VirtualBox global preferences, and {{ic|vboxnetflt}} is needed to launch a virtual machine using that network interface.<br />
<br />
* {{ic|vboxpci}}是需要的, 当你的虚拟机需要使用一个你的主机上的pci设备时<br />
<br />
{{Note|If the VirtualBox kernel modules were loaded in the kernel while you updated the modules, you need to reload them manually to use the new updated version. To do it, run {{ic|vboxreload}} as root.}}<br />
<br />
Finally, if you use the aforementioned "Host-only" or "bridge networking" feature, make sure {{pkg|net-tools}} is installed. VirtualBox actually uses {{ic|ifconfig}} and {{ic|route}} to assign the IP and route to the host interface configured with {{ic|VBoxManage hostonlyif}} or via the GUI in ''Settings > Network > Host-only Networks > Edit host-only network (space) > Adapter''.<br />
<br />
=== 添加用户到 vboxusers组 ===<br />
<br />
将需要运行 Virtualbox 的用户名添加到 '''vboxusers''' [[group|用户组]],文件夹共享和其它功能需要正确的组才能工作。新组设置不会应用到当前会话,请重新登录或者通过命令 {{ic|newgrp}} 或 {{ic|sudo -u ''username'' -s}} 启动一个新环境。<br />
# gpasswd -a $USER vboxusers<br />
<br />
=== Guest 附加光盘 ===<br />
<br />
建议在运行VirtualBox 的主机系统上安装{{Pkg|virtualbox-guest-iso}} 软件包 。 这个包是一个磁盘镜像,用来安装虚拟系统的附加功能。 The ''.iso'' file will be located at {{ic|/usr/lib/virtualbox/additions/VBoxGuestAdditions.iso}}, and may have to be mounted manually inside the virtual machine. Once mounted, you can run the guest additions installer inside the guest.<br />
<br />
=== 扩展包 ===<br />
<br />
Since VirtualBox 4.0, non-GPL components have been split from the rest of the application. Despite being released under a non-free license and '''being only available for personal use''', you might be interested in installing the Oracle Extension Pack which provides [https://www.virtualbox.org/manual/ch01.html#intro-installing additional features]. To avoid manual manipulation, the {{aur|virtualbox-ext-oracle}} package is available, and a prebuilt version can be found in the [[Unofficial user repositories#seblu|seblu]] repository.<br />
<br />
If you prefer to use the traditional and manual way: download the extension manually and install it via the GUI (''File > Preferences > Extensions'') or via {{ic|VBoxManage extpack install <.vbox-extpack>}}, make sure you have a toolkit (like [[Polkit]], gksu, etc.) to grant privileged access to VirtualBox. The installation of this extension [https://www.virtualbox.org/ticket/8473 requires root access].<br />
<br />
=== 使用正确的前端 ===<br />
<br />
现在,你已经准备好使用VirtualBox的。祝贺!<br />
<br />
多个前端提供给您,其中两个是默认提供:<br />
* If you want to use VirtualBox in command-line only (only launch and change settings of existing virtual machines), you can use the {{ic|VBoxSDL}} command. VBoxSDL does only provide a simple window that contains only the ''pure'' virtual machine, without menus or other controls.<br />
* If you want to use VirtualBox in command-line without any GUI running (e.g. on a server) to create, launch and configure virtual machines, use the {{ic|VBoxHeadless}} which produces no visible output on the host at all, but instead only delivers VRDP data.<br />
<br />
If you installed the {{Pkg|qt4}} optional dependency, you can run {{ic|VirtualBox}} and have a nice-looking GUI interface with menus usable via the mouse.<br />
<br />
Finally, you can use [[PhpVirtualBox]] to administrate your virtual machines via a web interface.<br />
<br />
Refer to the [https://www.virtualbox.org/manual VirtualBox manual] to learn how to create virtual machines.<br />
<br />
{{Warning|If you intend to store virtual disk images on a [[Btrfs]] file system, before creating any images, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the destination directory of these images.}}<br />
<br />
== 安装 Arch Linux的客户端 ==<br />
<br />
=== 安装Arch Linux在虚拟机内部 ===<br />
<br />
在 VirtualBox 中安装 Arch 非常简单直接,而且最好通过 pacman 安装 Guest Addition,不要使用 VirtualBox 中的 "Install Guest Additions" 或挂载的 ISO 安装。 <br />
{{Note| Windows 8+ or Server 2008+ hosts may have to disable Hyper-V in order to use hardware virtualization features and create 64 bit virtual machines in VirtualBox. To learn how to disable or re-enable Hyper-V [https://superuser.com/questions/684966/switch-off-hyper-v-without-disable-functionality-in-windows-8-1 see this Super User post]. }}<br />
<br />
Boot the Arch installation media through one of the virtual machine's virtual drives. Then, complete the installation of a basic Arch system as explained in the [[Beginners' guide]] or the [[Installation guide]] without installing any graphic driver: we will install one provided by VirtualBox just at the next step.<br />
<br />
==== 安装模式为EFI ====<br />
<br />
If you want to install Arch Linux in EFI mode inside VirtualBox, in the settings of the virtual machine, go in the ''Settings'' tab, and check the checkbox ''Enable EFI (special OSes only)''. After selecting the kernel from the Arch Linux installation media's menu, the media will hang for a minute or two and will continue to boot the kernel normally afterwards. Be patient.<br />
<br />
When booting in EFI mode, VirtualBox will first attempt to run {{ic|/EFI/BOOT/BOOTX64.EFI}} from the ESP. If that first option fails, VirtualBox will then try the EFI shell script {{ic|startup.nsh}} from the root of the ESP. Unless you want to manually launch your bootloader from the EFI shell every time, you will need to move your bootloader to that default path. Do not bother with the VirtualBox Boot Manager (accessible with {{ic|F2}} at boot): EFI entries added to it manually at boot or with {{Pkg|efibootmgr}} will persist after a reboot [https://www.virtualbox.org/ticket/11177 but are lost when the VM is shut down].<br />
<br />
=== 在 VirtualBox EFI 模式下使用 Arch ===<br />
<br />
我对这方面的设置有非常不好的经历,但是依然可以办到。<br />
<br />
''UPD. Using efibootmgr has the same effect as using VirtualBox boot menu (see the note below): settings [https://www.virtualbox.org/ticket/11177 disappear] after VM shutdown.''首先要说的是 {{ic|efibootmgr}} *完全无效*。虽然看起来是正常的,但是所有更动似乎在重啟后就失效。在进行正常 UEFI/GPT 安装后重啟,你会被丢到 EFI shell。送出 exit 后会看到菜单,选中 Boot Management Manager -> Boot Options -> Add Boot Option。使用文件浏览器找到 grub efi 文件并选中,添加你要的标签。之后,菜单选中 Change Boot Order,使用方向键选中你的 Arch 选项,按下 {{ic|+}} 移到最上方。现在 GRUB 应该默认啟动了。<br />
<br />
其它选项: 1) 将引导程序移到 {{ic|\EFI\boot\bootx64.efi}}, 2) 创建 {{ic|\startup.nsh}} 脚本,运行选定的引导程序,就像这样:<br />
<br />
{{hc|\startup.nsh|<br />
HD16a0a1:\EFI\refind\refindx64.efi}}<br />
<br />
Here I'm using consistent mapping name (HD16a0a1). It is probably a good idea, because they do survive configuration changes.<br />
<br />
{{Note|Another useful way to get back to the EFI menu after autobooting is working is to press the {{ic|C}} key inside GRUB and type {{ic|exit}}. Obviously, this will only work with {{ic|grub-efi}}, not {{ic|grub-bios}}.<br><br />
Regenerating the {{ic|grub.cfg}} file may also be required to fix broken UUIDs. Check with the {{ic|lsblk -f}} command that they match.<br><br />
Yet another useful way to get to VirtualBox boot menu is pressing {{ic|F12}} right after starting virtual machine. It comes in handy when using rEFInd + EFISTUB, for example.}}<br />
<br />
=== 安装客户端增强包 ===<br />
客户端增强包(The Guest Additions)能够激活共享文件夹功能,改善显卡加速支持和在主机端及客户端之间启用双向剪贴板。鼠标集成是另一项功能,用于减少在客户端中使用鼠标后将其释放的需要。<br />
<br />
After completing the installation of the guest system, install the VirtualBox [https://www.virtualbox.org/manual/ch04.html Guest Additions] which include drivers and applications that optimize the guest operating system. These can be installed via {{Pkg|virtualbox-guest-utils}}, which provides {{Pkg|virtualbox-guest-modules}} as a required dependency.<br />
<br />
{{Note|The method described in the [https://www.virtualbox.org/manual/ch04.html#idp54932560 VirtualBox manual] does not work on Arch Linux guests, resulting in an {{ic|Unable to determine your Linux distribution}} repeated several times as error message. If you tried this method first and you use the right solution described above afterwards, this will fail. You will get a [[Pacman#"Failed to commit transaction (conflicting files)" error|file conflict]]: {{ic|/usr/bin/VBox*}} and {{ic|/usr/lib/VBox* exists in filesystem}}. The solution is to remove the offending files first with {{ic|rm /usr/bin/VBox* /usr/lib/VBox*}} as root. These files are actually symbolic links to the location where the additions tools were installed; by default, this is {{ic|/opt/VBoxGuestAdditions-''version number''}}. Remove these files too with {{ic|rm -r /opt/VBoxGuestAdditions-''version number''}} as they are not needed. Now you can restart the installation from the right method above.}}<br />
<br />
===Arch Linux 客户端===<br />
参阅Arch Linux VirtualBox客户端<br />
====Windows 客户端====<br />
在你的虚拟机中安装Windows(XP 等等)后,只需选择''设备 &rarr; 安装增强功能''<br />
<br />
这将会挂载ISO镜像,接着Windows应该自动运行客户端增强包安装向导(The guest additions installer)。按照说明进行到底。<br />
<br />
=== 安装VirtualBox guest内核模块 ===<br />
<br />
==== 运行官方内核Guests ====<br />
<br />
* If you are using the {{Pkg|linux}} kernel, make sure the {{pkg|virtualbox-guest-modules}} package is still installed. The latter has been installed when you installed the {{Pkg|virtualbox-guest-utils}} package.<br />
* If you are using the LTS version of the kernel ({{pkg|linux-lts}}), you need to install the {{pkg|virtualbox-guest-modules-lts}} package. {{Pkg|virtualbox-guest-modules}} can now be removed if you want.<br />
* If you are using the {{aur|linux-ck}}, kernel, build the {{aur|virtualbox-ck-guest-modules}} package. {{Pkg|virtualbox-guest-modules}} can now be removed in this case too, if you want.<br />
<br />
==== 运行定制内核Guests ====<br />
<br />
As this installation step is quite similar to the Vitualbox kernel modules section for the host described above, please refer to [[#Install the VirtualBox kernel modules|that section]] for more information and replace all {{Pkg|virtualbox-host-modules}}, {{Pkg|virtualbox-host-dkms}} and {{AUR|vboxhost-hook}} statements by {{Pkg|virtualbox-guest-modules}}, {{Pkg|virtualbox-guest-dkms}} and {{AUR|vboxguest-hook}} respectively.<br />
<br />
=== 加载Virtualbox 内核模块 ===<br />
手动加载内核模块:<br />
# modprobe -a vboxguest vboxsf vboxvideo<br />
<br />
开机时自动加载VirtualBox模块[[Kernel modules#Automatic module handling]] 创建{{ic|*.conf}} 文件 (e.g. {{ic|virtualbox.conf}}) 在{{ic|/etc/modules-load.d/}} 加入如下几行:<br />
{{hc|/etc/modules-load.d/virtualbox.conf|<br />
vboxguest<br />
vboxsf<br />
vboxvideo}}<br />
<br />
Alternatively, [[enable]] the {{ic|vboxservice}} service which loads the modules and synchronizes the guest's system time with the host.<br />
<br />
=== 加载VirtualBox guest 服务 ===<br />
<br />
After the rather big installation step dealing with VirtualBox kernel modules, now you need to start the guest services. The guest services are actually just a binary executable called {{ic|VBoxClient}} which will interact with your X Window System. {{ic|VBoxClient}} manages the following features:<br />
* shared clipboard and drag and drop between the host and the guest;<br />
* seamless window mode;<br />
* the guest display is automatically resized according to the size of the guest window;<br />
* checking the VirtualBox host version<br />
<br />
All of these features can be enabled independently with their dedicated flags:<br />
$ VBoxClient --clipboard --draganddrop --seamless --display --checkhostversion<br />
<br />
As a shortcut, the {{ic|VBoxClient-all}} bash script enables all of these features. You should set {{ic|VBoxClient}} to be automatically loaded as your [[desktop environment]] or [[window manager]] starts. In practice,<br />
* if you are using a [[desktop environment]], you just need to check a box or add the {{ic|/usr/sbin/VBoxClient-all}} to the autostart section in your [[desktop environment]] settings (the DE will typically set a flag to a ''.desktop'' file in {{ic|~/.config/autostart}}, see [[Autostart#Desktop entries|the Autostart section]] for more details);<br />
* if you do not have any [[desktop environment]], add the following line to the top of {{ic|~/.xinitrc}} above any {{ic|exec}} options. See [[Xinitrc]] for detail.<br />
{{hc|~/.xinitrc|<br />
/usr/bin/VBoxClient-all}}<br />
<br />
VirtualBox can also synchronize the time between the host and the guest. To do this, run {{ic|VBoxService}} as root. To set this to run automatically on boot, simply [[enable]] the {{ic|vboxservice}} service.<br />
<br />
Now, you should have a working Arch Linux guest. Note that features like clipboard sharing are disabled by default in VirtualBox, and you will need to turn them on in the per-VM settings if you actually want to use them (e.g. ''Settings > General > Advanced > Shared Clipboard'').<br />
<br />
If you want to share folders between your host and your Arch Linux guest, read on.<br />
<br />
=== 启用文件共享 ===<br />
<br />
在安装 {{pkg|virtualbox-guest-utils}} 之后,你应该运行 {{ic|VBoxClient-all}} 啟动共享剪贴板、调整屏幕大小等服务。<br />
* 若你运行会啟动 {{ic|/etc/xdg/autostart/vboxclient.desktop}} 的服务,例如 GNOME 或 KDE,便不需再进行额外动作。<br />
* If you use {{Ic|.xinitrc}} to launch things instead, you must add the following to your {{Ic|.xinitrc}} before launching your WM.<br />
<br />
# VBoxClient-all &<br />
<br />
Shared folders are managed on the host, in the settings of the Virtual Machine accessible via the GUI of VirtualBox, in the ''Shared Folders'' tab. There, ''Folder Path'', the name of the mount point identified by ''Folder name'', and options like ''Read-only'', ''Auto-mount'' and ''Make permanent'' can be specified. These parameters can be defined with the {{ic|VBoxManage}} command line utility. See [https://www.virtualbox.org/manual/ch04.html#sharedfolders there for more details].<br />
<br />
No matter which method you will use to mount your folder, all methods require some steps first.<br />
<br />
To avoid this issue {{ic|/sbin/mount.vboxsf: mounting failed with the error: No such device}}, make sure the {{ic|vboxsf}} kernel module is properly loaded. It should be, since we enabled all guest kernel modules previously.<br />
<br />
Two additional steps are needed in order for the mount point to be accessible from users other than root:<br />
* the {{Pkg|virtualbox-guest-utils}} package created a group {{ic|vboxsf}} (done in a previous step);<br />
* your username must be in this group, use this command {{ic|gpasswd -a $USER vboxsf}} to add your username and use {{ic|newgrp}} to apply the changes immediately;<br />
<br />
== Arch Linux 客户机共享文件夹 ==<br />
共享文件夹是主机上的 VirtualBox 程序控制。可以添加、自动挂载并设置成只读。主机系统创建的共享文件夹位于 /media/sf_SHAREDFOLDERNAME。要使用共享文件,需要在安装完 Guest Additions 软件包之后执行:<br />
<br />
$sudo groupadd vboxsf<br />
$sudo gpasswd -a $USER vboxsf<br />
<br />
<br />
=== 和主机系统同步日期 ===<br />
<br />
要同步系统间的日期,<br />
<br />
==== Systemd ====<br />
<br />
下次开机开始同步:<br />
<br />
# systemctl enable vboxservice.service<br />
<br />
立即启动同步:<br />
<br />
# systemctl start vboxservice.service<br />
<br />
<br />
==== 手动挂载 ====<br />
<br />
Use the following command to mount your folder in your Arch Linux guest:<br />
# mount -t vboxsf ''shared_folder_name'' ''mount_point_on_guest_system''<br />
<br />
The vboxsf filesystem offers other options which can be displayed with this command:<br />
# mount.vboxsf<br />
<br />
For example if the user was not in the ''vboxsf'' group, we could have used this command to give access our mountpoint to him:<br />
# mount -t vboxsf -o uid=1000,gid=1000 home /mnt/<br />
<br />
Where ''uid'' and ''gid'' are values corresponding to the users we want to give access to. These values are obtained from the {{ic|id}} command run against this user.<br />
<br />
==== 自动挂载 ====<br />
<br />
In order for the automounting feature to work you must have checked the auto-mount checkbox in the GUI or used the optional {{ic|--automount}} argument with the command {{ic|VBoxManage sharedfolder}}.<br />
<br />
The shared folder should now appear in {{ic|/media/sf_''shared_folder_name''}}. If users in {{ic|media}} cannot access the shared folders, check that {{ic|media}} has permissions 755 or has group ownership {{ic|vboxsf}} if using permission 750. This is currently not the default if media is created by installing the {{ic|virtualbox-guest-utils}}.<br />
<br />
You can use symlinks if you want to have a more convenient access and avoid to browse in that directory, e.g.:<br />
$ ln -s /media/sf_''shared_folder_name'' ~/''my_documents''<br />
<br />
==== 引导时挂载====<br />
<br />
You can mount your directory with [[fstab]]. However, to prevent startup problems with systemd, {{ic|1=comment=systemd.automount}} should be added to {{ic|/etc/fstab}}. This way, the shared folders are mounted only when those mount points are accessed and not during startup. This can avoid some problems, especially if the guest additions are not loaded yet when systemd read fstab and mount the partitions.<br />
desktop /media/desktop vboxsf uid=user,gid=group,rw,dmode=700,fmode=600,comment=systemd.automount 0 0<br />
<br />
As of 2012-08-02, mount.vboxsf does not support the ''nofail'' option:<br />
desktop /media/desktop vboxsf uid=user,gid=group,rw,dmode=700,fmode=600,nofail 0 0<br />
<br />
== VirtualBox虚拟机从其他虚拟机导入/导出的管理==<br />
<br />
If you plan to use your virtual machine on another hypervisor or want to import in VirtualBox a virtual machine created with another hypervisor, you might be interested in reading the following steps.<br />
<br />
=== 添加删除===<br />
<br />
Guest additions are available in most hypervisor solutions: VirtualBox comes with the Guest Additions, VMware with the VMware Tools, Parallels with the Parallels Tools, etc. These additional components are designed to be installed inside a virtual machine after the guest operating system has been installed. They consist of device drivers and system applications that optimize the guest operating system for better performance and usability [https://www.virtualbox.org/manual/ch04.html by providing these features].<br />
<br />
If you have installed the additions to your virtual machine, please uninstall them first. Your guest, especially if it is using an OS from the Windows family, might behave weirdly, crash or even might not boot at all if you are still using the specific drivers in another hypervisor.<br />
<br />
=== 使用正确的虚拟磁盘格式===<br />
<br />
这一步将取决于虚拟磁盘映像直接或不能转换的能力。<br />
<br />
==== 自动工具 ====<br />
<br />
Some companies provide tools which offer the ability to create virtual machines from a Windows or GNU/Linux operating system located either in a virtual machine or even in a native installation. With such a product, you do not need to apply this and the following steps and can stop reading here.<br />
* ''[http://www.parallels.com/products/transporter Parallels Transporter]'' which is non free, is a product from Parallels Inc. This solution basically consists in an piece of software called ''agent'' that will be installed in the guest you want to import/convert. Then, Parallels Transporter, <u>which only works on OS X</u>, will create a virtual machine from that ''agent'' which is contacted either by USB or Ethernet network.<br />
* ''[https://www.vmware.com/products/converter/ VMware vCenter Converter]'' which is free upon registration on the VMware webiste, works nearly the same way as Parallels Transporter, but the piece of software that will gather the data to create the virtual machine only works on a Windows platform.<br />
<br />
==== 手动转换 ====<br />
<br />
First, familiarize yourself with the [[#Formats supported by VirtualBox]] and [[Wikipedia:Comparison of platform virtual machines#Image type compatibility|those supported by third-party hypervisors]].<br />
<br />
* Importing or exporting a virtual machine from/to a VMware solution is not a problem at all if you use the VMDK or OVF disk format, otherwise converting [[#VMDK to VDI and VDI to VMDK]] is possible and the aforementioned VMware vCenter Converter tool is available.<br />
<br />
* Importing or exporting from/to QEMU is not a problem neither: some QEMU formats are supported directly by VirtualBox and conversion between [[#QCOW2 to VDI and VDI to QCOW2]] is still available if needed.<br />
<br />
* Importing or exporting from/to Parallels hypervisor is the hardest way: Parallels does only support its own HDD format (even the standard and portable OVF format is not supported!).<br />
:* To export your virtual machine to Parallels, you will need to use the Parallels Transporter tool described above.<br />
:* To import your virtual machine to VirtualBox, you will need to use the VMware vCenter Converter described above to convert the VM to the VMware format first. Then, apply the solution to migrate from VMware.<br />
<br />
===创建虚拟机的配置为你的虚拟机管理程序 ===<br />
<br />
Each hypervisor have their own virtual machine configuration file: {{ic|.vbox}} for VirtualBox, {{ic|.vmx}} for VMware, a {{ic|config.pvs}} file located in the virtual machine bundle ({{ic|.pvm}} file), etc. You will have thus to recreate a new virtual machine in your new destination hypervisor and specify its hardware configuration as close as possible as your initial virtual machine.<br />
<br />
Pay a close attention to the firmware interface (BIOS or UEFI) used to install the guest operating system. While an option is available to choose between these 2 interfaces on VirtualBox and on Parallels solutions, on VMware, you will have to add manually the following line to your ''.vmx'' file.<br />
<br />
{{hc|ArchLinux_vm.vmx|2=<br />
firmware = "efi"<br />
}}<br />
<br />
Finally, ask your hypervisor to use the existing virtual disk you have converted and launch the virtual machine.<br />
{{Tip|<br />
* On VirtualBox, if you do not want to browse the whole GUI to find the right location to add your new virtual drive device, you can [[#Replace a virtual disk manually from the .vbox file]], or use the {{ic|VBoxManage storageattach}} described in [[#Increase virtual disks]] or in the [https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach VirtualBox manual page].<br />
* Similarly, in VMware products, you can replace the location of the current virtual disk location by adapting the ''.vmdk'' file location in your ''.vmx'' configuration file.}}<br />
<br />
==虚拟磁盘管理 ==<br />
<br />
=== 支持VirtualBox的格式 ===<br />
<br />
VirtualBox supports the following virtual disk formats:<br />
<br />
* VDI: The Virtual Disk Image is the VirtualBox own open container used by default when you create a virtual machine with VirtualBox.<br />
<br />
* VMDK: The Virtual Machine Disk has been initially developed by VMware for their products. The specification was initially closed source, but it became now an open format which is fully supported by VirtualBox. This format offers the ability to be split into several 2GB files. This feature is specially useful if you want to store the virtual machine on machines which do not support very large files. Other formats, excluding the HDD format from Parallels, do not provide such an equivalent feature.<br />
<br />
* VHD: The Virtual Hard Disk is the format used by Microsoft in Windows Virtual PC and Hyper-V. If you intend to use any of these Microsoft products, you will have to choose this format.<br />
:{{Tip|Since Windows 7, this format can be mounted directly without any additional application.}} <br />
<br />
* VHDX (read only): This is the eXtended version of the Virtual Hard Disk format developed by Microsoft, which has been released on 2012-09-04 with Hyper-V 3.0 coming with Windows Server 2012. This new version of the disk format does offer enhanced performance (better block alignment), larger blocks size, and journal support which brings power failure resiliency. VirtualBox [https://www.virtualbox.org/manual/ch15.html#idp63002176 should support this format in read only].<br />
<br />
* Version 2 of the HDD: The HDD format is developed by Parallels Inc and used in their hypervisor solutions like Parallels Desktop for Mac. Newer versions of this format (i.e. 3 and 4) are not supported due to the lack of documentation for this proprietary format. {{Note|There is currently a controversy regarding the support of the version 2 of the format. While the official VirtualBox manual [https://www.virtualbox.org/manual/ch05.html#vdidetails only reports the second version of the HDD file format as supported], Wikipedia's contributors are [[Wikipedia:Comparison of platform virtual machines#Image type compatibility|reporting the first version may work too]]. Help is welcome if you can perform some tests with the first version of the HDD format.}}<br />
<br />
* QED: The QEMU Enhanced Disk format is an old file format for QEMU, another free and open source hypervisor. This format was designed from 2010 in a way to provide a superior alternative to QCOW2 and others. This format features a fully asynchronous I/O path, strong data integrity, backing files, and sparse files. QED format is supported only for compatibility with virtual machines created with old versions of QEMU.<br />
<br />
* QCOW: The QEMU Copy On Write format is the current format for QEMU. The QCOW format does support zlib-based transparent compression and encryption (the latter has flaw and is not recommended). QCOW is available in two versions: QCOW and QCOW2. The latter tends to supersede the first one. QCOW is [https://www.virtualbox.org/manual/ch15.html#idp63002176 currently fully supported by VirtualBox]. QCOW2 comes in two revisions: QCOW2 0.10 and QCOW2 1.1 (which is the default when you create a virtual disk with QEMU). VirtualBox does not support this QCOW2 format (both revisions have been tried).<br />
<br />
* OVF: The Open Virtualization Format is an open format which has been designed for interoperability and distributions of virtual machines between different hypervisors. VirtualBox supports all revisions of this format via the [https://www.virtualbox.org/manual/ch08.html#idp55423424 {{ic|VBoxManage}} import/export feature] but with [https://www.virtualbox.org/manual/ch14.html#KnownProblems known limitations].<br />
<br />
* RAW: This is the mode when the virtual disk is exposed directly to the disk without being contained in a specific file format container. VirtualBox supports this feature in several ways: converting RAW disk [https://www.virtualbox.org/manual/ch08.html#idp59139136 to a specific format], or by [https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi cloning a disk to RAW], or by using directly a VMDK file [https://www.virtualbox.org/manual/ch09.html#idp57804112 which points to a physical disk or a simple file].<br />
<br />
=== 磁盘映像格式转换 ===<br />
<br />
==== VMDK to VDI and VDI to VMDK ====<br />
<br />
VirtualBox can handle back and forth conversion between VDI and VMDK by itself with [https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi {{ic|VBoxManage clonehd}}].<br />
<br />
VMDK to VDI:<br />
<br />
$ VBoxManage clonehd ''source.vmdk'' ''destination.vdi'' --format VDI<br />
<br />
VDI to VMDK:<br />
<br />
$ VBoxManage clonehd ''source.vdi'' ''destination.vmdk'' --format VMDK<br />
<br />
==== VHD to VDI and VDI to VDH ====<br />
<br />
VirtualBox can handle conversion back and forth this format with [https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi {{ic|VBoxManage clonehd}}] too.<br />
<br />
VHD to VDI:<br />
<br />
$ VBoxManage clonehd ''source.vhd'' ''destination.vdi'' --format VDI<br />
<br />
VDI to VHD:<br />
<br />
$ VBoxManage clonehd ''source.vdi'' ''destination.vhd'' --format VHD<br />
<br />
==== QCOW2 to VDI and VDI to QCOW2 ====<br />
<br />
[https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi {{ic|VBoxManage clonehd}}] cannot handle the QEMU format conversion; we will thus rely on another tool. The {{ic|qemu-img}} command from {{Pkg|qemu}} can be used to convert images back and forth from VDI to QCOW2. {{Note|{{ic|qemu-img}} can handle a bunch of other formats too. According to the {{ic|qemu-img --help}}, here are the supported formats this tool supports: "''vvfat vpc vmdk vhdx vdi ssh sheepdog sheepdog sheepdog raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd nbd nbd iscsi dmg tftp ftps ftp https http cow cloop bochs blkverify blkdebug'".}}<br />
<br />
QCOW2 to VDI:<br />
<br />
$ qemu-img convert -pO vdi ''source.qcow2'' ''destination.vdi''<br />
<br />
VDI to QCOW2:<br />
<br />
$ qemu-img convert -pO qcow2 ''source.vdi'' ''destination.qcow2''<br />
<br />
As QCOW2 comes in two revisions (see [[#Formats supported by VirtualBox]], use the flag {{ic|1=-o compat=}} to specify the revision.<br />
<br />
$ qemu-img convert -pO qcow2 ''source.vdi'' ''destination.qcow2'' -o compat=0.10<br />
or<br />
$ qemu-img convert -pO qcow2 ''source.vdi'' ''destination.qcow2'' -o compat=1.1<br />
<br />
{{Tip|The {{ic|-p}} parameter is used to get the progression of the conversion task.}}<br />
<br />
==从其他虚拟机中迁移==<br />
<code>qemu-img</code> 程序可以用来将映像从一种格式转换到另一种格式,或为一个映像添加压缩或加密。<br />
<br />
# pacman -S qemu<br />
<br />
===从QEMU映像转换===<br />
To convert a QEMU image for use with VirtualBox, first convert it to ''raw'' format, then use VirtualBox's conversion utility to convert and compact it in its native format.<br />
$ qemu-img convert -O raw test.qcow2 test.raw<br />
$ VBoxManage modifyvdi /full/path/to/test.vdi compact<br />
or <br />
$ qemu-img convert -O raw test.qcow2 test.raw<br />
(of course you must have installed qemu package for that)<br />
$ VBoxManage convertfromraw /full/path/to/test.raw /full/path/to/test.vdi<br />
$ VBoxManage modifyvdi /full/path/to/test.vdi compact<br />
<br />
===从VMware映像转换===<br />
运行 <br />
$ VBoxManage clonehd source.vmdk target.vdi --format VDI<br />
<br />
对于当前VirtualBox版本来说也许是不必要的(有待证实)<br />
<br />
=== 挂载虚拟磁盘 ===<br />
<br />
==== VDI ====<br />
<br />
Mounting vdi images only works with fixed size images (a.k.a. static images); dynamic (dynamically size allocating) images are not easily mountable.<br />
<br />
The offset of the partition (within the vdi) is needed, then add the value of {{ic|offData}} to {{ic|32256}} (e.g. 69632 + 32256 = 101888):<br />
<br />
$ VBoxManage internalcommands dumphdinfo <storage.vdi> | grep "offData"<br />
<br />
The can now be mounted with:<br />
<br />
# mount -t ext4 -o rw,noatime,noexec,loop,offset=101888 <storage.vdi> /mntpoint/<br />
<br />
You can also use [https://github.com/pld-linux/VirtualBox/blob/master/mount.vdi mount.vdi] script that, which you can use as (install script itself to {{ic|/usr/bin/}}):<br />
<br />
# mount -t vdi -o fstype=ext4,rw,noatime,noexec ''vdi_file_location'' ''/mnt/''<br />
<br />
Alternately you can use {{Pkg|qemu}}'s kernel module that can do this [[http://bethesignal.org/blog/2011/01/05/how-to-mount-virtualbox-vdi-image/ attrib]]:<br />
<br />
# modprobe nbd max_part=16<br />
# qemu-nbd -c /dev/nbd0 <storage.vdi><br />
# mount /dev/nbd0p1 /mnt/dir/<br />
# # to unmount:<br />
# umount /mnt/dir/<br />
# qemu-nbd -d /dev/nbd0<br />
<br />
If the partition nodes are not propagated try using {{ic|partprobe /dev/nbd0}}; otherwise, a vdi partition can be mapped directly to a node by: {{ic|qemu-nbd -P 1 -c /dev/nbd0 <storage.vdi>}}.<br />
<br />
=== 压缩磁盘映像 ===<br />
<br />
Compacting virtual disks only works with {{ic|.vdi}} files and basically consists in the following steps.<br />
<br />
Boot your virtual machine and remove all bloat manually or by using cleaning tools like {{Pkg|bleachbit}} which is [http://bleachbit.sourceforge.net/download/windows available for Windows systems too].<br />
<br />
Wiping free space with zeroes can be achieved with several tools:<br />
* If you were previously using Bleachbit, check the checkbox ''System > Free disk space'' in the GUI, or use {{ic|bleachbit -c system.free_disk_space}} in CLI;<br />
* 在 UNIX基本系统,使用 {{ic|dd}} or preferably {{Pkg|dcfldd}} (see [http://superuser.com/a/355322 here] to learn the differences) :<br />
:{{bc|1=# dcfldd if=/dev/zero of=''/fillfile'' bs=4M}}<br />
:When {{ic|fillfile}} reaches the limit of the partition, you will get a message like {{ic|1280 blocks (5120Mb) written.dcfldd:: No space left on device}}. This means that all of the user-space and non-reserved blocks of the partition will be filled with zeros. Using this command as root is important to make sure all free blocks have been overwritten. Indeed, by default, when using partitions with ext filesystem, a specified percentage of filesystem blocks is reserved for the super-user (see the {{ic|-m}} argument in the {{ic|mkfs.ext4}} man pages or use {{ic|tune2fs -l}} to see how much space is reserved for root applications).<br />
:When the aforementioned process has completed, you can remove the file {{ic|''fillfile''}} you created.<br />
<br />
* On Windows, there are two tools available:<br />
:*{{ic|sdelete}} from the [http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx Sysinternals Suite], type {{ic|sdelete -s -z ''c:''}}, where you need to reexecute the command for each drive you have in your virtual machine;<br />
:* or, if you love scripts, there is a [http://blog.whatsupduck.net/2012/03/powershell-alternative-to-sdelete.html PowerShell solution], but which still needs to be repeated for all drives.<br />
::{{bc|PS> ./Write-ZeroesToFreeSpace.ps1 -Root ''c:\'' -PercentFree 0}}<br />
::{{Note|This script must be run in a PowerShell environment with administrator privileges. By default, scripts cannot be run, ensure the execution policy is at least on {{ic|RemoteSigned}} and not on {{ic|Restricted}}. This can be checked with {{ic|Get-ExecutionPolicy}} and the required policy can be set with {{ic|Set-ExecutionPolicy RemoteSigned}}.}}<br />
<br />
Once the free disk space have been wiped, shut down your virtual machine.<br />
<br />
The next time you boot your virtual machine, it is recommended to do a filesystem check.<br />
* On UNIX-based systems, you can use {{ic|fsck}} manually;<br />
:* On GNU/Linux systems, and thus on Arch Linux, you can force a disk check at boot [[Fsck#Forcing the check|thanks to a kernel boot parameter]];<br />
* On Windows systems, you can use:<br />
:* either {{ic|chkdsk ''c:'' /F}} where {{ic|''c:''}} needs to be replaced by each disk you need to scan and fix errors;<br />
:* or {{ic|FsckDskAll}} [http://therightstuff.de/2009/02/14/ChkDskAll-ChkDsk-For-All-Drives.aspx from here] which is basically the same software as {{ic|chkdsk}}, but without the need to repeat the command for all drives;<br />
<br />
Now, remove the zeros from the {{ic|vdi}} file with {{ic|[https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi VBoxManage modifyhd]}}:<br />
$ VBoxManage modifyhd ''your_disk.vdi'' --compact<br />
<br />
{{Note|If your virtual machine has snapshots, you need to apply the above command on each {{ic|.vdi}} files you have.}}<br />
<br />
=== 增加虚拟磁盘 ===<br />
<br />
If you are running out of space due to the small hard drive size you selected when you created your virtual machine, the solution adviced by the VirtualBox manual is to use [https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi {{ic|VBoxManage modifyhd}}]. However this command only works for VDI and VHD disks and only for the dynamically allocated variants. If you want to resize a fixed size virtual disk disk too, read on this trick which works either for a Windows or UNIX-like virtual machine.<br />
<br />
First, create a new virtual disk next to the one you want to increase:<br />
$ VBoxManage createhd -filename ''new.vdi'' --size ''10000''<br />
<br />
where size is in MiB, in this example 10000MiB ~= 10GiB, and ''new.vdi'' is name of new hard drive to be created.<br />
<br />
Next, the old virtual disk needs to be cloned to the new one which this may take some time:<br />
$ VBoxManage clonehd ''old.vdi'' ''new.vdi'' --existing<br />
<br />
{{Note|By default, this command uses the ''Standard'' (corresponding to dynamic allocated) file format variant and thus will not use the same file format variant as your source virtual disk. If your ''old.vdi'' has a fixed size and you want to keep this variant, add the parameter {{ic|--variant Fixed}}.}}<br />
<br />
Detach the old hard drive and attach new one, replace all mandatory italic arguments by your own:<br />
$ VBoxManage storageattach ''VM_name'' --storagectl ''SATA'' --port ''0'' --medium none<br />
$ VBoxManage storageattach ''VM_name'' --storagectl ''SATA'' --port ''0'' --medium ''new.vdi'' --type hdd<br />
<br />
To get the storage controller name and the port number, you can use the command {{ic|VBoxManage showvminfo ''VM_name''}}. Among the output you will get such a result (what you are looking for is in italic):<br />
<br />
{{bc|<br />
[...]<br />
Storage Controller Name (0): IDE<br />
Storage Controller Type (0): PIIX4<br />
Storage Controller Instance Number (0): 0<br />
Storage Controller Max Port Count (0): 2<br />
Storage Controller Port Count (0): 2<br />
Storage Controller Bootable (0): on<br />
Storage Controller Name (1): SATA<br />
Storage Controller Type (1): IntelAhci<br />
Storage Controller Instance Number (1): 0<br />
Storage Controller Max Port Count (1): 30<br />
Storage Controller Port Count (1): 1<br />
Storage Controller Bootable (1): on<br />
IDE (1, 0): Empty<br />
''SATA'' (''0'', 0): /home/wget/IT/Virtual_machines/GNU_Linux_distributions/ArchLinux_x64_EFI/Snapshots/{6bb17af7-e8a2-4bbf-baac-fbba05ebd704}.vdi (UUID: 6bb17af7-e8a2-4bbf-baac-fbba05ebd704)<br />
[...]}}<br />
<br />
Download [http://gparted.org/download.php GParted live image] and mount it as a virtual CD/DVD disk file, boot your virtual machine, increase/move your partitions, umount GParted live and reboot.<br />
<br />
{{Note|On GPT disks, increasing the size of the disk will result in the backup GPT header not being at the end of the device. GParted will ask to fix this, click on ''Fix'' both times. On MBR disks, you do not have such a problem as this partition table as no trailer at the end of the disk.}}<br />
<br />
Finally, unregister the virtual disk from VirtualBox and remove the file:<br />
$ VBoxManage closemedium disk ''old.vdi''<br />
$ rm ''old.vdi''<br />
<br />
===从.vbox文件中手动更换虚拟磁盘 ===<br />
<br />
If you think that editing a simple ''XML'' file is more convenient than playing with the GUI or with {{ic|VBoxManage}} and you want to replace (or add) a virtual disk to your virtual machine, in the ''.vbox'' configuration file corresponding to your virtual machine, simply replace the GUID, the file location and the format to your needs:<br />
<br />
{{hc|ArchLinux_vm.vbox|2=<br />
<HardDisk uuid="''{670157e5-8bd4-4f7b-8b96-9ee412a712b5}''" location="''ArchLinux_vm.vdi''" format="''VDI''" type="Normal"/><br />
}}<br />
<br />
then in the {{ic|<AttachedDevice>}} sub-tag of {{ic|<StorageController>}}, replace the GUID by the new one.<br />
<br />
{{hc|ArchLinux_vm.vbox|2=<br />
<AttachedDevice type="HardDisk" port="0" device="0"><br />
<Image uuid="''{670157e5-8bd4-4f7b-8b96-9ee412a712b5}''"/><br />
</AttachedDevice><br />
}}<br />
<br />
{{Note|If you do not know the GUID of the drive you want to add, you can use the {{ic|VBoxManage showhdinfo ''file''}}. If you previously used {{ic|VBoxManage clonehd}} to copy/convert your virtual disk, this command should have outputted the GUID just after the copy/conversion completed. Using a random GUID does not work, as each [http://www.virtualbox.org/manual/ch05.html#cloningvdis UUID is stored inside each disk image].}}<br />
<br />
====Linux主机和其他操作系统之间的转移 ====<br />
<br />
The information about path to harddisks and the snapshots is stored between {{ic|<HardDisks> .... </HardDisks>}} tags in the file with the ''.vbox'' extension. You can edit them manually or use this script where you will need change only the path or use defaults, assumed that ''.vbox'' is in the same directory with a virtual harddisk and the snapshots folder. It will print out new configuration to stdout.<br />
<br />
{{bc|1=<br />
#!/bin/bash<br />
NewPath="${PWD}/"<br />
Snapshots="Snapshots/"<br />
Filename="$1"<br />
<br />
awk -v SetPath="$NewPath" -v SnapPath="$Snapshots" '{if(index($0,"<HardDisk uuid=") != 0){A=$3;split(A,B,"=");<br />
L=B[2];<br />
gsub(/\"/,"",L);<br />
sub(/^.*\//,"",L);<br />
sub(/^.*\\/,"",L);<br />
if(index($3,"{") != 0){SnapS=SnapPath}else{SnapS=""};<br />
print $1" "$2" location="\"SetPath SnapS L"\" "$4" "$5}<br />
else print $0}' "$Filename"}}<br />
<br />
{{Note|<br />
* If you will prepare virtual machine for use in Windows host then in the path name end you should use backslash \ instead of / .<br />
* The script detects snapshots by looking for {{ic|{}} in the file name.<br />
* To make it run on a new host you will need to add it first to the register by clicking on '''Machine -> Add...''' or use hotkeys Ctrl+A and then browse to ''.vbox'' file that contains configuration or use command line {{ic|VBoxManage registervm ''filename''.vbox}}}}<br />
<br />
==配置==<br />
===网络===<br />
VirtualBox 客户端可以通过不同的方式连接网络;其中,有[[#NAT]]和[[#桥接]]链接。[[#NAT]]是最简单的且作为一个新虚拟机的默认方式。<br />
<br />
[http://www.virtualbox.org/manual/UserManual.html VirtualBox手册]涵盖了主机模式和内网选项。这些都被忽略了,因为在大多数情况下与操作系统无关。<br />
====NAT====<br />
在VirtualBox中:<br />
* 访问虚拟机的''设置''菜单;<br />
* 点击左边的''网络‘’;最后,<br />
* 在“连接方式”的下拉列表中选择''NAT''。<br />
<br />
与VirtualBox捆绑的DHCP服务使得客户端系统能够与DHCP一起配置,第一张卡的NAT IP地址是 10.0.2.0,第二张是10.0.3.0,往后以此类推。<br />
<br />
====桥接====<br />
桥接网络可能被以多种方式启动;其中,有要求以较少控制为代价进行最小启动的原生方式。对于较新版本,VirtualBox可以在没有第三方工具的帮助下,在客户端和无线主机接口间进行桥接。<br />
<br />
在继续之前,加载必要模块:<br />
# modprobe vboxnetflt<br />
<br />
在VirtualBox中:<br />
* 访问虚拟机的''设置''菜单;<br />
* 点击左边列表中的''网络''<br />
* 在''链接方式''的下拉列表中选择''Bridged Adapter(桥接适配器)'';最后,<br />
* 在''界面名称''下拉列表中,选择客户端操作系统被包含在内,主机用于连接网络的接口。<br />
<br />
Start the virtual machine and configure its network as usual; e.g., DHCP or static.<br />
打开虚拟机,像往常一样配置其网络;例如 DHCP 或 static(静态网络)。<br />
<br />
===主机端和客户端之间的键盘和鼠标===<br />
* 为了捕获键盘和鼠标,点击虚拟机内部。<br />
* 想要释放,按下右 {{ic|Ctrl}}.<br />
<br />
想要获得在主机端和客户端之间的无缝鼠标集成功能,在客户端内安装[[#客户端增强包]]。<br />
<br />
===主机端和客户端间的共享文件夹===<br />
在虚拟机的设置中,找到数据空间标签,然后加入你想要共享的文件夹。<br />
<br />
*注意:为了使用这个功能你需要安装客户端增强包。<br />
在Linux主机中,''设备 &rarr; 安装增强功能''<br />
确定(被要求下载CD镜像时)<br />
挂载(被要求注册和挂载时)<br />
<br />
In a Linux host, create one or more folders for sharing files, then set the shared folders via the virtualbox menu (guest window).<br />
在Linux主机端中,为共享的文件创建一个或更多的文件夹,然后通过Virtualbox菜单中设置(Windows客户端)<br />
<br />
在Windows客户端中,从VirtualBox 1.5.0开始,共享文件夹是可浏览的,所以在Windows资源管理器中是可视的。打开Windows资源管理器,在''我的网络位置(My Networking Places) &rarr; 整个网络(Entire Network) &rarr; VirtualBox Shared Folders(VirtualBox共享文件夹)''。<br />
<br />
启动Windows资源管理器(运行资源管理器命令),游览 网络位置(network places) -> (+)号展开:<br />
整个网络(entire network)&rarr; VirtualBox Shared Folders(VirtualBox共享文件夹) &rarr;'''\\Vboxsvr''' &rarr; 然后你就可以在此展开所有已配置的文件夹了,并且在客户端文件系统中为Linux文件夹创建快捷方式。你也可以使用“添加网络位置向导(Add network place wizard)”找到“VBoxsvr”。<br />
<br />
此外,在Windows命令行提示符中,你也可以使用以下命令:<br />
net use x: \\VBOXSVR\sharename<br />
<br />
虽然{{ic|VBOXSVR}}是一个固定名称,但请用你所想要用于共享的盘符替代{{ic|x:}},用VBoxManage指定的共享名替换sharename。<br />
<br />
在Windows客户端中,为了以VirtualBox共享文件夹改善文件的读取与保存(如MS Office),编辑''c:\windows\system32\drivers\etc\hosts''如下:<br />
127.0.0.1 localhost vboxsvr<br />
<br />
在Linux客户端中,实用以下命令:<br />
# mount -t vboxsf [-o OPTIONS] sharename mountpoint<br />
(注意:共享名是任意的,或者和VirtualBox对话框中选定的一样(在主机端文件系统中共享目录的挂载点)。<br />
:自动挂载共享文件夹可以通过Linux客户端 /etc/fstab 文件来实现。你可以指定uid=#,gid=#(# 用实际的数字uid和gid替换),以便以普通用户权限(而不是root权限)来挂载共享文件夹。(这个对于为了在Linux客户端中使用而挂载主机上~/home的一部分是很有用的。为了做到这点,依照以下格式添加一个条目到Linux客户端中的/etc/fstab:<br />
<br />
sharename mountpoint vboxsf uid=#,gid=# 0 0<br />
<br />
用在VBoxManage中指定的共享名替换{{ic|sharename}},并用你想要共享的路径替换mountpoint(如 /mnt/share)。通常的挂载申请,就是说,如果还没有的话,先创建这个文件夹。注意,如果你已经让VirtualBox“自动挂载”这个共享文件夹,这一步可能就不必了,而且你的文件夹可以在/media 下找到。<br />
<br />
除了mount命令提供的标准选项外,以下是可选的:<br />
iocharset=CHARSET<br />
设置用于I/O操作的字符集(默认utf8),并且:<br />
convertcp=CHARSET<br />
用于指定用于共享文件夹名称的字符集(默认utf8)<br />
<br />
=== Clone a virtual disk and assigning a new UUID to it ===<br />
<br />
UUIDs are widely used by VirtualBox. Each virtual machines and each virtual disk of a virtual machine must have a different UUID. When you launch a virtual machine in VirtualBox, the latter will keep track of all UUID of your virtual machine instance. See the [http://www.virtualbox.org/manual/ch08.html#vboxmanage-list {{ic|VBoxManage list}}] to list the items registered with VirtualBox.<br />
<br />
If you cloned a virtual disk manually by copying the virtual disk file, you will need to assign a new UUID to the cloned virtual drive if you want to use the disk in the same virtual machine or even in another (if that one has already been opened, and thus registered, with VirtualBox).<br />
<br />
You can use this command to assign a new UUID to your virtual disk: <br />
$ VBoxManage internalcommands sethduuid ''/path/to/disk.vdi''<br />
<br />
{{Tip|In the future, to avoid copying the virtual disk and assigning a new UUID to your file manually, use {{ic|[http://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi VBoxManage clonehd]}} instead.}}<br />
<br />
{{Note|The commands above supports [[#Formats supported by VirtualBox|all virtual disk formats supported by VirtualBox]].}}<br />
<br />
== 高级配置 ==<br />
<br />
=== 虚拟机管理启动 ===<br />
<br />
==== 启动虚拟机服务 ====<br />
<br />
此后查找将用于考虑虚拟机作为服务systemd服务的实现。<br />
<br />
{{hc|/etc/systemd/system/vboxvmservice@.service|2=<br />
[Unit]<br />
Description=VBox Virtual Machine %i Service<br />
Requires=systemd-modules-load.service<br />
After=systemd-modules-load.service<br />
<br />
[Service]<br />
User=''username''<br />
Group=vboxusers<br />
ExecStart=/usr/bin/VBoxHeadless -s %i<br />
ExecStop=/usr/bin/VBoxManage controlvm %i savestate<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
{{Note|Replace {{ic|''username''}} with a user that is a member of the {{ic|vboxusers}} group. Make sure the user chosen is the same user that will create/import virtual machines, otherwise the user will not see the VM appliances.}}<br />
<br />
{{Note|If you have multiple virtual machines managed by Systemd and they are not stopping properly, try to add {{ic|RemainAfterExit&#61;true}} and {{ic|KillMode&#61;none}} at the end of {{ic|[Service]}} section.}}<br />
<br />
To enable the service that will launch the virtual machine at next boot, use:<br />
# systemctl enable vboxvmservice@''your_virtual_machine_name''<br />
<br />
To start the service that will launch directly the virtual machine, use:<br />
# systemctl start vboxvmservice@''your_virtual_machine_name''<br />
<br />
VirtualBox 4.2 introduces [http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/ a new way] for UNIX-like systems to have virtual machines started automatically, other than using a systemd service.<br />
<br />
==== 启动虚拟机键盘快捷键 ====<br />
<br />
It can be useful to start virtual machines directly with a keyboard shortcut instead of using the VirtualBox interface (GUI or CLI). For that, you can simply define key bindings in {{ic|.xbindkeysrc}}. Please refer to [[Xbindkeys]] for more details.<br />
<br />
Example, using the {{ic|Fn}} key of a laptop with an unused battery key ({{ic|F3}} on the computer used in this example):<br />
"VBoxManage startvm 'Windows 7'"<br />
m:0x0 + c:244<br />
XF86Battery<br />
<br />
{{Note|If you have a space in the name of your virtual machine, then enclose it with single apostrophes like made in the example just above.}}<br />
<br />
=== 在虚拟机中使用特定的设备 ===<br />
<br />
=== 使用 USB 摄像头 / 麦克风 ===<br />
<br />
{{Note|在遵照下列步骤前,你需要安装 VirtualBox 扩展包。详见 [[VirtualBox_Extras#Extension_pack]]。}}<br />
<br />
# 要确保没有在运行虚拟机,以及没有使用摄像头 / 麦克风。<br />
# 进入VirtualBox主界面并打开Arch系统的设置界面,到USB设备页。<br />
# 要确保勾选上“启用USB控制器”选项。 还要确保选择“启用USB 2.0(EHCI)控制器”选项。<br />
# 点击“从设备列表中添加筛选器”按钮 (就是那个有“+”图标的连接线).<br />
# 从列表中选择你的USB摄像头 / 麦克风设备。<br />
# 然后再点击OK,启动你的VM<br />
<br />
==== 获得可探测的Web-cam和其他USB设备====<br />
<br />
Make sure you filter any devices that are not a keyboard or a mouse so they do not start up at boot and this insures that Windows will detect the device at start-up.<br />
<br />
=== 访问guest 服务 ===<br />
<br />
To access [[Wikipedia:Apache_HTTP_Server|Apache server]] on a Virtual Machine from the host machine '''only''', simply execute the following lines on the host:<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/''pcnet''/0/LUN#0/Config/Apache/HostPort" ''8888''<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/''pcnet''/0/LUN#0/Config/Apache/GuestPort" ''80''<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/''pcnet''/0/LUN#0/Config/Apache/Protocol" TCP<br />
Where 8888 is the port the host should listen on and 80 is the port the VM will send Apache's signal on.<br />
<br />
To use a port lower than 1024 on the host machine, changes need to be made to the firewall on that host machine. This can also be set up to work with SSH or any other services by changing "Apache" to the corresponding service and ports. <br />
<br />
{{note|{{ic|pcnet}} refers to the network card of the VM. If you use an Intel card in your VM settings, change {{ic|pcnet}} to {{ic|e1000}}.}}<br />
<br />
To communicate between the VirtualBox guest and host using ssh, the server port must be forwarded under Settings > Network. When connecting from the client/host, connect to the IP address of the client/host machine, as opposed to the connection of the other machine. This is because the connection will be made over a virtual adapter.<br />
<br />
=== 在Windows客户端中激活D3D加速 ===<br />
<br />
Recent versions of Virtualbox have support for accelerating OpenGL inside guests. This can be enabled with a simple checkbox in the machine's settings, right below where video ram is set, and installing the Virtualbox guest additions. However, most Windows games use Direct3D (part of DirectX), not OpenGL, and are thus not helped by this method. However, it is possible to gain accelerated Direct3D in your Windows guests by borrowing the d3d libraries from Wine, which translate d3d calls into OpenGL, which is then accelerated. These libraries are now part of Virtualbox guest additions software. <br />
<br />
After enabling OpenGL acceleration as described above, reboot the guest into safe mode (press F8 before the Windows screen appears but after the Virtualbox screen disappears), and install Virtualbox guest additions, during install enable checkbox "Direct3D support". Reboot back to normal mode and you should have accelerated Direct3D. <br />
<br />
{{Note | This hack may or may not work for some games depending on what hardware checks they make and what parts of D3D they use.}}<br />
{{Note | This was tested on Windows XP, 7 and 8.1. If method does not work on your Windows version please add data here.}}<br />
<br />
=== 在USB key上使用VirtualBox===<br />
When using VirtualBox on a USB key, for example to start an installed machine with an ISO image, you will manually have to create VDMKs from the existing drives. However, once the new VMDKs are saved and you move on to another machine, you may experience problems launching an appropriate machine again. To get rid of this issue, you can use the following script to launch VirtualBox. This script will clean up and unregister old VMDK files and it will create new, proper VMDKs for you:<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
# Erase old VMDK entries<br />
rm ~/.VirtualBox/*.vmdk<br />
<br />
# Clean up VBox-Registry<br />
sed -i '/sd/d' ~/.VirtualBox/VirtualBox.xml<br />
<br />
# Remove old harddisks from existing machines<br />
find ~/.VirtualBox/Machines -name \*.xml | while read file; do<br />
line=`grep -e "type\=\"HardDisk\"" -n $file | cut -d ':' -f 1`<br />
if [ -n "$line" ]; then<br />
sed -i ${line}d $file<br />
sed -i ${line}d $file<br />
sed -i ${line}d $file<br />
fi<br />
sed -i "/rg/d" $file<br />
done<br />
<br />
# Delete prev-files created by VirtualBox<br />
find ~/.VirtualBox/Machines -name \*-prev -exec rm '{}' \;<br />
<br />
# Recreate VMDKs<br />
ls -l /dev/disk/by-uuid | cut -d ' ' -f 9,11 | while read ln; do<br />
if [ -n "$ln" ]; then<br />
uuid=`echo "$ln" | cut -d ' ' -f 1`<br />
device=`echo "$ln" | cut -d ' ' -f 2 | cut -d '/' -f 3 | cut -b 1-3`<br />
<br />
# determine whether drive is mounted already<br />
checkstr1=`mount | grep $uuid`<br />
checkstr2=`mount | grep $device`<br />
checkstr3=`ls ~/.VirtualBox/*.vmdk | grep $device`<br />
if [[ -z "$checkstr1" && -z "$checkstr2" && -z "$checkstr3" ]]; then<br />
VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/$device.vmdk -rawdisk /dev/$device -register<br />
fi<br />
fi<br />
done<br />
<br />
# Start VirtualBox<br />
VirtualBox<br />
</nowiki>}}<br />
Note that your user has to be added to the "disk" group to create VMDKs out of existing drives.<br />
<br />
=== Run a native Arch Linux installation inside VirtualBox ===<br />
<br />
If you have a dual boot system between Arch Linux and another operating system, it can become rapidly tedious to switch back and forth if you need to work in both. Also, by using virtual machines, you just have a tiny fragment of your computer power, which can cause issues when working on projects requiring performance.<br />
<br />
This guide will let you reuse, in a virtual machine, your native Arch Linux installation when you are running your second operating system. This way, you keep the ability to run each operating system natively, but have the option to run your Arch Linux installation inside a virtual machine.<br />
<br />
==== Make sure you have a persistent naming scheme ====<br />
<br />
Depending on your hard drive setup, device files representing your hard drives may appear differently when you will run your Arch Linux installation natively or in virtual machine. This problem occurs when using [[RAID#Implementation|FakeRAID]] for example. The fake RAID device will be mapped in {{ic|/dev/mapper/}} when you run your GNU/Linux distribution natively, while the devices are still accessible separately. However, in your virtual machine, it can appear without any mapping in {{ic|/dev/sdaX}} for example, because the drivers controlling the fake RAID in your host operating system (e.g. Windows) are abstracting the fake RAID device.<br />
<br />
To circumvent this problem, we will need to use an addressing scheme that is persistent to both systems. This can be achieved using [[Fstab#UUIDs|UUIDs]] in your {{ic|/etc/fstab}} file. Make sure your [[fstab]] file is using UUIDs, otherwise fix this issue. Read [[fstab]] and [[Persistent block device naming]].<br />
<br />
{{ic|/etc/fstab}} is not the only location where UUIDs are used. Bootloaders and boot managers make use of them too. Now, make sure these are really using UUIDs.<br />
<br />
; [[GRUB Legacy]]<br />
If you are still using the old [[GRUB Legacy]], maybe is it [[GRUB Legacy#Upgrading to GRUB2|time to upgrade]], since this package is now dropped from the official Arch Linux repositories. If you want to keep it, edit {{ic|/boot/grub/menu.lst}} and replace the {{ic|1=root=/dev/sdXX}} statement in your Arch Linux boot entry by the Linux UUID mapping in {{ic|/dev/disk/by-uuid/}} corresponding to your root partition.<br />
<br />
title Arch Linux<br />
root<br />
kernel /vmlinuz-linux root=''/dev/disk/by-uuid/0a3407de-014b-458b-b5c1-848e92a327a3'' ro vga=773<br />
initrd /initramfs-linux-vbox.img<br />
<br />
Repeat the process here, for the fallback entry.<br />
<br />
; [[GRUB]]<br />
If you are running the most recent version of [[GRUB]]; you have nothing to do. Yet another reason to upgrade to GRUB 2.<br />
<br />
{{Warning|<br />
* Make sure your host partition is only accessible in read only from your Arch Linux virtual machine, this will avoid risk of corruptions if you were to corrupt that host partition by writing on it due to lack of attention.<br />
* You should NEVER allow VirtualBox to boot from the entry of your second operating system, which, as a reminder, is used as the host for this virtual machine! Take thus a special care especially if your default boot loader/boot manager entry is your other operating system. Give a more important timeout or put it below in the order of preferences.}}<br />
<br />
==== Make sure your mkinitcpio image is correct ====<br />
<br />
Make sure your [[Mkinitcpio|mkinitcpio]] configuration uses the [[Mkinitcpio#HOOKS|HOOK]] {{ic|block}}:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
[...]<br />
HOOKS="base udev autodetect modconf ''block'' filesystems keyboard fsck"<br />
[...]}}<br />
<br />
If it is not present, add it and [[Mkinitcpio#Image creation and activation|regenerate your initramfs]]:<br />
<br />
# mkinitcpio -p linux<br />
<br />
==== Create a VM configuration to boot from the physical drive ====<br />
<br />
===== 创建一个原始只读磁盘的.vmdk映像 =====<br />
<br />
Now, we need to create a new virtual machine which will use a [https://www.virtualbox.org/manual/ch09.html#rawdisk RAW disk] as virtual drive, for that we will use a ~ 1Kio VMDK file which will be mapped to a physical disk. Unfortunately, VirtualBox does not have this option in the GUI, so we will have to use the console and use an internal command of {{ic|VBoxManage}}.<br />
<br />
Boot the host which will use the Arch Linux virtual machine. The command will need to be adapted according to the host you have.<br />
<br />
; On a GNU/Linux host:<br />
<br />
There is 3 ways to achieve this: login as root, changing the access right of the device with {{ic|chmod}}, adding your user to the {{ic|disk}} group. The latter way is the more elegant, let us proceed that way:<br />
<br />
# gpasswd -a ''your_user'' disk<br />
<br />
Apply the new group settings with:<br />
<br />
$ newgrp<br />
<br />
Now, you can use the command:<br />
<br />
$ VBoxManage internalcommands createrawvmdk -filename ''/path/to/file.vmdk'' -rawdisk ''/dev/sdb'' -register <br />
<br />
Adapt the above command to your need, especially the path and filename of the VMDK location and the raw disk location to map which contain your Arch Linux installation.<br />
<br />
; On a Windows host:<br />
<br />
Open a command prompt must be run as administrator. {{Tip|On Windows, open your start menu/start screen, type {{ic|cmd}}, and type {{ic|Ctrl+Shift+Enter}}, this is a shortcut to execute the selected program with admin rights.}}<br />
<br />
On Windows, as the disk filename convention is different from UNIX, use this command to determine what drives you have in your Windows system and their location:{{hc|# wmic diskdrive get name,size,model|<br />
Model Name Size<br />
WDC WD40EZRX-00SPEB0 ATA Device \\.\PHYSICALDRIVE1 4000783933440<br />
KINGSTON SVP100S296G ATA Device \\.\PHYSICALDRIVE0 96024821760<br />
Hitachi HDT721010SLA360 ATA Device \\.\PHYSICALDRIVE2 1000202273280<br />
Innostor Ext. HDD USB Device \\.\PHYSICALDRIVE3 1000202273280}}<br />
<br />
In this example, as the Windows convention is {{ic|\\.\PhysicalDriveX}} where X is a number from 0, {{ic|\\.\PHYSICALDRIVE1}} could be analogous to {{ic|/dev/sdb}} from the Linux disk terminology.<br />
<br />
To use the {{ic|VBoxManage}} command on Windows, you can either, change the current directory to your VirtualBox installation folder first with {{ic|cd C:\Program Files\Oracle\VirtualBox\}}<br />
<br />
# .\VBoxManage.exe internalcommands createrawvmdk -filename C:\file.vmdk -rawdisk \\.\PHYSICALDRIVE1<br />
<br />
or use the absolute path name: <br />
<br />
# "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands createrawvmdk -filename C:\file.vmdk -rawdisk \\.\PHYSICALDRIVE1<br />
<br />
; On another OS host:<br />
<br />
There are other limitations regarding the aforementioned command when used in other operating systems like OS X, please thus [https://www.virtualbox.org/manual/ch09.html#rawdisk read carefully the manual page], if you are concerned.<br />
<br />
===== 创建虚拟机配置文件 =====<br />
<br />
{{Note|<br />
* To make use of the VBoxManage command on Windows, you need to change the current directory to your VirtualBox installation folder first: cd C:\Program Files\Oracle\VirtualBox\.<br />
* Windows makes use of backslashes instead of slashes, please replace all slashes / occurrences by backslashes \ in the commands that follow when you will use them.}}<br />
<br />
After, we need to create a new machine (replace the ''VM_name'' to your convenience) and register it with VirtualBox.<br />
<br />
$ VBoxManage createvm -name ''VM_name'' -register<br />
<br />
Then, the newly raw disk needs to be attached to the machine. This will depend if your computer or actually the root of your native Arch Linux installation is on an IDE or a SATA controller.<br />
<br />
If you need an IDE controller:<br />
<br />
$ VBoxManage storagectl ''VM_name'' --name "IDE Controller" --add ide<br />
$ VBoxManage storageattach ''VM_name'' --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /path/to/file.vmdk<br />
<br />
otherwise:<br />
<br />
$ VBoxManage storagectl ''VM_name'' --name "SATA Controller" --add sata<br />
$ VBoxManage storageattach ''VM_name'' --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /path/to/file.vmdk<br />
<br />
While you continue using the CLI, it is recommended to use the VirtualBox GUI, to personalise the virtual machine configuration. Indeed, you must specify its hardware configuration as close as possible as your native machine: turning on the 3D acceleration, increasing video memory, setting the network interface, etc.<br />
<br />
==== Install the Guest Additions ====<br />
<br />
Finally, you may want to seamlessly integrate your Arch Linux with your host operating system and allow copy pasting between both OSes. Please refer to [[#Install the Guest Additions]] for that, since this Arch Linux virtual machine is basically an Arch Linux guest.<br />
<br />
{{Warning|For [[Xorg]] to work in natively and in the virtual machine, since obviously it will be using different drivers, it is best if there is no {{ic|/etc/X11/xorg.conf}}, so Xorg will pick up everything it needs on the fly. However, if you really do need your own Xorg configuration, maybe is it worth to set your default systemd target to {{ic|multi-user.target}} with {{ic|systemctl isolate graphical.target}} as root (more details at [[Systemd#Targets table]] and [[Systemd#Change current target]]). In that way, the graphical interface is disabled (i.e. Xorg is not launched) and after you logged in, you can {{ic|startx}}} manually with a custom {{ic|xorg.conf}}.}}<br />
<br />
=== 安装VirtualBox的本地Arch Linux系统 ===<br />
<br />
In some cases it may be useful to install a native Arch Linux system while running another operating system: one way to accomplish this is to perform the installation through VirtualBox on a [http://www.virtualbox.org/manual/ch09.html#rawdisk raw disk]. If the existing operating system is Linux based, you may want to consider following [[Install from Existing Linux]] instead.<br />
<br />
This scenario is very similar to [[#Run a native Arch Linux installation inside VirtualBox]], but will follow those steps in a different order: start by [[#Create a raw disk .vmdk image]], then [[#Create the VM configuration file]].<br />
<br />
Now, you should have a working VM configuration whose virtual VMDK disk is tied to a real disk. The installation process is exactly the same as the steps described in [[#Installation steps for Arch Linux guests]], but [[#Make sure you have a persistent naming scheme]] and [[#Make sure your mkinitcpio image is correct]].<br />
<br />
{{Warning|<br />
*For BIOS systems and MBR disks, do not install a bootloader inside your virtual machine, this will not work since the MBR is not linked to the MBR of your real machine and your virtual disk is only mapped to a real partition without the MBR.<br />
*For UEFI systems without [[Wikipedia:Compatibility Support Module#CSM|CSM]] and GPT disks, the installation will not work at all since:<br />
:*the [[Wikipedia:EFI System partition|ESP]] partition is not mapped to your virtual disk and Arch Linux requires to have the Linux kernel on it to boot as an EFI application (see [[EFISTUB]] for details);<br />
:*and the efivars, if you are installing Arch Linux using the EFI mode brought by VirtualBox, are not the one of your real system: the bootmanager entries will hence not be registered.<br />
*This is why, it is recommended to create your partitions in a native installation first, otherwize the partitions will not be taken into consideration in your MBR/GPT partition table.}}<br />
<br />
After completing the installation, boot your computer natively with an GNU/Linux installation media (whether it be Arch Linux or not), [[Beginner's Guide#Chroot and configure the base system|chroot]] into your installed Arch Linux installation and [[Beginner's Guide#Install and configure a bootloader|#Install and configure a bootloader]].<br />
<br />
=== 将本机Windows安装到虚拟机 ===<br />
<br />
If you want to migrate an existing native Windows installation to a virtual machine which will be used with VirtualBox on GNU/Linux, this use case is for you. This section only covers native Windows installation using the MSDOS/Intel partition scheme. Your Windows installation must reside on the first MBR partition for this operation to success. Operation for other partitions are available but have been untested (see [[#Known limitations]] for details).<br />
<br />
{{Warning|If you are using an OEM version of Windows, this process is unauthorized by the end user license license. Indeed, the OEM license typically states the Windows install is tied with the hardware together. Transferring a Windows install to a virtual machine removes this link. Make thus sure you have a full Windows install or a volume license model before continuing. If you have a full Windows license but the latter is not coming in volume, nor as a special license for several PCs, this means you will have to remove the native installation after the transfer operation has been achieved.}}<br />
<br />
A couple of tasks are required to be done inside your native Windows installation first, then on your GNU/Linux host.<br />
<br />
==== Tasks on Windows ====<br />
<br />
The first three following points comes from [https://www.virtualbox.org/wiki/Migrate_Windows#HAL this outdated VirtualBox wiki page], but are updated here.<br />
<br />
* Remove IDE/ATA controllers checks (Windows XP only): Windows memorize the IDE/ATA drive controllers it has been installed on and will not boot if it detects these have changed. The solution proposed by Microsoft is to reuse the same controller or use one of the same serial, which is impossible to achieve since we are using a Virtual Machine. [https://www.virtualbox.org/wiki/Migrate_Windows#HardDiskSupport MergeIDE], a German tool, developped upon another other solution proposed by Microsoft can be used. That solution basically consists in taking all IDE/ATA controller drivers supported by Windows XP from the initial driver archive (the location is hard coded, or specify it as the first argument to the {{ic|.bat}} script), installing them and registering them with the regedit database.<br />
<br />
* Use the right type of Hardware Abstraction Layer (old 32 bits Windows versions): Microsoft ships 3 default versions: {{ic|Hal.dll}} (Standard PC), {{ic|Halacpi.dll}} (ACPI HAL) and {{ic|Halaacpi.dll}} (ACPI HAL with IO APIC). Your Windows install could come installed with the first or the second version. In that way, please [https://www.virtualbox.org/manual/ch08.html#idp56927888 disable the ''Enable IO/APIC'' VirtualBox extended feature].<br />
<br />
* Disable any AGP device driver (only outdated Windows versions): If you have the files {{ic|agp440.sys}} or {{ic|intelppm.sys}} inside the {{ic|C:\Windows\SYSTEM32\drivers\}} directory, remove it. As VirtualBox uses a PCI virtual graphic card, this can cause problems when this AGP driver is used.<br />
<br />
* Create a Windows recovery disk: In the following steps, if things turn bad, you will need to repair your Windows installation. Make sure you have an install media at hand, or create one with ''Create a recovery disk'' from Vista SP1, ''Create a system repair disc'' on Windows 7 or ''Create a recovery drive'' on Windows 8.x).<br />
<br />
==== Tasks on GNU/Linux ====<br />
<br />
* Reduce the native Windows partition size to the size Windows actually needs with {{ic|ntfsresize}} available from {{Pkg|ntfs-3g}}. The size you will specify will be the same size of the VDI that will be created in the next step. If this size is too low, you may break your Windows install and the latter might not boot at all.<br />
<br />
:Use the {{ic|--no-action}} option first to run a test:<br />
:{{bc|# ntfsresize --no-action --size ''52Gi'' ''/dev/sda1''}}<br />
<br />
:If only the previous test succeeded, execute this command again, but this time without the aforementioned test flag.<br />
<br />
* Install VirtualBox on your GNU/Linux host (see [[#Installation steps for Arch Linux hosts]] if your host is Arch Linux).<br />
<br />
* Create the Windows disk image from the beginning of the drive to the end of the first partition where is located your Windows installation. Copying from the beginning of the disk is necessary because the MBR space at the beginning of the drive needs to be on the virtual drive along with the Windows partition. In this example two following partitions {{ic|sda2}} and {{ic|sda3}}will be later removed from the partition table and the MBR bootloader will be updated.<br />
<br />
:{{bc|<nowiki># sectnum=$(( $(cat /sys/block/''sda/sda1''/start) + $(cat /sys/block/''sda/sda1''/size) ))</nowiki>}}<br />
:Using {{ic|cat /sys/block/''sda/sda1''/size}} will output the number of total sectors of the first partition of the disk {{ic|sda}}. Adapt where necessary.<br />
<br />
:{{bc|<nowiki># dd if=''/dev/sda'' bs=512 count=$sectnum | VBoxManage convertfromraw stdin ''windows.vdi'' $(( $sectnum * 512 ))</nowiki>}}<br />
:We need to display the size in byte, {{ic|$(( $sectnum * 512 ))}} will convert the sector numbers to bytes.<br />
<br />
* Since you created your disk image as root, set the right ownership to the virtual disk image: {{bc|# chown ''your_user'':''your_group'' windows.vdi}}<br />
<br />
* Create your virtual machine configuration file and use the virtual disk created previously as the main virtual hard disk.<br />
<br />
* Try to boot your Windows VM, it may just work. First though remove and repair disks from the boot process as it may interfere (and likely will) booting into safe-mode.<br />
<br />
* Attempt to boot your Windows virtual machine in safe mode (press the F8 key before the Windows logo shows up)... if running into boot issues, read [[#Fix MBR and Microsoft bootloader]]. In safe-mode, drivers will be installed likely by the Windows plug-and-play detection mechanism [http://i.imgur.com/hh1RrSp.png view]. Additionally, install the VirtualBox Guest Additions via the menu ''Devices'' > ''Insert Guest Additions CD image...''. If a new disk dialog does not appear, navigate to the CD drive and start the installer manually.<br />
<br />
* You should finally have a working Windows virtual machine. Do not forget to read the [[#Known limitations]].<br />
<br />
==== 修复MBR和Microsoft引导 ====<br />
<br />
如果您的Windows虚拟机拒绝引导, 你可能需要修复你的虚拟机.<br />
<br />
*Boot a GNU/Live live distribution inside your virtual machine before Windows starts up.<br />
<br />
*Remove other partitions entries from the virtual disk MBR. Indeed, since we copied the MBR and only the Windows partition, the entries of the other partitions are still present in the MBR, but the partitions are not available anymore. Use {{ic|fdisk}} to achieve this for example.<br />
:{{bc|<nowiki>fdisk ''/dev/sda''<br />
Command (m for help): a<br />
Partition number (''1-3'', default ''3''): ''1''</nowiki>}}<br />
<br />
*Write the updated partition table to the disk (this will recreate the MBR) using the {{ic|m}} command inside {{ic|fdisk}}.<br />
<br />
*Use {{Pkg|testdisk}} (see [http://www.cgsecurity.org/index.html?testdisk.html here] for details) to add a generic MBR:<br />
:{{bc|# testdisk > ''Disk /dev/sda...''' > [Proceed] > [Intel] Intel/PC partition > [MBR Code] Write TestDisk MBR to first sector > Write a new copy of MBR code to first sector? (Y/n) > Y > Write a new copy of MBR code, confirm? (Y/N) > A new copy of MBR code has been written. You have to reboot for the change to take effect. > [OK]}}<br />
<br />
*With the new MBR and updated partition table, your Windows virtual machine should be able to boot. If you are still encountering issues, boot your Windows recovery disk from on of the previous step, and inside your Windows RE environment, execute the commands [http://support.microsoft.com/kb/927392 described here].<br />
<br />
==== 已知的限制====<br />
<br />
*Your virtual machine can sometimes hang and overrun your RAM, this can be caused by conflicting drivers still installed inside your Windows virtual machine. Good luck to find them!<br />
*Additional software expecting a given driver beneath may either not be disabled/uninstalled or needs to be uninstalled first as the drivers that are no longer available.<br />
*Your Windows installation must reside on the first partition for the above process to work. If this requirement is not met, the process might be achieved too, but this had not been tested. This will require either copying the MBR and editing in hexadecimal see [http://superuser.com/questions/237782/virtualbox-booting-cloned-disk/253417#253417 VirtualBox: booting cloned disk] or will require to fix the partition table [http://gparted.org/h2-fix-msdos-pt.php manually] or by repairing Windows with the recovery disk you created in a previous step. Let us consider our Windows installation on the second partition; we will copy the MBR, then the second partition where to the disk image. {{ic|VBoxManage convertfromraw}} needs the total number of bytes that will be written: calculated thanks to the size of the MBR (the start of the first partition) plus the size of the second (Windows) partition. {{ic|<nowiki>{ dd if=/dev/sda bs=512 count=$(cat /sys/block/sda/sda1/start) ; dd if=/dev/sda2 bs=512 count=$(cat /sys/block/sda/sda2/size) ; } | VBoxManage convertfromraw stdin windows.vdi $(( ($(cat /sys/block/sda/sda1/start) + $(cat /sys/block/sda/sda2/size)) * 512 ))</nowiki>}}.<br />
<br />
== 故障排除 ==<br />
<br />
=== modprobe Exec 格式错误 ===<br />
<br />
确认你使用的是最新系统:<br />
pacman -Syu<br />
<br />
<br />
=== VERR_ACCESS_DENIED ===<br />
<br />
To access the raw vmdk image on a windows host, run the VirtualBox GUI as administrator.<br />
<br />
=== 键盘和鼠标都在我的虚拟机 ===<br />
<br />
This means your virtual machine has captured the input of your keyboard and your mouse. Simply press the right {{ic|Ctrl}} key and your input should control your host again.<br />
<br />
To control transparently your virtual machine with your mouse going back and forth your host, without having to press any key, and thus have a seamless integration, install the guest additions inside the guest. Read from the [[#Install the Guest Additions]] step if you guest is Arch Linux, otherwise read the official VirtualBox help.<br />
<br />
=== 无法发送CTRL + ALT+ Fn键到我的虚拟机 ===<br />
<br />
Your guest operating system is a GNU/Linux distribution and you want to open a new TTY shell by hitting {{ic|Ctrl+Alt+F2}} or exit your current X session with {{ic|Ctrl+Alt+Backspace}}. If you type these keyboard shortcuts without any adaptation, the guest will not receive any input and the host (if it is a GNU/Linux distribution too) will intercept these shortcut keys. To send {{ic|Ctrl+Alt+F2}} to the guest for example, simply hit your ''Host Key'' (usually the right {{ic|Ctrl}} key) and press {{ic|F2}} simultaneously.<br />
<br />
=== 解决ISO映像问题===<br />
<br />
While VirtualBox can mount ISO images without problem, there are some image formats which cannot reliably be converted to ISO. For instance, ccd2iso ignores .ccd and .sub files, which can give disk images with broken files. <br />
<br />
In this case, you will either have to use [[CDEmu]] for Linux inside VirtualBox or any other utility used to mount disk images.<br />
<br />
=== VirtualBox的GUI没有应用我的GTK主题===<br />
<br />
See [[Uniform Look for Qt and GTK Applications]] for information about theming Qt based applications like Virtualbox.<br />
<br />
===OpenBSD系统无法使用时,虚拟化指令不可用 ===<br />
<br />
While OpenBSD is reported to work fine on other hypervisors without virtualisation instructions (VT-x AMD-V) enabled, an OpenBSD virtual machine running on VirtualBox without these instructions will be unusable, manifesting with a bunch of segmentation faults. Starting VirtualBox with the ''-norawr0'' argument [https://www.virtualbox.org/ticket/3947 may solve the problem]. You can do it like this:<br />
$ VBoxSDL -norawr0 -vm ''name_of_OpenBSD_VM''<br />
<br />
=== VBOX_E_INVALID_OBJECT_STATE (0x80BB0007) ===<br />
这种情形可能会在虚拟机没有正常退出时发生,解除锁定虚拟机并不难: <br />
$ VBoxManage controlvm ''virtual_machine_name'' poweroff<br />
<br />
=== USB 子系统在宿主机和虚拟机没有作用 ===<br />
<br />
Your user must be in the {{ic|vboxusers}} group, and you need to install the [[#Extension pack|extension pack]] if you want USB 2 support. Then you will be able to enable USB 2 in the VM settings and add one or several filters for the devices you want to access from the guest OS.<br />
<br />
Sometimes, on old Linux hosts, the USB subsystem is not auto-detected resulting in an error {{ic|Could not load the Host USB Proxy service: VERR_NOT_FOUND}} or in a not visible USB drive on the host, [https://bbs.archlinux.org/viewtopic.php?id=121377 even when the user is in the '''vboxusers''' group]. This problem is due to the fact that VirtualBox switched from ''usbfs'' to ''sysfs'' in version 3.0.8. If the host does not understand this change, you can revert to the old behaviour by defining the following environment variable in any file that is sourced by your shell (e.g. your {{ic|~/.bashrc}} if you are using ''bash''):<br />
<br />
{{hc|~/.bashrc|VBOX_USB<nowiki>=</nowiki>usbfs}}<br />
<br />
Then make sure, the environment has been made aware of this change (reconnect, source the file manually, launch a new shell instance or reboot).<br />
<br />
Also make sure that your user is a member of the {{ic|storage}} group.<br />
<br />
=== 主机模式网络接口创建失败 ===<br />
<br />
Make sure all required kernel modules are loaded. See [[#Load the VirtualBox kernel modules]].<br />
<br />
To be able to create a Host-Only Network Adapter or a Bridged Network Adapter the kernel modules {{ic|vboxnetadp}} and {{ic|vboxnetflt}} need to be loaded, you also need to make sure the {{pkg|net-tools}} package is installed. It's possible to load these kernel modules manually with<br />
<br />
# modprobe -a vboxnetadp vboxnetflt<br />
<br />
若要开机自动加载,每个模块添加一行到 {{ic|/etc/modules-load.d/virtualbox.conf}}:<br />
<br />
vboxdrv<br />
vboxnetadp<br />
vboxnetflt<br />
<br />
{{Note|以前这些都要添加到 {{ic|/etc/rc.conf}} 的 {{ic|MODULES}} 数组,现此方法已过时。}}<br />
<br />
更多信息请看[https://bbs.archlinux.org/viewtopic.php?id=130581 这个]主题。<br />
<br />
=== WinXP: 位深不能大于 16 ===<br />
<br />
若你运行于 16 位色深,图标可能看起来糊糊的。但是当你试图调到更高色深,系统可能会受限于较低的分辨率,甚至根本不允许更改色深。若要修正此问题,运行 {{ic|regedit}} 并添加下列键值到虚拟 XP 注册表:<br />
<br />
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]<br />
"ColorDepth"=dword:00000004<br />
<br />
接著在桌面属性窗口改变色深。若没有反应,可透过一些方法强制屏幕重绘 (按下 {{ic|Host+F}} 重绘/进入全屏)。<br />
<br />
=== 虚拟系统使用串行端口 ===<br />
确认你的串行端口权限<br />
$ /bin/ls -l /dev/ttyS*<br />
crw-rw---- 1 root uucp 4, 64 Feb 3 09:12 /dev/ttyS0<br />
crw-rw---- 1 root uucp 4, 65 Feb 3 09:12 /dev/ttyS1<br />
crw-rw---- 1 root uucp 4, 66 Feb 3 09:12 /dev/ttyS2<br />
crw-rw---- 1 root uucp 4, 67 Feb 3 09:12 /dev/ttyS3<br />
<br />
添加你的用户到 {{ic|uucp}} 组。<br />
# gpasswd -a $USER uucp <br />
然后重新登陆。<br />
<br />
=== Windows 8.x Error Code 0x000000C4===<br />
<br />
If you get this error code while booting, even if you choose OS Type Win 8, try to enable the {{ic|CMPXCHG16B}} CPU instruction:<br />
<br />
$ vboxmanage setextradata ''virtual_machine_name'' VBoxInternal/CPUM/CMPXCHG16B 1<br />
<br />
=== Windows 8 VM fails to boot with error "ERR_DISK_FULL" ===<br />
<br />
Situation: Your Windows 8 VM refuses to start. VirtualBox throws an error stating the virtual disk is full. However, you are certain that the disk is not full. <br />
Bring up your VM's settings at ''Settings > Storage > Controller:SATA'' and select "Use Host I/O Cache".<br />
<br />
=== Linux guests have slow/distorted audio ===<br />
<br />
The AC97 audio driver within the Linux kernel occasionally guesses the wrong clock settings when running inside Virtual Box, leading to audio that is either too slow or too fast. To fix this, create a file in {{ic|/etc/modprobe.d}} with the following line:<br />
<br />
options snd-intel8x0 ac97_clock=48000<br />
<br />
=== 客户端启动后的Xorg死机 ===<br />
<br />
Faulty or missing drivers may cause the guest to freeze after starting Xorg, see for example [https://bbs.archlinux.org/viewtopic.php?pid=1167838] and [https://bbs.archlinux.org/viewtopic.php?id=156079]. Try disabling 3D acceleration in ''Settings > Display'', and check if all [[Xorg]] drivers are installed.<br />
<br />
=== "NS_ERROR_FAILURE" and missing menu items ===<br />
<br />
If you encounter this message when first time starting the virtual machine:<br />
<br />
{{bc|Failed to open a session for the virtual machine debian.<br />
Could not open the medium '/home/.../VirtualBox VMs/debian/debian.qcow'.<br />
QCow: Reading the L1 table for image '/home/.../VirtualBox VMs/debian/debian.qcow' failed (VERR_EOF).<br />
VD: error VERR_EOF opening image file '/home/.../VirtualBox VMs/debian/debian.qcow' (VERR_EOF).<br />
<br />
Result Code: <br />
NS_ERROR_FAILURE (0x80004005)<br />
Component: <br />
Medium<br />
}}<br />
<br />
Exit VirtualBox, delete all files of the new machine and from virtualbox config file remove the last line in {{ic|MachineRegistry}} menu (or the offending machine you are creating):<br />
<br />
{{hc|~/.config/VirtualBox/VirtualBox.xml|2=<br />
...<br />
<MachineRegistry><br />
<MachineEntry uuid="{00000000-0000-0000-0000-000000000000}" src="/home/void/VirtualBox VMs/debian/debian.vbox"/><br />
<MachineEntry uuid="{00000000-0000-0000-0000-000000000000}" src="/home/void/VirtualBox VMs/ubuntu/ubuntu.vbox"/><br />
<strike><MachineEntry uuid="{00000000-0000-0000-0000-000000000000}" src="/home/void/VirtualBox VMs/lastvmcausingproblems/lastvmcausingproblems.qcow"/></strike><br />
</MachineRegistry><br />
...<br />
}}<br />
<br />
This happens sometimes when selecting ''QCOW''/''QCOW2''/''QED'' disk format when creating a new virutal disk.<br />
<br />
=== USB modem ===<br />
<br />
If you have a USB modem which is being used by the guest OS, killing the guest OS can cause the modem to become unusable by the host system. Killing and restarting {{ic|VBoxSVC}} should fix this problem.<br />
<br />
=== "The specified path does not exist. Check the path and then try again." error in Windows guests ===<br />
<br />
This error message often appears when running an .exe file which requires administrator priviliges from a shared folder in windows guests. See [https://www.virtualbox.org/ticket/5732 the bug report] for details.<br />
<br />
There are several workarounds:<br />
<br />
# Disable UAC from Control Panel -> Action Center -> "Change User Account Control settings" from left side pane -> set slider to "Never notify" -> OK and reboot<br />
# Copy the file from the shared folder to the guest and run from there<br />
# Control Panel -> Network and Internet -> Internet Options -> Security -> Trusted Sites -> Sites -> Add "VBOXSVR" as a website<br />
# Start -> type "gpedit.msc" and press Enter -> Computer Configuration -> Administrative Templates -> Windows Components -> Internet Explorer -> Internet Control Panel -> Security Page -> Size to Zone Assignment List -> Add "VBOXSVR" to "2" and reboot<br />
<br />
{{Accuracy|Haven't tested#3 and #4 workarounds myself. If someone can confirm that they are working as well, please delete this note/template.}}<br />
<br />
=== 挂载失败导致的啟动问题 ===<br />
<br />
若你在内核升级后 [[systemd]] 设定遇到问题,你应该透过 {{ic|1=init=/bin/bash}} 开啟系统 (如果应急 shell 对你没有作用)。<br />
<br />
root=/dev/mapper/vg_main-lv_root ro vga=792 resume=/dev/mapper/vg_main-lv_swap init=/bin/bash<br />
<br />
接著附加写入权限挂载 ''root''-文件系统:<br />
<br />
# mount / -o remount,rw<br />
<br />
根据 [[#Arch Linux 客户机共享文件夹]] 更改 {{ic|/etc/fstab}}]],然后在 Bash shell 运行 systemd:<br />
<br />
# exec /bin/systemd<br />
<br />
=== 复制和粘贴在 Arch Linux 客户机没有作用 ===<br />
<br />
Since updating {{ic|virtualbox-guest-additions}} to version {{ic|4.2.0-2}} copy&paste from Host OS to Arch Linux Guest stopped working. It seems to be due to {{ic|VBoxClient-all}} requiring ''root'' access. In previous versions adding ''VBoxClient-all &'' to ''~/.xinitrc'' was sufficient to make copy&paste work. Update ''~/.xinitrc'' to match {{ic|sudo VBoxClient-all &}} and add the line {{ic|, NOPASSWD: /usr/bin/VBoxClient-all}} to your username in the sudoers file and restart X. It should all work again. The line in the sudoers file should look similar to this:<br />
<br />
# Allow sudo for user 'you' and let him run VBoxClient-all without requiring a password<br />
you ALL = PASSWD: ALL, NOPASSWD: /usr/bin/VBoxClient-all<br />
<br />
{{Note|使用 {{ic|visudo}} 编辑 sudoer 文件,这会在存储时检查语法错误。}}<br />
<br />
=== 唤醒后异常 ===<br />
有个已知臭虫导致唤醒后异常: https://www.virtualbox.org/ticket/11289。避开的方法很简单: 每次都按 Host+q 或菜单关闭虚拟机。<br />
<br />
=== Btrfs 系统镜像 ===<br />
In 2010 there were reports that OS disk images would not start if they were attached via a virtual SATA device. It was reportedly fixed, and seemed to be. But as of around March 2013, that particular bug report has been [https://www.virtualbox.org/ticket/6905 repoened]. This can be fixed by enabling the use of the host I/O cache, which is disabled by default with virtual SATA interfaces.<br />
<br />
=== vagrant 啟动问题 ===<br />
在最新版的 VirtualBox(4.2.14-1),运行 {{ic|vagrant up}} 命令伴随以下错误:<br />
<br />
Command: ["import",<br />
"/Users/username/.vagrant.d/boxes/precise32/virtualbox/box.ovf"]<br />
Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%<br />
Interpreting<br />
/Users/username/.vagrant.d/boxes/precise32/virtualbox/box.ovf...<br />
OK.<br />
0%...<br />
Progress object failure: NS_ERROR_CALL_FAILED<br />
<br />
在[https://www.virtualbox.org/ticket/11895 这个修正]释出前,你需要使用其它方法解决,或是将 VirtualBox 降级。<br />
<br />
有个临时的解决方法是在 {{ic|~/.vagrant.d/boxes/BoxName/virtualbox}} 為每个 box 创建 manifest:<br />
<br />
openssl sha1 *.vmdk *.ovf > box.mf<br />
<br />
你可以降级 VirtualBox。若你的缓存有旧的软件包,可以透过下列命令降级:<br />
<br />
sudo pacman -U /var/cache/pacman/pkg/virtualbox-4.2.12-3-x86_64.pkg.tar.xz<br />
<br />
这个错误似乎同时出现在所有平台: http://www.marshut.com/pzisi/progress-object-failure-ns-error-call-failed-when-running-vagrant-up-in-getting-started-guide.html#qhihz<br />
<br />
It's unclean for the moment. It could be regression inside Virtualbox or a issue inside Vagrant. When you delete the cache you can downgrade via ArchLinux [https://aur.archlinux.org/packages/downgrader/ downgrader ] (I did not test it correctly, but I assume this works, else<br />
check the wiki page for downgrading: [[Downgrading packages]]<br />
<br />
更多信息请到 GitHub issue 页面查看 [https://github.com/mitchellh/vagrant/issues/1847 Clean install on OS X 10.8.4 w/ latest VirtualBox not working]<br />
<br />
根据 [https://twitter.com/mitchellh/status/348886504728305664 Vagrant creator on Twitter],这是 VirtualBox 的臭虫。在 2013 年 06 月 25 日,他说他们在 SVN 修正此臭虫,并且正在等待释出。同时,我可以确认这是跨平台的问题,4.2.14 在我的 Win7 上面是坏的。<br />
<br />
这个问题在 virtualbox-4.2.16-1 这份 VirtualBox 版本释出时已解决<br />
<br />
=== 没有64位客户端选项 ===<br />
<br />
When launching a VM client, and no 64-bit options are available, make sure your CPU virtualization capabilities (usually named {{ic|VT-x}}) are enabled in the BIOS.<br />
<br />
=== 主机上的虚拟机启动操作系统死机===<br />
<br />
{{Expansion|Needs a link to a bug report; vague expressions like "currently" and "at the moment of writing" are of no help.}}<br />
<br />
This is a known incompatiblity with SMAP enabled kernels affecting (mostly) Intel Broadwell chipsets.<br />
<br />
The matter is currently being investigated, with a wide variety of WIP vboxhost module patches out in the wild that are meant to solve the issue.<br />
<br />
At the moment of writing though, the only 100% guaranteed solution to this problem is disabling SMAP support in your kernel by appending the "nosmap" option to your kernel boot command line.<br />
<br />
<br />
===向客户端发送CTRL+ALT+F1===<br />
如果你的客户端操作系统是Linux发行版,且你又想打开一个新的tty文本shell或者通过键入{{ic|Ctrl}}+{{ic|Alt}}+{{ic|F1}}来退出 X ,你可以简单地敲击你的'Host Key'向客户端操作系统发送这个命令(通常为键盘右边的{{ic|Ctrl}}) + {{ic|F1}} 或 {{ic|F2}},以此类推。<br />
<br />
===在运行于无显示器的服务器上的系统上启动虚拟机===<br />
Add this line to /etc/rc.local<br />
exec /bin/su -c 'VBoxManage startvm --type headless <''UUID|NAME''>' ''PREFERED_USER'' >/dev/null 2>&1<br />
Where <UUID|NAME> is the guest identifier, and PREFERRED_USER is the user profile that contains the VM definitions and .vdi files.<br />
<br />
Since exec replaces the currently running process, you will not be able to start a second VM, or execute any other commands, after the exec. Try the following if this is a problem:<br />
su -c 'VBoxHeadless -s <''UUID|NAME''> &' -s /bin/sh ''PREFERED_USER'' >/dev/null 2>&1<br />
Using fully qualified path to su and VBoxHeadless is recommend. Add additional lines like above to start additional VMs. Commands following these in rc.local will be executed. Based on some rooting around in the VBox documentation, I get the impression this will be a little more robust than 'VBoxManage ... --type headless' in future VBox releases.<br />
<br />
To determine the available VMs for a user:<br />
su -c 'VBoxManage list vms' PREFERED_USER<br />
<br />
To save the state of a running VM:<br />
su -c 'VBoxManage controlvm <UUID|NAME> savestate' PREFERED_USER<br />
rc.local.shutdown would be a good spot for this.<br />
<br />
===从主机端访问虚拟机上的服务器===<br />
To access apache on a VM from the Host machine ONLY, simply execute the following lines on the Host:<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8888<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80<br />
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP<br />
Where 8888 is the port the host should listen on and 80 is the port the VM will send Apache's signal on. <br />
To use a port lower than 1024 on the host machine changes need to be made to the firewall on the host machine. This can also be set up to work with SSH, etc.. by changing "Apache" to whatever service and using different ports. <br />
<br />
Note: "pcnet" refers to the network card of the VM. If you use an Intel card in your VM settings change "pcnet" to "e1000"<br />
<br />
*from [http://mydebian.blogdns.org/?p=111 ]<br />
<br />
It might also be necessary to allow connections from the outside to the server in your VM. E.g. if the guest OS is Arch, you may want to add the line <br />
httpd: ALL<br />
to your /etc/hosts.allow file.<br />
<br />
===守护进程工具===<br />
While VirtualBox can mount ISO images without a problem, there are some image formats which cannot reliably be converted to ISO. For instance, ccd2iso ignores .ccd and .sub files, which can give disk images with broken files. cdemu, fuseiso, and MagicISO will do the same. In this case there is no choice but to use Daemon Tools inside VirtualBox.<br />
<br />
Recent Daemon Tools versions won't install, so use this old one: [http://www.disc-tools.com/download/daemon347+hashcalc]<br />
<br />
== 参阅 ==<br />
<br />
* [https://www.virtualbox.org/manual/UserManual.html VirtualBox User Manual]<br />
* [[Wikipedia:VirtualBox]]</div>无极