您的位置:首页 > 理论基础 > 计算机网络

Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP) 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http

2017-12-19 22:42 866 查看
之前整过CentOS,整了Ubuntu才发现,Ubuntu简单多了~~不知道性能相比又如何。

以Ubtuntu 14.04为例,记录一下搭建流程。

一、安装注意点

1. IP地址

安装时先不要插网线,不然会DHCP,后续配置起来也麻烦

2. 硬盘分区

自动分区貌似有:/、swap、efiswap、/boot(200MB) 

实际两个区就足够了:swap为内存的1~2倍大小,剩余皆为/

二、IP配置

装完后一般远程连接,需要配置ip地址,以下是多ip配置。(安装时会以向导形式配好一个IP,修改时只要复制粘贴就可以)

vi /etc/network/interfaces配置信息:

 # The primary network interface

 auto em0

 iface em0 inet static

         address 192.168.1.1

         netmask 255.255.252.0

         network 192.168.1.0

         broadcast 192.168.1.255

         gateway 192.168.8.254

         # dns-* options are implemented by the resolvconf package, if installed

         dns-nameservers 8.8.8.8 8.8.8.9

         # dns-search 163.com

 # The second network interface

 auto em1

 iface em1 inet static

         address 192.168.1.2

         netmask 255.255.252.0

         network 192.168.1.0

重启网卡(貌似不一定生效,reboot肯定可以)

/etc/init.d/networking restart三、SSH服务器

默认安装后vi /etc/ssh/sshd_config,修改配置文件。 

安全起见,可以建立允许列表:

1. 修改/etc/hosts.allow:

sshd: 192.168.1. , 192.168.0. : allow2. 修改/etc/hosts.deny:

sshd : ALL四、系统更新

先更新源,用以Trusty Tahr (14.04)为例,其他版本看配置生成器

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse再更新apt-get

apt-get update

sudo apt-get upgrade然后更新系统并重启

sudo apt-get install update五、Samba安装网上邻居

默认安装 apt-get install samba 

为samba创建ubuntu系统已经存在的用户somebody: 

smbpasswd -a somebody然后会提示你输入密码,这是访问网上邻居文件夹的密码。 

3. 修改配置文件:

cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

vi /etc/samba/smb.conf在其后增加共享目录:

[share]

    path = /home/somebody/samba_share

      available = yes 

      browseable = yes 

      public = no 

      writable = yes重启samba就可以像windows一样访问 

/etc/init.d/samba restart 六、安装apache2

apt-get install apache2  装好后访问http://localhost就可以看到“It Works!” 

apache2配置文件在/etc/apache2/apache2.conf,web目录在/var/www/html

默认用户是www-data,定义在./envvars文件中

其他配置文件在:./sites-enabled/*.conf

七、安装mysql

apt-get install mysql-server mysql-client安装过程需要设置root的密码。Ubuntu下,MySQL的配置信息在/etc/mysql目录

MySQL默认的字符集是latin1: 

 

为了避免中文可能带来的乱码问题,将默认字符集改成utf-8,具体可以参考这篇文章,修改 /etc/mysql/my.cnf 文件,在相应位置添加:

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[mysqld]

collation-server = utf8_unicode_ci

init-connect='SET NAMES utf8'

character-set-server = utf8修改后是这样的: 

八、安装php5及Apache的php5模块

apt-get install php5 libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xslOK! It Works!

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2015-06/119061.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐