安装 mysql php apache
sudo apt-get install mysql-server mysql-common
先用管理员密码登入,下面查询管理员密码
sudo cat /etc/mysql/debian.cnf
mysql -u debian-sys-maint -p
Enter password: #输入文件中的密码即可成功登陆(password)
修改密码:
mysql> update mysql.user set authentication_string=password('password') where user='root'and Host = 'localhost';
退出后一定要重启服务
sudo /etc/init.d/mysql restart
然后再重新登入(务必前面带sudo)
sudo mysql -u root -p
安装apache
sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php
安装mysql扩展
sudo apt-get install php-mysql
安装必要扩展
sudo apt-get install php-pear
sudo apt-get install php-curl
sudo apt-get install php-json
sudo apt-get install php-cgi
修改配置后要重启apache
sudo /etc/init.d/apache2 restart
注意:只有本机能访问,要防火墙开放80或者8080端口,根据需要来
修改端口 所有 80 改 8080,如果需要的话
sudo nano /etc/apache2/ports.conf
sudo nano /etc/apache2/sites-enabled/000-default.conf
修改根目录
sudo nano /etc/apache2/apache2.conf
复制一个节点
将/var/www/ 改为 /home/zmy/www(这个不改,会提示没有权限访问)
然后在节点中添加DirectoryIndex index.php index.phtml index.html index.htm
这个index.php放前面优先级最高
<Directory /home/zmy/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
DirectoryIndex index.php index.phtml index.html index.htm
</Directory>
同样在/etc/apache2/sites-enabled/000-default.conf中
修改 DocumentRoot /home/zmy/www/html
chmod -R 775 /home/zmy/www/html
关于防火墙配置
用命令iptables -L -n 查看防火墙配置规则,看看想要的那个端口是不是开放了
开放下面端口:
iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
但是通常不会做add操作,因为accept规则必须在reject规则前,否则这个accept无效
用插入指令
sudo iptables -I INPUT 3 -p tcp -m tcp --dport 8080 -j ACCEPT (表示在第三行插入这条规则)
当添加错了可以用删除操作
iptables -D INPUT 3(表示要删除第三条)
最后保存添加的规则
sudo iptables-save > /etc/iptables.up.rules (但是这个会提示权限不够,哪怕sudo)
需要切换成root用户
设置root密码 sudo passwd
然后通过命令 su root进入
再执行就ok了iptables-save > /etc/iptables.up.rules
https://www.aliyun.com/jiaocheng/166105.html
https://yq.aliyun.com/articles/517339
http://blog.51yip.com/linux/1404.html