https://wiki.archlinux.org/api.php?action=feedcontributions&user=Burra&feedformat=atomArchWiki - User contributions [en]2024-03-28T20:09:34ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Apache_HTTP_Server&diff=58291Apache HTTP Server2009-01-18T09:48:19Z<p>Burra: /* PHP */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|LAMP}}<br />
{{i18n_entry|Español|LAMP (Español)}}<br />
{{i18n_entry|Italiano|LAMP (Italiano)}}<br />
{{i18n_entry|Türkçe|LAMP_(Türkçe)}}<br />
{{i18n_entry|Русский|LAMP (russian)}}<br />
{{i18n_entry|Česky|LAMP_(Česky)}}<br />
{{i18n_entry|简体中文|LAMP(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
== Introduction ==<br />
This document describes how to set up the Apache web server on an Arch Linux system. It also tells how to optionally install PHP and MySQL and integrate these in the Apache server. This combination is commonly referred to as LAMP (Linux Apache MySQL PHP).<br />
<br />
== Installation ==<br />
# pacman -S apache php mysql<br />
<br />
This document assumes you will install Apache, PHP and MySQL together. If desired however, you may install Apache, PHP, and MySQL separately and simply refer to the relevant sections below.<br />
{{Box Note | New default user and group: Instead of group "nobody" apache now runs as user/group "http" by default. You might want to adjust your httpd.conf according to this change, though you may still run httpd as nobody.}}<br />
<br />
== Configuration ==<br />
=== Apache ===<br />
* Create the user http (this account may already exist):<br />
# useradd http<br />
* Add this line to <code>/etc/hosts</code> (if the file doesn't exist, create it):<br />
127.0.0.1 localhost.localdomain localhost<br />
'''Note:''' If you want a different hostname, append it to the end:<br />
127.0.0.1 localhost.localdomain localhost myhostname<br />
<br />
* Edit <code>/etc/rc.conf</code>: If you set a hostname, the HOSTNAME variable should be the same; otherwise, use "localhost":<br />
#<br />
# Networking<br />
#<br />
HOSTNAME="localhost"<br />
<br />
* Edit <code>/etc/httpd/conf/httpd.conf</code> as root and comment the following module:<br />
LoadModule unique_id_module modules/mod_unique_id.so<br />
It should now appear as:<br />
#LoadModule unique_id_module modules/mod_unique_id.so<br />
<br />
* Run the following in a terminal as root to start the http server:<br />
# /etc/rc.d/httpd start<br />
<br />
* Apache should now be running. Test by visiting http://localhost/ in a web browser. It should display a simple Apache test page.<br />
<br />
* To start Apache automatically at boot, edit <code>/etc/rc.conf</code> as root and add the '''httpd''' daemon:<br />
DAEMONS=(... '''httpd''' ...)<br />
'''Or''' add this line to <code>/etc/rc.local</code>:<br />
/etc/rc.d/httpd start<br />
<br />
* If you want to use user directories (i.e. <code>~/public_html</code> on the machine is accessed as <code>http://localhost/~user/</code>) to be available on the web, uncomment the following lines in <code>/etc/httpd/conf/extra/httpd-userdir.conf</code>:<br />
UserDir public_html<br />
and<br />
<Directory /home/*/public_html><br />
AllowOverride FileInfo AuthConfig Limit Indexes<br />
Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI<br />
<Limit GET POST OPTIONS PROPFIND><br />
Order allow,deny<br />
Allow from all<br />
</Limit><br />
<LimitExcept GET POST OPTIONS PROPFIND><br />
Order deny,allow<br />
Deny from all<br />
</LimitExcept><br />
</Directory><br />
<br />
You must make sure that your home directory permissions are set properly so that Apache can get there. Your home directory and <code>~/public_html/</code> must be executable for others ("rest of the world"). This seems to be enough:<br />
$ chmod o+x ~<br />
$ chmod o+x ~/public_html<br />
<br />
There may be some other, more-secure ways of setting the permissions by creating a special group and allowing only Apache and you to enter there... You know how paranoid you are.<br />
<br />
==== Advanced Options====<br />
<br />
These options in /etc/httpd/conf/httpd.conf might be interesting for you:<br />
<br />
# Listen 80<br />
This is the port Apache will listen to. For Internet-access with router, you have to forward the port.<br />
<br />
# ServerAdmin sample@sample.com<br />
This is the admin's email-address which can be found on error-pages e.g.<br />
<br />
# DocumentRoot "/srv/http"<br />
This is the directory where you should put your web pages. Change it, if you want to, but don't forget to change the<br />
<br />
<Directory "/srv/http"><br />
to whatever you changed your DocumentRoot to.<br />
<br />
=== PHP ===<br />
PHP is practically available out of the box now.<br />
<br />
* Add these line in <code>/etc/httpd/conf/httpd.conf</code><br />
LoadModule php5_module modules/libphp5.so<br />
Include conf/extra/php5_module.conf<br />
NOTE: The "Include" can not be directly after the "LoadModule" line in the configuration file, it need to be down with the other "Includes".<br />
<br />
Apache2:<br />
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so<br />
AddHandler php5-script php<br />
http://dan.drydog.com/apache2php.html<br />
<br />
* Remember to add a file handler for .phtml if you need it in /etc/httpd/conf/extra/php5_module.conf:<br />
DirectoryIndex index.php index.phtml index.html<br />
<br />
* If you want the libGD module, uncomment in <code>/etc/php/php.ini</code>:<br />
;extension=gd.so<br />
to<br />
extension=gd.so<br />
Pay attention to which extension you uncomment, as this extension is sometimes mentioned in an explanatory comment before the actual line you want to uncomment. <br />
<br />
* If your <code>DocumentRoot</code> is outside of <code>/home/</code>, add it to <code>open_basedir</code> in <code>/etc/php/php.ini</code> as such:<br />
open_basedir = /home/:/tmp/:/usr/share/pear/:/path/to/documentroot<br />
<br />
suggestion - Add your document root as follows:<br />
open_basedir = /home/:/tmp/:/usr/share/pear/:/srv/http<br />
<br />
* Restart the Apache service to make changes take effect (as root):<br />
# /etc/rc.d/httpd restart<br />
<br />
* Test PHP with a simple, but very informative script:<br />
<html><br />
<head><br />
<title>PHP Test Page</title><br />
</head><br />
<body><br />
This is Arch Linux, running PHP.<br />
<?php<br />
phpinfo();<br />
?><br />
</body><br />
</html><br />
<br />
Save this file as <code>test.php</code> and copy to <code>/srv/http/</code> or to <code>~/public_html</code> if you permitted such a configuration.<!-- Also, remember to make it executable (<code>chmod o+x test.php</code>).--><br />
<br />
* Test PHP: http://localhost/test.php or http://localhost/~myname/test.php<br />
<br />
'''If you continue to have problems''', edit your /etc/httpd/conf/httpd.conf file with the following information<br />
<br />
* Edit your httpd.conf file<br />
# nano /etc/httpd/conf/httpd.conf<br />
<br />
* Under <code><IfModule mime_module></code><br />
AddType application/x-httpd-php .php<br />
AddType application/x-httpd-php-source .phps<br />
<br />
* Restart Apache<br />
# /etc/rc.d/httpd restart<br />
<br />
Be sure to test the page again to verify it's working properly (as stated above).<br />
<br />
=== MySQL ===<br />
* Configure MySQL as described at the [[MySQL]] wiki.<br />
<br />
* Edit <code>/etc/php/php.ini</code> (this is in <code>/usr/etc</code> on older systems) to uncomment the following line (''By removing <code>;</code>''):<br />
;extension=mysql.so<br />
<br />
* You can add minor privileged users for your web scripts by editing the tables found in the <code>mysql</code> database. You have to restart MySQL for changes to take effect. Don't forget to check the <code>mysql/users</code> table. If there's a second entry for root and your hostname is left with no password set, everybody from your host probably could gain full access. Perhaps see next section for these jobs.<br />
<br />
* Run in terminal (as root):<br />
# /etc/rc.d/mysqld start<br />
<br />
* MySQL should now be running. Test by visiting <code>http://localhost/phpMyAdmin</code> in a web browser - for testing by phpMyAdmin, you should have installed phpMyAdmin (<code>pacman -S phpmyadmin</code>). It should display phpMyAdmin main page.<br />
<br />
* Edit <code>/etc/rc.conf</code> (to start MySQL at boot):<br />
DAEMONS=(... '''mysqld''' ...)<br />
'''Or''' add this line to <code>rc.local</code>:<br />
/etc/rc.d/mysqld start<br />
<br />
* You can get the "<code>error no. 2013: Lost Connection to mysql server during query</code>" message instantly whenever you try to connect to the MySQL daemon by TCP/IP. This is the TCP wrappers system (tcpd), which uses the <code>hosts_access(5)</code> system to allow or disallow connections.<br />
<br />
* If you're running into this problem, be sure to add this to your /etc/hosts.allow file:<br />
# mysqld : ALL : ALLOW<br />
# mysqld-max : ALL : ALLOW<br />
# and similar for the other MySQL daemons.<br />
<br />
* Notes: The examples above are the simplest case, telling tcpd to allow connections from anywhere. You may wish to use a more-appropriate choice of permissible sources instead of ALL. Just make sure that localhost and the IP address (numeric or DNS) of the interface by which you connect are specified.<br />
<br />
* You might also need to edit <code>/etc/my.cnf</code> and comment out the <code>skip-networking</code> line as such:<br />
skip-networking<br />
to<br />
#skip-networking<br />
<br />
== More Resources ==<br />
* [[MySQL]] - Arch wiki article for MySQL<br />
* http://www.apache.org/<br />
* http://www.php.net/<br />
* http://www.mysql.com/</div>Burrahttps://wiki.archlinux.org/index.php?title=Talk:Very_Secure_FTP_Daemon&diff=42896Talk:Very Secure FTP Daemon2008-06-11T21:11:52Z<p>Burra: </p>
<hr />
<div>What is the advantage of using the xinitd approach over adding vsftpd to the Daemon list?<br />
<br />
And also, # pacman -S xinitd<br />
xinitd: not found in sync db<br />
<br />
What is xinitd?<br />
<br />
<br />
----<br />
<br />
Could one add a column that explains the security in /etc/hosts.allow like there is in the ssh wiki page:<br />
<br />
/etc/hosts.allow<br />
<br />
# let everyone connect to you<br />
vsftpd: ALL<br />
<br />
# OR you can restrict it to a certain ip<br />
vsftpd: 192.168.0.1<br />
<br />
# OR restrict for an IP range<br />
vsftpd: 10.0.0.0/255.255.255.0<br />
<br />
# OR restrict for an IP match<br />
vsftpd: 192.168.1.<br />
<br />
--[[User:Burra|Burra]] 17:11, 11 June 2008 (EDT)<br />
----</div>Burra