阿里云ECS 镜像ubuntu16.04配置apache+mysql+php

来源:转载



先更新系统
```
$ 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.conf

ServerAdmin [email protected]
DocumentRoot /var/www/html

Options FollowSymLinks
AllowOverride All
Order deny,allow
allow from All

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

#重启生效
$ service apache2 restart
```
### 安装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 -p
use 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
```

分享给朋友:
您可能感兴趣的文章:
随机阅读: