買了一臺阿里雲的機器,系統是ubuntu 16.01,而後想搭一個php環境php
爲了下包快一點,換成阿里源 /etc/apt/sources.listhtml
- deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
- deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
- deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
- deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
- deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
- deb http://mirrors.aliyun.com/ubuntu/ xenial universe
- deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
- deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
- deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
- deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
- deb http://archive.canonical.com/ubuntu xenial partner
- deb-src http://archive.canonical.com/ubuntu xenial partner
- deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
- deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
- deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
- deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
先安裝一下apache2 apt-get install apache2mysql
使用apt-cache search 能夠查詢軟件包sql
安裝完成以後 查看一下 it works!輸入1localhost 就好了 通常是80端口數據庫
關閉的話 /etc/init.d/apache2 stop/start/restartapache
安裝php 7.0ubuntu
apt-get install php7.0segmentfault
apt-get install libapache2-mod-php7.0瀏覽器
而後安裝一個mysql數據庫微信
apt-get install mysql-server
/etc/init.d/mysql restart/start/stop
而後裝個phpmyadmin
apt-get install phpmyadmin
最後建立phpmyadmin連接 ln -s /usr/share/phpmyadmin /var/www/html/
最後在瀏覽器上訪問一下
可是若是ecs中的這個數據庫須要外網訪問的話,須要再作一些設置
參考這個地址的回答:https://segmentfault.com/q/1010000009603559/a-1020000009605146
按照上面的步驟,就能夠訪問了!
而後隨便在/var/www/html目錄下寫個php文件 命名aa.php
輸出
這樣差很少就完成了吧
微信公衆號: