follow my heart...
分类: LINUX
2010-02-02 09:51:49
这个文档描述了怎样在Archlinux系统上安装设置Apache网页服务器。以及选择安装PHP和MySQL并集成到Apache服务器中。
如果你只是用来开发和测试, Xampp 可能更简便一些。
# pacman -S apache php php-apache mysql
你可以只单独安装Apache,PHP或者MySQL,也可以安装所有包。这个文档假设你安装全部,当然你可以忽略任何部分。
# useradd -d /srv/http -r -s /bin/false -U http
127.0.0.1 localhost.localdomain localhost
注意: 如果你想要不同的域名,在末尾追加以下行:
127.0.0.1 localhost.localdomain localhost myhostname
## Networking#STNAME="localhost"H
O
# nano /etc/httpd/conf/httpd.conf
把
LoadModule unique_id_module modules/mod_unique_id.so
注释为
#LoadModule unique_id_module modules/mod_unique_id.so
# /etc/rc.d/httpd start
DAEMONS=(... some daemons ... httpd)
或者 添加以下行到 /etc/rc.local:
/etc/rc.d/httpd start
~/public_html
在机器上通过~user/
访问) 可以被访问,请在/etc/httpd/conf/extra/httpd-userdir.conf取消注释以下行:UserDir public_html
和
AllowOverride FileInfo AuthConfig Limit IndexesOptions MultiViews Indexes SymLinksIfOwnerMatch ExecCGIOrder allow,deny IONS PROPFIND>Allow from allT Order deny,allow Deny from all
请确认你的用户目录权限正确设置使apache可以访问,你的用户目录和~/public_html/
必有要有可执行权限。这样就可以了:
$ chmod o+x ~$ chmod o+x ~/public_html
如果你对安全问题很偏执的话,还有其它更安全的方法设置权限,可以创建一个只允许apache和你可以访问特别组。
下面这些参数可以在/etc/httpd/conf/httpd.conf 中看到,有些可能你会感兴趣:
# Listen 80
这是Apache监听的端口。对于通过路由器的网络,应该转发这个端口。
# ServerAdmin sample@sample.com
这是管理员admin的email地址,可以在出错页面error-pages找到,比如.
# DocumentRoot "/srv/http"
这是你网页存放的目录,可以改变它,改了之后,还要把这也改成相应的目录
PHP基本上可以使用的了.
LoadModule php5_module modules/libphp5.soInclude /etc/httpd/conf/extra/php5_module.conf
DocumentRoot
是在/home/
以外地方,在/etc/php/php.ini
添加这个open_basedir
成:open_basedir = /home/:/tmp/:/usr/share/pear/:/path/to/documentroot
# /etc/rc.d/httpd restart
PHP Test Page>> h Linux, running PHP. This is Ar
chpinfo(); ?>
保存此文件为test.php
复制到/srv/http/
或 ~/public_html
如果你允许此权限。当然请把它设置为可执行文件(chmod o+x test.php
).
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.phtml index.html
/etc/php/php.ini
里的;extension=gd.so
取消注释为
extension=gd.so
display_errors=Off
修改为
display_errors=On
;extension=mcrypt.so
extension=mcrypt.so
如果只要设置支持MySQL,做以下步骤就行了,至于具体配置MySQL请参考: MySQL
/usr/etc
里) to 取消注释如下行(移除;
即可):;extension=mysql.so
mysql
database. You have to restart MySQL for changes to take effect. Don't forget to check the mysql/users
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.# /etc/rc.d/mysqld start
# /etc/rc.d/httpd restart
# mysqladmin -u root password password# mysql -u root -p
DAEMONS=(... mysqld ...)
或者在 rc.local中添加:
/etc/rc.d/mysqld start
error no. 2013: Lost Connection to mysql server during query
" message instantly whenever you try to connect to the MySQL daemon by TCP/IP. This is the TCP wrappers system (tcpd), which uses the hosts_access(5)
system to allow or disallow connections.# mysqld : ALL : ALLOW# mysqld-max : ALL : ALLOW# and similar for the other MySQL daemons.
skip-networking
注释掉:skip-networking
修改为
#skip-networking