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
离线