先更新系统
$ apt update
安装Apache2
$ apt install apache2
使用rewrite模块
#查看已安装模块$ apache2ctl -M$ vi /etc/apache2/apache2.conf#增加一行LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so#站点设置$ vi /etc/apache2/sites-enabled/000-default.confServerAdmin webmaster@localhost DocumentRoot /var/www/html #重启生效$ service apache2 restartOptions FollowSymLinks AllowOverride All Order deny,allow allow from All ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
安装PHP
$ apt install php$ apt install libapache2-mod-php#查看已安装模块$ php -m#安装需要的模块$ apt install php-sqlite3#重启生效$ service apache2 restart
安装MySQL
$ apt install mysql-server$ apt install mysql-client$ apt install php-mysql#重启生效$ service apache2 restart#运行mysql的安全向导$ mysql_secure_installation
设置MYSQL的远程登录
$ vi /etc/mysql/mysql.conf.d/mysqld.cnf#注释掉这一条#bind-address = 127.0.0.1$ mysql -u root -puse mysql;grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option;flush privileges;exit;#重启生效$ service mysql restart
安装PHPMYADMIN
$ apt install phpmyadmin$ apt install php-mbstring$ apt install php-gettext$ ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin#重启生效$ service apache2 restart