Ubuntu安装PHP,MySQL,Apache


安装
安装环境 : Ubuntu 16.04
1,Install Apache
a
sudo apt-get update
sudo apt-get install apache2

Y+Enter
b 设置全局服务名,去掉语法警告
sudo nano /etc/apache2/apache2.conf
   /etc/apache2/apache2.conf 文件末尾添加 ... ServerName server_domain_or_IP
   server_domain_or_IP get : ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
sudo apache2ctl configtest // Syntax OK
c restart
sudo systemctl restart apache2
d 设置防火墙
sudo ufw app list
 Output
 Available applications:
   Apache
   Apache Full
   Apache Secure
   OpenSSH
sudo ufw app info "Apache Full"
 Output
 Profile: Apache Full
 Title: Web Server (HTTP,HTTPS)
 Description: Apache v2 is the next generation of the omnipresent Apache web
 server.
 Ports:
   80,443/tcp
 
sudo ufw allow in "Apache Full"
http://your_server_IP_address   //default page
2,Install MySQL
a
sudo apt-get install mysql-server
b 安全脚本
sudo mysql_secure_installation
设置 MySQL root password
     VALIDATE PASSWORD PLUGIN:https://dev.mysql.com/doc/refman/5.6/en/validate-password-plugin.html
3,Install PHP
a
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
b,设置Apache先找indec.php
sudo nano /etc/apache2/mods-enabled/dir.conf
 /etc/apache2/mods-enabled/dir.conf
 //index.php放在index.html前面
 <IfModule mod_dir.c>
  DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
 </IfModule>
c 重启Apache
sudo systemctl restart apache2
sudo systemctl status apache2 // just check
d 查看PHP的可安装组件
apt-cache search php- | less
apt-cache show php-cli  //php-cli的详细信息
sudo apt-get install php-cli //安装php-cli
4,Test PHP on Web Server
sudo nano /var/www/html/info.php
 info.php
 //编辑php界面显示信息
 <?php
 phpinfo();
http://your_server_IP_address/info.php  //也可以浏览器查看
sudo rm /var/www/html/info.php   //删除文件

使用sudo进行安装时可能遇到问题
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
ubuntu系统默认root用户不能登陆,密码也是空的。
解决
1,用root用户登录。
terminal:sudo passwd root,
回车,当前登录用户密码
回车,root用户密码,两边,千万记住!
2,更新软件
因为是刚安装unbuntu,所以选择了升级下
terminal:sudo su //切换到root, su user 切换回用户
su:switch user
terminal:sudo apt-get update && sudo apt-get upgrade //然后y



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值