1.安裝 Apache2 Mysql-server php
sudo apt install apache2 mysql-serverhtml
sudo mysql_secure_installation
sudo mysqladmin -p -u root version
2.安裝 phpMyAdminmysql
安裝phpMyAdmin會自動安裝wordpress 所需的php 和PHP extensions。sql
sudo vi /var/www/html/phpinfo.php
<?php
phpinfo();
?>
sudo apt install phpmyadmin
安裝完成後,測試一下myphpadmin:
http://IP/phpmyadmin (eg: http://172.16.11.80/phpmyadmin)
若是用root登陸,會出現:#1698 – Access denied for user ‘root’@’localhost’
由於咱們在設置MySQL server 時設置了root 禁止遠程登陸。
因此要爲phpMyAdmin新建專用的登陸用戶:
sudo mysql -p -u root
CREATE USER 'myadmin'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'myadmin'@'%' WITH GRANT OPTION;
如今用myadmin登陸phpmyadmin 就能夠了:
爲了安全,能夠修改phpmyadmin的訪問地址:
sudo vi /etc/apache2/conf-available/phpmyadmin.conf
修改Alias /phpmyadmin /usr/share/phpmyadmin
sudo service apache2 reload
訪問http://IP/phpinfo.phpapache
3. 配置Apache 爲多站點服務:Virtual Host安全
apache 默認的站點目錄是:/var/www/htmltcp
咱們如今要建兩個站點:eg: a.ink 和 b.ccide
首先,創建兩站點目錄:/var/www/a.ink/html 和 /var/www/b.cc/htmlwordpress
sudo mkdir -p /var/www/afd.ink/html測試
sudo mkdir -p /var/www/nipc.cc/html
sudo chmod -R 755 /var/www
sudo vi /var/www/afd.ink/html/index.html
<html> <head> <title>Welcome to afd.ink</title> </head> <body> <h2>Welcome to afd.ink</h2> </body> </html>
sudo vi /var/www/nipc.cc/html/index.html
<html> <head> <title>Welcome to nipc.cc</title> </head> <body> <h2>Welcome to nipc.cc</h2> </body> </html>
sudo vi /etc/apache2/sites-available/afd.ink.conf
<VirtualHost *:80> ServerAdmin admin@afd.ink ServerName afd.ink ServerAlias www.afd.ink DocumentRoot /var/www/afd.ink/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo vi /etc/apache2/sites-available/nipc.cc.conf
<VirtualHost *:80> ServerAdmin admin@nipc.cc ServerName nipc.cc ServerAlias www.nipc.cc DocumentRoot /var/www/nipc.cc/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo a2ensite afd.ink.conf
sudo a2ensite nipc.cc.conf
apachectl configtest
sudo systemctl reload apache2
sudo vi /ect/hosts
172.16.11.80 afd.ink
172.16.11.80 nipc.cc
訪問測試一下是否成功:
4.安裝vsftpd安裝:
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 40000:50000/tcp
sudo ufw allow 990/tcp