ubuntu 搭建 apache php mysql 运行环境,并在服务器恢复网站数据.
ubuntu14.04 :
sudo apt-get install -y apache2
sudo apt-get install -y php5
sudo apt-get install -y mysql-serversudo apt-get install -y php5-mysql
ubuntu16.04 :
----------------------------------------------------------
sudo apt-get install -y apache2
sudo apt-get install -y php libapache2-mod-php
sudo apt-get install -y mysql-serversudo apt-get install -y php-mysql
sudo a2enmod php7.0
sudo service apache2 restart
sudo service mysql restart
接着安装网页版mysql管理程序:
cd /var/www/html
wget https://files.phpmyadmin.net/phpMyAdmin/4.8.0.1/phpMyAdmin-4.8.0.1-all-languages.tar.gz
tar xvf phpMyAdmin-4.8.0.1-all-languages.tar.gz
mv phpMyAdmin-4.8.0.1-all-languages pma
在线
安装完
sudo apt-get install -y apache2
sudo apt-get install -y php5
sudo apt-get install -y mysql-server
之后,出现这个错误:
This PHP environment doesn't have MySQL support built in. MySQL support is required if you want to use a MySQL database to run this forum. Consult the PHP documentation for further assistance.
解决方案:
sudo apt-get install -y php5-mysql
在线
接着安装网页版mysql管理程序:
cd /var/www/html
wget https://files.phpmyadmin.net/phpMyAdmin/4.8.0.1/phpMyAdmin-4.8.0.1-all-languages.tar.gz
tar xvf phpMyAdmin-4.8.0.1-all-languages.tar.gz
mv phpMyAdmin-4.8.0.1-all-languages pma
然后在浏览器输入 http://localhost/pma/
可以看到界面了:
登录:
登录进去:
新建数据库:
在线
使能ssl与rewrite模块:
sudo a2enmod rewrite
sudo a2enmod ssl
修改 /etc/apache2/sites-available/000-default.conf
VirtualHost 节点添加:
Options +FollowSymLinks
RewriteEngine On
#RewriteRule /phpinfo.html /phpinfo.php
#RewriteRule /6a.tar.gz /6a.mp4
#RewriteRule /q_23.html /index.php?q-23.html
#RewriteRule /q/(\d+)\.html /index.php?q-$1.html
#RewriteRule /a/(\d+)\.html /index.php?article-$1.html
RewriteRule ^/t_(\d+)\.html /viewtopic.php?id=$1
#RewriteRule ^/p_(\d+)\.html /viewtopic.php?pid=$1
RewriteRule ^/f_(\d+)\.html /viewforum.php?id=$1
RewriteRule ^/index.php /viewall.php?id=4
RewriteRule ^/f_(\d+)_(\d+)\.html /viewforum.php?id=$1&p=$2RewriteRule ^/index.html /viewall.php?id=4
RewriteRule ^/index_4.html /viewall.php?id=4
RewriteRule ^/index_4_(\d+)\.html /viewall.php?id=4&p=$1
搞定重写URL
在线
厉害了,我的晕哥~~
离线
建站高手~
离线
全栈!
歪朵拉开源硬件: https://widora.cn
淘宝: https://widora.taobao.com/
离线
晕哥,你别学了,跟不上
离线
全栈啊,认真跟帖学习!
离线
全栈啊,认真跟帖学习!
离线
晕哥在哪里买的主机,性价比怎么样
离线
可以支付宝支付吗?还是需要visa卡支付
离线
备份数据库 命令行输入:
恢复数据库 命令行输入:
补充一下,这里sql脚本创建数据库:
create database bb default character set utf8mb4 collate utf8mb4_general_ci;
sql脚本删除数据库:
drop databse bb
离线