1.安装 Apache2 Mysql-server
sudo apt install apache2 mysql-server
sudo mysql_secure_installation
sudo mysqladmin -p -u root version
2.安装 phpMyAdmin
安装phpMyAdmin会自动安装wordpress 所需的php 和PHP extensions。
sudo vi /var/www/html/phpinfo.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.php
3. 配置Apache 为多站点服务:Virtual Host
apache 默认的站点目录是:/var/www/html
我们现在要建两个站点:eg: a.ink 和 b.cc
首先,建立两站点目录:/var/www/a.ink/html 和 /var/www/b.cc/html
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
Welcome to afd.ink Welcome to afd.ink
sudo vi /var/www/nipc.cc/html/index.html
Welcome to nipc.cc Welcome to nipc.cc
sudo vi /etc/apache2/sites-available/afd.ink.conf
ServerAdmin [email protected]
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
sudo vi /etc/apache2/sites-available/nipc.cc.conf
ServerAdmin [email protected]
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
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