要新装几台服务器,想起来记录一下步骤。
还是用的Ubuntu16.04服务器版,以后估计会更新到18版本,现在还是觉得16版本比较稳定(其实是用习惯了懒得换)。先更新软件,感觉花了十来分钟:
sudo apt update
sudo apt upgrade
正式开始安装LAMP
1、安装apache2 -- sudo apt install apache2
$ sudo apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
liblua5.1-0 ssl-cert
Suggested packages:
......
2、安装php7.0
$ sudo apt install php7.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
php-common php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
php-pear
Setting up php7.0-json (7.0.32-0ubuntu0.16.04.1) ...
......
检查一下
$ php -v
PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
安装apache2 php7 module
$ sudo apt install libapache2-mod-php7.0
3、安装mysql
$ sudo apt install mysql-server mysql-client -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 22 newly installed, 0 to remove and 0 not upgraded.
......
中间会让你输入root的password
整合并重启php和mysql
$ sudo apt install php7.0-mysql
$ sudo service mysql restart
$ sudo service apache2 restart
4、安装phpmyadmin
$ sudo apt install phpmyadmin php-mbstring php-gettext
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dbconfig-common dbconfig-mysql fontconfig-config fonts-dejavu-core javascript-common libfontconfig1
libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-sphinxdoc libjs-underscore libmcrypt4
libtiff5 libvpx3 libxpm4 php-gd php-mcrypt php-pear php-phpseclib php-tcpdf php-xml php7.0-gd
php7.0-mbstring php7.0-mcrypt php7.0-xml
Suggested packages:
libgd-tools libmcrypt-dev mcrypt php-libsodium php-gmp php-imagick www-browser
The following NEW packages will be installed:
dbconfig-common dbconfig-mysql fontconfig-config fonts-dejavu-core javascript-common libfontconfig1
libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs- sphinxdoc libjs-underscore libmcrypt4
libtiff5 libvpx3 libxpm4 php-gd php-gettext php-mbstring php-mcrypt php-pear php-phpseclib php-tcpdf
php-xml php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-xml phpmyadmin
0 upgraded, 30 newly installed, 0 to remove and 0 not upgraded.
......
中间还要你设定phpmyadmin的密码
5、重启apache2, 出现以下画面就说明OK 了
如果不成功,先看下进程
$ ps -ef | grep apache2
root 19216 1 0 Oct06 ? 00:02:12 /usr/sbin/apache2 -k start
www-data 21549 19216 0 08:17 ? 00:00:00 /usr/sbin/apache2 -k start
。。。。。。
再检查一下防火墙 sudo iptables -L 和sudo ufw status 有没有开放80端口。