<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=D-demirci</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=D-demirci"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/D-demirci"/>
	<updated>2026-05-06T03:23:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_Up_Apache_with_PHP&amp;diff=18674</id>
		<title>Setting Up Apache with PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_Up_Apache_with_PHP&amp;diff=18674"/>
		<updated>2021-03-01T13:56:45Z</updated>

		<summary type="html">&lt;p&gt;D-demirci: /* Installing Apache + PHP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing Apache + PHP ==&lt;br /&gt;
&lt;br /&gt;
Enable the repositories:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
cat &amp;gt; /etc/apk/repositories &amp;lt;&amp;lt; EOF&lt;br /&gt;
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d&#039;.&#039; -f1,2)/main&lt;br /&gt;
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d&#039;.&#039; -f1,2)/community&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
apk update&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the main packages with the command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;export phpverx=$(alpinever=$(cat /etc/alpine-release|cut -d &#039;.&#039; -f1);[ $alpinever -ge 9 ] &amp;amp;&amp;amp; echo  7|| echo 5)&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
{{Cmd|apk add apache2 php$phpverx-apache2}}&lt;br /&gt;
&lt;br /&gt;
If you get an exception like unsatisfible dependency use the above command like this:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;export phpverx=$(alpinever=$(cat /etc/alpine-release);[ ${alpinever//./} -ge 309 ] &amp;amp;&amp;amp; echo  7|| echo 5)&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
then&lt;br /&gt;
{{Cmd|apk add apache2 php$phpverx-apache2}}&lt;br /&gt;
or just change {{Cmd| -f1 to -f2 }} in the original command.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;php&amp;quot;$phpverx&amp;quot;-apache2&amp;lt;/code&amp;gt; will be &amp;quot;5&amp;quot; or &amp;quot;7&amp;quot; depending of the alpine version installed, since alpine 3.9 there&#039;s only the php7 packages.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Move to the directory where your site will reside:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|cd /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
And create an index.php file to test if everything is ok:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vi index.php}}&lt;br /&gt;
&lt;br /&gt;
Add the following lines in the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That done, let us start apache2 web server:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service apache2 start}}&lt;br /&gt;
&lt;br /&gt;
Now access: http://&amp;lt;ip_address&amp;gt; and if everything is ok you will see the PHP info page.&lt;br /&gt;
&lt;br /&gt;
== Ending ==&lt;br /&gt;
&lt;br /&gt;
Finally let us set up apache2 to start on operating system startup:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add apache2}}&lt;br /&gt;
&lt;br /&gt;
Now you can create your PHP site and host in this directory.&lt;br /&gt;
&lt;br /&gt;
== Note ==&lt;br /&gt;
This is the easiest way to setup Apache with PHP support, but it&#039;s the most inefficient (resource wise) setup, please refer to [[Apache with php-fpm]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server]]&lt;br /&gt;
[[Category:PHP]]&lt;/div&gt;</summary>
		<author><name>D-demirci</name></author>
	</entry>
</feed>