meta data for this page
To jest stara wersja strony!
LAMP serwer
czyli jak zainstalować i skonfigurować na Linux: Apache, MySQL i PHP. Zobacz także: Zmiana wersji PHP.
Od wersji Debian 10 MySQL'a nie ma w standardowym repozytorium. Dodanie repozytorium:
apt-get install gnupg wget wget http://repo.mysql.com/mysql-apt-config_0.8.15-1_all.deb dpkg -i mysql-apt-config_0.8.15-1_all.deb
Sprawdź jakie jest najnowsze repozytorium na stronie https://dev.mysql.com/downloads/repo/apt/.
Debian
apt-get update apt-get install apache2 apt-get install mysql-server mysql-client apt-get install php php-mysql
CentOS
yum update yum install httpd yum install mariadb-server mariadb yum install php php-mysql yum install mod_ssl openssl # Instalujemy mod_ssl
Wrzucamy pliki strony do /home/dak/httpdocs/, gdzie dak to nazwa użytkownika (zamień wszędzie na swoją stosowną nazwę).
useradd --create-home --shell /bin/bash dak cd /home/dak sudo -u dak mkdir httpdocs install logs backup
Teraz tworzymy konfigurację serwera Apache w /etc/apache2/sites-available, np. /etc/apache2/sites-available/dak.conf (patrz Przykładowa konfiguracja Apache).
W CentOS wystarczy utworzyć konfigurację w /etc/httpd/conf.d/dak.conf - zostanie ona automatycznie zainkludowana.
a2ensite dak
W sites-enabled powinno się pojawić dowiązanie do konfiguracji. Włączmy niezbędne mody Apache:
a2enmod headers a2enmod ssl a2enmod rewrite
W CentOS musimy ręcznie włączyć uruchamianie serwisów przy starcie systemu:
systemctl enable mariadb systemctl enable httpd
Na koniec restartujemy serwis, żeby nowe ustawienia zaczęły obowiązywać:
service apache2 restart service apache2 status
Jeżeli uruchamiamy stronę na HTTPS, musimy jeszcze wrzucić certyfikaty do katalogu /etc/apache2/ssl. Zmieniamy właściciela plików strony:
chown -R www-data:www-data /home/dak/httpdocs/ # W CentOS użytkownik ten nazywa się apache
W MySQL tworzymy bazę danych dla naszej strony, przykładowo (dak to nazwa naszej bazy):
mysql -u root -p CREATE DATABASE IF NOT EXISTS dak CHARACTER SET 'utf8' COLLATE utf8_polish_ci; GRANT ALL PRIVILEGES ON dak.* TO 'dak'@'localhost' IDENTIFIED BY 'dak'; FLUSH PRIVILEGES; SELECT host, user, password FROM mysql.user ORDER BY user, host; # sprawdzenie use dak; exit;
Przykładowa konfiguracja Apache
- dak.conf
<VirtualHost *:443> DocumentRoot /home/dak/httpdocs ServerName dak.uwb.edu.pl ServerAdmin p.grygorczuk@uwb.edu.pl Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;" SSLEngine On SSLCertificateFile /etc/apache2/ssl/certs/server.crt SSLCertificateKeyFile /etc/apache2/ssl/private/server.key SSLCertificateChainFile /etc/apache2/ssl/certs/chain.crt ErrorLog /home/dak/logs/ssl_error.log CustomLog /home/dak/logs/ssl_access.log combined <Directory /home/dak/httpdocs> AddType application/x-httpd-php .php .php3 .php4 .inc DirectoryIndex index.php index.php3 index.html Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted #Require all denied #Require ip 10.9.5 </Directory> <Directory /home/wiki-dak/httpdocs/docs> AddType application/x-httpd-php .php .php3 .php4 .inc DirectoryIndex index.php index.php3 index.html Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All #Require all granted Require all denied Require ip 10.9.5 Require ip 212.33.72 Require ip 91.145.135.39 </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot /home/dak/httpdocs ServerName dak.uwb.edu.pl ServerAdmin p.grygorczuk@uwb.edu.pl Redirect permanent / https://dak.uwb.edu.pl ErrorLog /home/dak/logs/error.log CustomLog /home/dak/logs/access.log combined <Directory /home/dak/httpdocs> AddType application/x-httpd-php .php .php3 .php4 .inc DirectoryIndex index.php index.php3 index.html Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted #Require all granted #Require not ip 212 #Require all denied #Require ip 10.9.5 </Directory> <Directory /home/wiki-dak/httpdocs/docs> AddType application/x-httpd-php .php .php3 .php4 .inc DirectoryIndex index.php index.php3 index.html Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All #Require all granted Require all denied Require ip 10.9.5 Require ip 212.33.72 Require ip 91.145.135.39 </Directory> </VirtualHost>