您的位置:首页 > 运维架构 > Linux

#ubuntu LAMP服务器配置文档

2017-11-12 00:00 399 查看
##环境说明
阿里云服务器ECS
ubuntu16.04操作系统
已有root用户,可以通过SSH远程访问(该处配置请补充)

——
##目标
搭建LAMP服务器,完成应用服务器的配置

——

##步骤

###添加访问规则
实例–>更多–>安全组配置–>配置规则–>克隆22端口规则–>修改协议规则为http(80),保存即可

###升级系统现有软件
`#`为系统提示符,表示现有用户为root用户
执行以下命令
`#apt-get install update`
`#apt-get install dist-upgrade`
所有选项均选择`Y`,完成系统升级
升级完成后,重启系统
`#reboot`

###安装apache/php/mysql环境

####安装apache2
`#apt-get install apache2`
查看apache版本
`#apache2 -v`

`Server version: Apache/2.4.18 (Ubuntu)`
`Server built: 2017-05-05T16:32:00`
apache安装完成

#### 安装php7
`#apt-get install php7.0`
查看php7版本
`#php -v`

`PHP 7.0.18-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.18-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies`

安装PHP7 for apache2的模块
`#apt-get install libapache2-mod-php7.0`
检查模块是否正常安装
`#cat /etc/apache2/mods-enabled/php7.0.load`

`# Conflicts: php5`
`LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so`
php安装完成

#### 安装mysql
`#apt-get install mysql-server mysql-client`

#过程中需要输入mysql的root密码,请设置后立刻记录下来

#### 安装php7 for mysql
`#apt-get install php7.0-mysql`

#### 重启服务器
`#reboot`

#### 检查安装结果
`#cd /var/www/html`
`#vi phpinfo.php`
内容为:
`<?php
phpinfo();
?>`
保存退出
访问:http://ip地址/phpinfo.php

#### 安装phpmyadmin
`#apt-get install phpmyadmin`

访问地址:http://ip地址/phpmyadmin

#务必建立linux新用户,禁止使用linux root用户进行登录
#务必建立MySql新用户,禁止使用mysql root用户进行登录

## 补充

#### 更换阿里源
`sudo mv /etc/apt/source.list bak.source.list`
`sudo vi /etc/apt/source.list`
加入如下内容:
`deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse`
`deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse`
`deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse`
`deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse`

`deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse`

`deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse`
`deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse`
`deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse`
`deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse`

`deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse`

`deb http://archive.canonical.com/ubuntu/ xenial partner`
`deb http://extras.ubuntu.com/ubuntu/ xenial main`

#### ssh登录报错的处理:
修改`/etc/ssh/sshd_config`
在文件末尾添加如下内容
`Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc`
`MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96`
`KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org`
保存,重启即可

#### php curl模块安装
`#apt-get install php7.0-curl`
重启apache
`#/etc/init.d/apache2 restart`

#### apache rewrite模块安装
`#cd /etc/apache2/mod-enable`
`#ln -s /etc/apache2/mod-available/rewrite.load rewrite.load`
重启apache
`#/etc/init.d/apache2 restart`

#### 安装npm&apidoc

`apt-get install npm`
安装apidoc
`npm install apidoc -g`
增加链接
`ln -s /usr/bin/nodejs /usr/bin/node`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux LAMP