当前位置: > Linux发行版 > Arch Linux >

ArchLinux LAMP 配置与使用

时间:2016-05-19 17:42来源:linux.it.net.cn 作者:IT
安装相关包(apache php mysql)

$ sudo pacman -S apache php mysql mysql-gui-tools





配置apache

$ sudo gvim /etc/hosts

127.0.0.1  localhost.localdomain   localhost



$ sudo gvim /etc/rc.conf

#

# Networking

#

HOSTNAME="localhost"

$ sudo gvim /etc/httpd/conf/httpd.conf

LoadModule unique_id_module        modules/mod_unique_id.so        =>         #LoadModule unique_id_module        modules/mod_unique_id.so



启动apache

$ sudo /etc/rc.d/httpd start

$ sudo gvim /etc/rc.conf

DAEMONS=(... some daemons ... httpd)

如果想使用用户路径,比如/home/wywacczy/public_html文件夹下的网页通过http://localhost/~wywacczy/访问

$ sudo gvim /etc/httpd/conf/extra/httpd-userdir.conf



UserDir public_html



<Directory /home/*/public_html>

  AllowOverride FileInfo AuthConfig Limit Indexes

  Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI

  <Limit GET POST OPTIONS PROPFIND>

    Order allow,deny

    Allow from all

  </Limit>

  <LimitExcept GET POST OPTIONS PROPFIND>

    Order deny,allow

    Deny from all

  </LimitExcept>

</Directory>



$ chmod o+x ~

$ chmod o+x ~/public_html



错误页面的webmaster电子邮件地址

$ sudo gvim /etc/httpd/conf/httpd.conf



ServerAdmin sample@sample.com





apache默认Web站点根目录

$ sudo gvim /etc/httpd/conf/httpd.conf



DocumentRoot "/srv/http"



<Directory "/srv/http">





apache默认Web页面(DirectoryIndex中越前优先级越高)

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>







配置php

$ sudo gvim /etc/httpd/conf/httpd.conf



LoadModule php5_module  /usr/lib/httpd/modules/libphp5.so



AddHandler php5-script php

加载php支持 Include /etc/httpd/conf/extra/php5_module.conf



重启apache服务器

sudo /etc/rc.d/httpd restart







配置mysql

$ sudo gvim /etc/php/php.ini

;extension=mysql.so        =>        extension=mysql.so



启动mysql

$ sudo /etc/rc.d/mysqld start



$ sudo gvim /etc/rc.conf

DAEMONS=(... some daemons ... mysqld)

ArchLinux下mysql安装时不添加任何用户,不像ubuntu下安装时会配置root密码,结果就是无法使用mysql

$ mysql -u root -p

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)



mysql的系统数据库mysql中的user表包含着用户以及用户权限信息,添加root用户,并添加权限即可(我自己将root密码设置为空)

$ sudo /etc/rc.d/mysqld stop



$ sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &



$ mysql -u root mysql



mysql> UPDATE user SET Password=PASSWORD('') where USER='root';



mysql> FLUSH PRIVILEGES;



mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;



$ sudo /etc/rc.d/mysqld restart






(责任编辑:IT)
------分隔线----------------------------