1.Устанавливаем пакеты: apache2, apache2-mod_php5, php5, php5-curl, php5-gd, php5-iconv, php5-mbstring, php5-mysql, mysql, mysql-client
2.Создаем необходимые каталоги. /opt/www будет для виртуальных хостов (к примеру /opt/www/mytest будет соответствовать http://mytest/ ). Все действия (до установки phpMyAdmin) выполняйте от рута.
Код: Выделить всё
mkdir /opt/www
chmod 0777 /opt/www
mkdir /opt/www/logs
mkdir /opt/www/tools
touch /opt/www/tools/vhost.conf3.Настраиваем Apache
/etc/apache2/httpd.conf
Код: Выделить всё
### Global Environment ######################################################
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests.
# run under this user/group id
Include /etc/apache2/uid.conf
# - how many server processes to start (server pool regulation)
# - usage of KeepAlive
Include /etc/apache2/server-tuning.conf
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog /var/log/apache2/error_log
# generated from APACHE_MODULES in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/loadmodule.conf
# IP addresses / ports to listen on
#Заккоментируйте это, чтобы избежать доступа к серверу из сети.
#Include /etc/apache2/listen.conf
# predefined logging formats
Include /etc/apache2/mod_log_config.conf
# generated from global settings in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/global.conf
# optional mod_status, mod_info
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
# optional cookie-based user tracking
# read the documentation before using it!!
Include /etc/apache2/mod_usertrack.conf
# configuration of server-generated directory listings
Include /etc/apache2/mod_autoindex-defaults.conf
# associate MIME types with filename extensions
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf
# set up (customizable) error responses
Include /etc/apache2/errors.conf
# global (server-wide) SSL configuration, that is not specific to
# any virtual host
Include /etc/apache2/ssl-global.conf
# forbid access to the entire filesystem by default
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var index.php
### 'Main' server configuration #############################################
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
Include /etc/apache2/default-server.conf
# Another way to include your own files
#
# The file below is generated from /etc/sysconfig/apache2,
# include arbitrary files as named in APACHE_CONF_INCLUDE_FILES and
# APACHE_CONF_INCLUDE_DIRS
Include /etc/apache2/sysconfig.d/include.conf
### Virtual server configuration ############################################
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
#Include /etc/apache2/vhosts.d/*.conf
Listen 127.0.0.1:80
NameVirtualHost *:80
Include /opt/www/tools/vhost.conf/etc/apache2/default-server.conf
Код: Выделить всё
#
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
#
#DocumentRoot "/opt/www"
#
# Configure the DocumentRoot
#
<Directory "/opt/www">
Options Indexes FollowSymLinks SymLinksIfOwnerMatch MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Aliases: aliases can be added as needed (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL. So "/icons" isn't aliased in this
# example, only "/icons/". If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings. If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf
# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?confЕсли не хотите проблем с правами доступа в PHP, то пропишите в /etc/apache2/uid.conf свой user и group.
4. Настраиваем MySQL. В файл /etc/my.cnf в секцию mysqld добавьте следующее:
Код: Выделить всё
# Запрещает внешнее подкючение к базе
skip-networking
# Для снижения нагрузки отключаем innodb и bdb
skip-innodb
skip-bdb
default-storage-engine=MyISAM
# Кодировка по умолчанию
character-set-server=cp1251
skip-character-set-client-handshake5. Скрипт для генерации виртуальных хостов
/opt/www/tools/vhost.php
Код: Выделить всё
<?php
$vhostfile="/opt/www/tools/vhost.conf";
$vhostdir="/opt/www";
$hostsfile="/etc/hosts";
$hostsconf=file_get_contents($hostsfile);
$hostsconf=preg_replace('|#myvhosts[^#]*#end|s', '', $hostsconf);
$hostsconf=rtrim($hostsconf)."\n\n#myvhosts\n";
$vhostconf="";
$dh=opendir($vhostdir);
while (($name=readdir($dh))!==false) {
if (($name=='.') or ($name=='..') or ($name=='logs') or ($name=='tools') or (!is_dir("$vhostdir/$name"))) {continue;}
echo "Add vhost $name\n";
$vhostconf.="<VirtualHost *:80>\n";
$vhostconf.="ServerName $name\n";
$vhostconf.="DocumentRoot $vhostdir/$name\n";
$vhostconf.="ErrorLog $vhostdir/logs/{$name}_error.log\n";
$vhostconf.="CustomLog $vhostdir/logs/{$name}_access.log combined\n";
$vhostconf.="ScriptAlias /cgi-bin/ $vhostdir/$name/cgi-bin/\n";
$vhostconf.="</VirtualHost>\n";
$hostsconf.="127.0.0.1\t$name\n";
}
closedir($dh);
$hostsconf.="#end\n";
file_put_contents($vhostfile, $vhostconf);
file_put_contents($hostsfile, $hostsconf);
?>6. Ярлыки для запуска и остановки
/opt/www/tools/start
Код: Выделить всё
#!/bin/bash
php /opt/www/tools/vhost.php
/etc/init.d/apache2 start
/etc/init.d/mysql start/opt/www/tools/stop
Код: Выделить всё
#!/bin/bash
/etc/init.d/apache2 stop
/etc/init.d/mysql stop/opt/www/tools/restart
Код: Выделить всё
#!/bin/bash
/etc/init.d/apache2 stop
/etc/init.d/mysql stop
php /opt/www/tools/vhost.php
/etc/init.d/apache2 start
/etc/init.d/mysql startУстанавливаем права
Код: Выделить всё
chmod 0755 /opt/www/tools/start
chmod 0755 /opt/www/tools/stop
chmod 0755 /opt/www/tools/restartСоздаем, к примеру, на рабочем столе "ссылку на приложение" и в свойствах в поле "команда" указываем (для старта)
Код: Выделить всё
konsole -e su -c /opt/www/tools/startДля остановки и перезапуска аналогично.
Все. Можно создавать каталоги в /opt/www и запускать.
7. Установка phpMyAdmin
Скачиваем phpMyAdmin здесь. Распаковываем архив в /opt/www/pma.
Создаем в этом каталоге config.inc.php
Код: Выделить всё
<?php
$i = 0;
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['controluser'] = 'phpmyadmin';
$cfg['Servers'][$i]['controlpass'] = '';
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
?>Перезапускаем сервер. Заходим в phpMyAdmin, раздел Привелегии, Добавить нового пользователя. Имя - phpmyadmin, пароль - не использовать, база данных - Создать базу данных с именем пользователя в названии и предоставить на нее полные привилегии, глобальные привелегии ставить не надо. После создания пользователя выбираем базу phpmyadmin, Импорт. Импортируем файл /opt/www/pma/scripts/create_tables_mysql_4_1_2+.sql