PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
Install the package.
Due to application software that cannot use the latest PHP version, you may install actively supported PHP branch and must be configured within the applications that require it. For detailed instruction, see Nextcloud#Migrating_to_php-legacy.alongside. That package provides the oldest still
You can find older and pinned versions of PHP in the AUR, including openSUSE Build Service.AUR, AUR, AUR, AUR, AUR, AUR, AUR, AUR, AUR, AUR and AUR. Those are binary builds using the
While PHP can be run standalone, it is typically used with web servers. That requires installing additional packages and editing configuration files. For common setups, see the following:
To run PHP scripts as plain CGI, you need thepackage.
The main PHP configuration file is well-documented and located at
- It is recommended to set your timezone (list of timezones) in
date.timezone = Europe/Berlin
- If you want to display errors to debug your PHP code, change
display_errors = On
- The open_basedir directive limits the paths that can be accessed by PHP, thus increasing security at the expense of potentially interfering with normal program execution. Starting with PHP 7.0, it is no longer set by default to more closely match upstream so users who wish to use it must configure it manually. All symbolic links are resolved, so it is not possible to avoid this restriction with a symlink. The default Arch packages for certain webapps like
phpmyadmininstalls the webapps under
/usr/share/webappsand creates a symlink pointing to the actual configuration files for those webapps under
/etc/webapps. So, if you are setting up
open_basedir, make sure both those folders listed are in the
open_basedir. This will obviously be different for webapps installed in other locations. Example:
open_basedir = /srv/http/:/var/www/:/home/:/tmp/:/var/tmp/:/var/cache/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/
A number of commonly used PHP extensions can also be found in the official repositories:
$ pacman -Ss php-
/etc/php/php.ini, an extension may be enabled/configured in the
/etc/php/conf.ddirectory instead (e.g.
Existing extensions are located in
For example, to enable
ext-iconv extension create file
/etc/php/conf.d/extensions.ini with line:
Extensions for current and older versions of PHP are also available in the AUR under prefixes like php- and php56-, e.g. , , AUR.
Install the package and install one of the listed PHP extension library.
/etc/php/conf.d/imagick.ini to configure the extension.
If you want imagemagick to have SVG support, e.g. for nextcloud, then install} as a dependency.
Make sure theAUR package has been installed:
# pecl install imagick
/etc/php/conf.d/imagick.ini and enable the extension:
If you wish to have POSIX multi-threading you will need the parallel extension. To install the extension using
pecl you are required to use a compiled version of PHP with the the thread safety support flag
--enable-maintainer-zts. Currently the most clean way to do this would be to rebuild the original package with the flag. Instruction can be found on the PHP pthreads extension page.
PCNTL allows you to create process directly into the server side machine. While this may seen as something you would want, it also gives PHP the power to mess things up really badly. 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 PCNTL has to be compiled into PHP.
The php package on Arch Linux is currently built with "--enable-pcntl", so that it should be available by default.
Install and configure MySQL/MariaDB as described in MariaDB.
Uncomment the following lines in
extension=mysqlwas removed in PHP 7.0.
You can add minor privileged MySQL users for your web scripts. You might also want to edit
/etc/my.cnf.d/server.cnf and add in mysqld section
skip-networking line so the MySQL server is only accessible by the localhost, as per MariaDB#Enable access locally only via Unix sockets. You have to restart MySQL for changes to take effect.
Install and configure Redis, then install .
Uncomment the line of the package, e.g.
Also ensure that the igbinary extension is enabled (also uncommented) in
Install and configure PostgreSQL, then install the package and uncomment the following lines in
Install and configure SQLite, then install the package and uncomment the following lines in
XDebug allows you to easily debug (using modified var_dump function), profile, or trace PHP code.
You can configure what XDebug does by adding a xdebug.mode line to the same file. By default, it is set to
xdebug.remote_autostart=on. For Xdebug 3 the default port is 9003, to change it set
Install broken link: package not found] and uncomment the line at
/etc/php/conf.d/snuffleupagus.ini, and put the path to the
snuffleupagus.rules file in the second line:
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.
OPCache comes bundled with the standard PHP distribution, therefore to enable it you simply have to add or uncomment the following line in your PHP configuration file:
A list of its options and suggested settings can be found in its official entry on the PHP website.
zend_mm_heap corruptedbeing produced.
APCu can be installed with the
/etc/php/conf.d/apcu.ini, or adding it to your PHP configuration file:
Its author recommends a few suggested settings, among which:
apc.shm_size=32Mare not really required as they represent the default values;
apc.ttl=7200on the other hand seems rather beneficial;
apc.enable_cli=1, which although not recommended by the manual may be required by some software such as ownCloud.
/etc/php/conf.d/apcu.inior directly to your PHP configuration file. Just make sure not to enable the extension twice as it will result in errors being diplayed in the system logs.
- Visual Studio Code — Code Editor for programming PHP and other languages.
- Aptana Studio — IDE for programming in PHP and web development. Does not have a PHP debugger.
- Eclipse PDT — The PHP variant of Eclipse.
- https://www.eclipse.org/pdt/ || AUR
- http://komodoide.com/ || AUR, editor only: AUR
- Netbeans — IDE for many languages including PHP. Includes features like debugging, refactoring, code templating, autocomplete, XML features, and web design and development functionalities.
- JetBrains PhpStorm — Commercial, cross-platform IDE for PHP built on JetBrains' IntelliJ IDEA platform. You can get a free license for education from Jetbrains..
- https://www.jetbrains.com/phpstorm/ || AUR, 30-day trial: AUR
- Zend Studio — 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.
Composer is a dependency manager for PHP. It can be installed with the package.
Allow user-wide installations
Box is an application for building and managing Phars. It can be installed with the AUR package.
PHP Depend (pdepend) is software metrics tool for php. It can be installed with the AUR package.
PHP Coding Standards Fixer
PHP Coding Standards Fixer is a PSR-1 and PSR-2 Coding Standards fixer for your code. It can be installed with the AUR package.
phpcov is a command-line frontend for the PHP_CodeCoverage library. It can be installed with the AUR package.
phpDox is the documentation generator for PHP projects. This includes, but is not limited to, API documentation. It can be installed with the AUR package.
PHPLoc is a tool for quickly measuring the size of a PHP project. It can be installed with the AUR package.
PhpMetrics provides various metrics about PHP projects. It can be installed with the AUR package.
phptok is a tool for quickly dumping the tokens of a PHP sourcecode file. It can be installed with the AUR package.
PHPUnit is a programmer-oriented testing framework for PHP. It can be installed with the AUR package.
PHPUnit Skeleton Generator
PHPUnit Skeleton Generator is a tool that can generate skeleton test classes from production code classes and vice versa. It can be installed with the AUR package.
Producer is a command-line quality-assurance tool to validate, and then release, your PHP library package. It can be installed with the AUR package.
PHP Fatal error: Class 'ZipArchive' not found
Ensure the zip extension is enabled.
/etc/php/php.ini not parsed
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
/etc/php/php-uwsgi.ini. If you are using cli, it is
PHP Warning: PHP Startup: <module>: Unable to initialize module
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.
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
To fix, find a compatible update for your module, probably by looking up the AUR using its common name.
If it applies, flag the outdated AUR package as outdated.