Gentoo/Sabayon 安装LAMP

DEPHI 2011-08-16

本文主要给大家介绍如何在Gentoo/Sabayon 安装LAMP组合。

LAMP:Linux+Apache,+MySQL+PHP

#1,升级系统

#emerge --sync

#2,安装Apache 网络服务器

安装过程:

sabayon6 ~ # emerge  apache
^[OH
 * IMPORTANT: 3 news items need reading for repository 'gentoo'.

 * Use eselect news to read news items.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Starting parallel fetch

>>> Emerging (1 of 2) app-admin/apache-tools-2.2.17

 * waiting for lock on /usr/portage/distfiles/.httpd-2.2.17.tar.bz2.portage_lockfile
 ...                [ ok ]

root目录在/var/www/localhost/htdocs/

如果允许用户拥有自己的网页(public_html),执行命令:

echo "www-servers/apache userdir" >> /etc/portage/package.use emerge apache

After that you also need to edit the file /etc/conf.d/apache2 and add “-D USERDIR” to APACHE2_OPTS as shown:
APACHE2_OPTS=”-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D USERDIR”
Then every user have to make a public_html directory in order to put his/her index.html and any other files in there.
[edit] 00_mod_userdir.conf
If you want to allow just some users to have their own web pages, then you have to edit the userdir module in:
/etc/apache2/modules.d/00_mod_userdir.conf
and add to it the following lines:
Code: add to 00_mod_userdir.conf
UserDir public_html
UserDir disabled
UserDir enabled user1 user2 root

接下来,可以启动apache:

sabayon6 ~ # /etc/init.d/apache2   start
 * Caching service dependencies ...                                       [ ok ]
 * Starting apache2 ...
apache2:
 Could not reliably determine the server's fully qualified domain name,
using 10.0.2.15 for
ServerName                                            [ ok]

设置apache2 为开机启动:

# rc-update -v add  apache2 default

输出结果为:

 * apache2 added to runlevel default
 * Caching service dependencies... [ ok ]
 * rc-update complete.

#3,安装PHP 软件包

可通过下面命令安装PHP:

# emerge  php mod_php

当安装mod_php,需要手动修改配置文件/etc/conf.d/apache2:

 * The INI file for this build is /etc/php/apache2-php5/php.ini
 * Due to some previous bloopers with PHP and slotting, you may have

 * multiple instances of mod_php installed. Please look at the autoclean
 * To have Apache run php programs, please do the following:
 * Edit /etc/conf.d/apache2 and add "-D PHP5" to APACHE2_OPTS
 APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D SUEXEC -D LANGUAGE -D PHP5"

检查PHP 安装

现在,我们已经安装了PHP软件包,下面进行相应php页面测试:

可在root 下的apache目录建立文件,如info.php

< ? phpinfo() ? >

echo '' > /var/www/localhost/htdocs/index.php

现在,打开页面http://yourip/info.php查看下,是否已经生效。

#4,安装MySQL 数据库

可用下面命令安装MySQL:

# emerge mysql

配置MySQL数据库:

(提示,将 [version] 修改成你安装的版本号即可)

 # emerge --config =dev-db/mysql-[version]
 * MySQL DATADIR is /var/lib/mysql
 * Press ENTER to create the mysql database and set proper
 * permissions on it, or Control-C to abort now...

   Preparing db table
   Preparing host table
   Preparing user table
   Preparing func table
   Preparing tables_priv table
   Preparing columns_priv table
   Installing all prepared tables

下面我们设置MySQL密码:

首先,开启服务器:

/etc/init.d/mysql start

接下来,我们设置密码即可:

usr/bin/mysqladmin -u root -h [your hostname] -p password 'new-password'

提示,将[your hostname] 替换成自己的主机名,’new-password’换成自定义的密码即可。

测试mySQL服务器

重启MySQL服务器:

# /etc/init.d/mysql restart作为数据库管理员登录(注意区别linux管理员密码):

# mysql -u root -p监测数据库是否正确简历,查看表和相关数据:

mysql> use mysql

mysql> show tables;

mysql> select * from user;

查看输出有错误提示信息即可。

添加MySQL开机启动

# rc-update -v add mysql default

若一切正常,会看到下面输出信息:

* mysql added to runlevel default

* Caching service dependencies... [ ok ]

* rc-update complete.

#5,安装phpMyAdmin

命令:

emerge -av phpmyadmin

下面进行相关授权:

mysql -u root -p < /usr/share/webapps/phpmyadmin//sqlscripts/mysql/_create.sql

相关推荐

caspertian / 0评论 2019-12-20