zoukankan      html  css  js  c++  java
  • Linux入门(三)搭建服务器linux运行环境LAMP/LNMP

    本文内容主要根据慕课网教学视频整理,原链接http://www.imooc.com/learn/170 

    我用的linux系统是ubuntu 12.04 LTS  虚拟机是VMware Workstation Pro12.1.0 远程管理工具是 xshell5。  

    ubuntu不能通过root账户远程连接。只能通过非root账户之外的普通账户连接。

    ubuntu需要安装ssh服务器后,才能使用xshell等远程工具连接。 

    sudo apt-get install openssh-server

     常见服务器环境 LAMP(Linux,Apache,Mysql,PHP) 和 LAMP(Linux,Nginx,Mysql,PHP) Nignx做负载均衡时候好一点。

    一次性安装多个软件包命令

     sudo apt-get install apache2 php5 mysql-server php5-mysql

    或者通过下面命令直接安装lamp环境。

    sudo apt-get install tasksel
    sudo
    tasksel install lamp-server

     单个安装命令汇总

     1.1首先获取所有软件最新列表

    zzc@ubuntu:~$ sudo apt-get update

     2.1 安装apache服务

    zzc@ubuntu:~$ sudo apt-get install apache2

    2.2 确认apache安装情况及版本信息  默认情况下apache的www目录 zzc@ubuntu:/var/www/html$ sudo vim info.php

    zzc@ubuntu:~$ apache2 -v

    2.3 在浏览器中确认 

    在浏览器中输入刚才通过ifconfig获取的服务器ip地址,我的是:http://192.168.174.128/

    3.1安装php运行环境

    zzc@ubuntu:~$ sudo apt-get install php5

    3.2 查看php版本信息 

    php5 -v   //php5.0
    php -v //php7.0

    3.3确认apache是否已经加载php服务模块

    ~$ cat /etc/apache2/mods-enabled/php5.load   #php5.0
    cat /etc/apache2/mods-enabled/php7.0.load   #php7.0

    4.1 安装mysql(中间需要设定数据库的密码)

    ~$ sudo apt-get install mysql-server

    4.2 确认mysql安装信息,这个命令和教学视频里面不一样

    cat /etc/php5/mods-available/mysql.ini     #php5.0
    cat /etc/php/7.0/mods-available/mysqli.ini #php7.0

    4.3 当出现cat: /etc/php5/conf.d/mysql.ini: No such file or directory说明没有被正常加载,需要执行下面命令。

    zzc@ubuntu:~$ sudo apt-get install php-mysql

    5.1重启mysql命令

    ~$ sudo service mysql restart

    5.2 重启apache服务

    zzc@ubuntu:~$ sudo service apache2 restart

    6.1安装php扩展 

    sudo apt-get install php5-gd  curl libcurl3 libcurl3-dev php5-curl

    sudo service apache2 restart //重启apapche服务

     单个安装软件详细步骤

     1 首先获取所有软件最新列表

    zzc@ubuntu:~$ sudo apt-get update
    zzc@ubuntu:~$ sudo apt-get update

    Ign http://us.archive.ubuntu.com trusty InRelease
    Hit http://security.ubuntu.com trusty-security InRelease
    Ign http://extras.ubuntu.com trusty InRelease
    Get:1 http://us.archive.ubuntu.com trusty-updates InRelease [65.9 kB]
    Hit http://extras.ubuntu.com trusty Release.gpg
    Hit http://security.ubuntu.com trusty-security/main Sources
    Hit http://extras.ubuntu.com trusty Release
    Hit http://security.ubuntu.com trusty-security/restricted Sources
    Hit http://security.ubuntu.com trusty-security/universe Sources
    Hit http://extras.ubuntu.com trusty/main Sources
    Hit http://security.ubuntu.com trusty-security/multiverse Sources
    Hit http://extras.ubuntu.com trusty/main amd64 Packages
    Hit http://security.ubuntu.com trusty-security/main amd64 Packages
    Hit http://security.ubuntu.com trusty-security/restricted amd64 Packages
    Hit http://extras.ubuntu.com trusty/main i386 Packages
    Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
    Hit http://us.archive.ubuntu.com trusty-backports InRelease
    Hit http://security.ubuntu.com trusty-security/multiverse amd64 Packages
    Hit http://us.archive.ubuntu.com trusty Release.gpg
    Hit http://security.ubuntu.com trusty-security/main i386 Packages
    Get:2 http://us.archive.ubuntu.com trusty-updates/main Sources [380 kB]
    Hit http://security.ubuntu.com trusty-security/restricted i386 Packages
    Hit http://security.ubuntu.com trusty-security/universe i386 Packages
    Hit http://security.ubuntu.com trusty-security/multiverse i386 Packages
    Hit http://security.ubuntu.com trusty-security/main Translation-en
    Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
    Hit http://security.ubuntu.com trusty-security/restricted Translation-en
    Hit http://security.ubuntu.com trusty-security/universe Translation-en
    Ign http://extras.ubuntu.com trusty/main Translation-en_US
    Ign http://extras.ubuntu.com trusty/main Translation-en
    Get:3 http://us.archive.ubuntu.com trusty-updates/restricted Sources [5,360 B]
    Get:4 http://us.archive.ubuntu.com trusty-updates/universe Sources [163 kB]
    Get:5 http://us.archive.ubuntu.com trusty-updates/multiverse Sources [7,137 B]
    Get:6 http://us.archive.ubuntu.com trusty-updates/main amd64 Packages [889 kB]
    Get:7 http://us.archive.ubuntu.com trusty-updates/restricted amd64 Packages [15.9 kB]
    Get:8 http://us.archive.ubuntu.com trusty-updates/universe amd64 Packages [373 kB]
    Get:9 http://us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [14.8 kB]
    Get:10 http://us.archive.ubuntu.com trusty-updates/main i386 Packages [851 kB]
    Get:11 http://us.archive.ubuntu.com trusty-updates/restricted i386 Packages [15.6 kB]
    Get:12 http://us.archive.ubuntu.com trusty-updates/universe i386 Packages [374 kB]
    Get:13 http://us.archive.ubuntu.com trusty-updates/multiverse i386 Packages [15.2 kB]
    Hit http://us.archive.ubuntu.com trusty-updates/main Translation-en
    Hit http://us.archive.ubuntu.com trusty-updates/multiverse Translation-en
    Hit http://us.archive.ubuntu.com trusty-updates/restricted Translation-en
    Hit http://us.archive.ubuntu.com trusty-updates/universe Translation-en
    Hit http://us.archive.ubuntu.com trusty-backports/main Sources
    Hit http://us.archive.ubuntu.com trusty-backports/restricted Sources
    Hit http://us.archive.ubuntu.com trusty-backports/universe Sources
    Hit http://us.archive.ubuntu.com trusty-backports/multiverse Sources
    Hit http://us.archive.ubuntu.com trusty-backports/main amd64 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/restricted amd64 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/universe amd64 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/main i386 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/restricted i386 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/universe i386 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/multiverse i386 Packages
    Hit http://us.archive.ubuntu.com trusty-backports/main Translation-en
    Hit http://us.archive.ubuntu.com trusty-backports/multiverse Translation-en
    Hit http://us.archive.ubuntu.com trusty-backports/restricted Translation-en
    Hit http://us.archive.ubuntu.com trusty-backports/universe Translation-en
    Hit http://us.archive.ubuntu.com trusty Release
    Hit http://us.archive.ubuntu.com trusty/main Sources
    Hit http://us.archive.ubuntu.com trusty/restricted Sources
    Hit http://us.archive.ubuntu.com trusty/universe Sources
    Hit http://us.archive.ubuntu.com trusty/multiverse Sources
    Hit http://us.archive.ubuntu.com trusty/main amd64 Packages
    Hit http://us.archive.ubuntu.com trusty/restricted amd64 Packages
    Hit http://us.archive.ubuntu.com trusty/universe amd64 Packages
    Hit http://us.archive.ubuntu.com trusty/multiverse amd64 Packages
    Hit http://us.archive.ubuntu.com trusty/main i386 Packages
    Hit http://us.archive.ubuntu.com trusty/restricted i386 Packages
    Hit http://us.archive.ubuntu.com trusty/universe i386 Packages
    Hit http://us.archive.ubuntu.com trusty/multiverse i386 Packages
    Hit http://us.archive.ubuntu.com trusty/main Translation-en
    Hit http://us.archive.ubuntu.com trusty/multiverse Translation-en
    Hit http://us.archive.ubuntu.com trusty/restricted Translation-en
    Hit http://us.archive.ubuntu.com trusty/universe Translation-en
    Ign http://us.archive.ubuntu.com trusty/main Translation-en_US
    Ign http://us.archive.ubuntu.com trusty/multiverse Translation-en_US
    Ign http://us.archive.ubuntu.com trusty/restricted Translation-en_US
    Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US
    Fetched 3,170 kB in 1min 9s (45.9 kB/s)
    Reading package lists... Done
    zzc@ubuntu:~$

     2.1安装apache服务

    zzc@ubuntu:~$ sudo apt-get install apache2

    zzc@ubuntu:~$ sudo apt-get install apache2

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    libntdb1 python-ntdb
    Use 'apt-get autoremove' to remove them.
    The following extra packages will be installed:
    apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
    libaprutil1-ldap
    Suggested packages:
    apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
    The following NEW packages will be installed:
    apache2 apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
    libaprutil1-ldap
    0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,267 kB of archives.
    After this operation, 5,244 kB of additional disk space will be used.
    Do you want to continue? [Y/n]

     y

    Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]

    Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1 amd64 1.5.3-1 [76.4 kB]
    Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1-dbd-sqlite3 amd64 1.5.3-1 [10.5 kB]
    Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaprutil1-ldap amd64 1.5.3-1 [8,634 B]
    Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2-bin amd64 2.4.7-1ubuntu4.13 [839 kB]
    Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2-data all 2.4.7-1ubuntu4.13 [160 kB]
    Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main apache2 amd64 2.4.7-1ubuntu4.13 [87.4 kB]
    Fetched 1,267 kB in 8s (145 kB/s)
    Selecting previously unselected package libapr1:amd64.
    (Reading database ... 199961 files and directories currently installed.)
    Preparing to unpack .../libapr1_1.5.0-1_amd64.deb ...
    Unpacking libapr1:amd64 (1.5.0-1) ...
    Selecting previously unselected package libaprutil1:amd64.
    Preparing to unpack .../libaprutil1_1.5.3-1_amd64.deb ...
    Unpacking libaprutil1:amd64 (1.5.3-1) ...
    Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
    Preparing to unpack .../libaprutil1-dbd-sqlite3_1.5.3-1_amd64.deb ...
    Unpacking libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
    Selecting previously unselected package libaprutil1-ldap:amd64.
    Preparing to unpack .../libaprutil1-ldap_1.5.3-1_amd64.deb ...
    Unpacking libaprutil1-ldap:amd64 (1.5.3-1) ...
    Selecting previously unselected package apache2-bin.
    Preparing to unpack .../apache2-bin_2.4.7-1ubuntu4.13_amd64.deb ...
    Unpacking apache2-bin (2.4.7-1ubuntu4.13) ...
    Selecting previously unselected package apache2-data.
    Preparing to unpack .../apache2-data_2.4.7-1ubuntu4.13_all.deb ...
    Unpacking apache2-data (2.4.7-1ubuntu4.13) ...
    Selecting previously unselected package apache2.
    Preparing to unpack .../apache2_2.4.7-1ubuntu4.13_amd64.deb ...
    Unpacking apache2 (2.4.7-1ubuntu4.13) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    Processing triggers for ufw (0.34~rc-0ubuntu2) ...
    Setting up libapr1:amd64 (1.5.0-1) ...
    Setting up libaprutil1:amd64 (1.5.3-1) ...
    Setting up libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
    Setting up libaprutil1-ldap:amd64 (1.5.3-1) ...
    Setting up apache2-bin (2.4.7-1ubuntu4.13) ...
    Setting up apache2-data (2.4.7-1ubuntu4.13) ...
    Setting up apache2 (2.4.7-1ubuntu4.13) ...
    Enabling module mpm_event.
    Enabling module authz_core.
    Enabling module authz_host.
    Enabling module authn_core.
    Enabling module auth_basic.
    Enabling module access_compat.
    Enabling module authn_file.
    Enabling module authz_user.
    Enabling module alias.
    Enabling module dir.
    Enabling module autoindex.
    Enabling module env.
    Enabling module mime.
    Enabling module negotiation.
    Enabling module setenvif.
    Enabling module filter.
    Enabling module deflate.
    Enabling module status.
    Enabling conf charset.
    Enabling conf localized-error-pages.
    Enabling conf other-vhosts-access-log.
    Enabling conf security.
    Enabling conf serve-cgi-bin.
    Enabling site 000-default.
    * Starting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    *
    Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    Processing triggers for ufw (0.34~rc-0ubuntu2) ...
    zzc@ubuntu:~$ 

    2.2 确认apache安装情况及版本信息

    zzc@ubuntu:~$ apache2 -v

    Server version: Apache/2.4.7 (Ubuntu)
    Server built: Jul 15 2016 15:34:04 

      2.3在浏览器中输入刚才通过ifconfig获取的服务器ip地址,我的是:http://192.168.174.128/



    3.1安装php运行环境
    zzc@ubuntu:~$ sudo apt-get install php5

    Reading package lists... Done

    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    libntdb1 python-ntdb
    Use 'apt-get autoremove' to remove them.
    The following extra packages will be installed:
    libapache2-mod-php5 php5-cli php5-common php5-json php5-readline
    Suggested packages:
    php-pear php5-user-cache
    The following NEW packages will be installed:
    libapache2-mod-php5 php5 php5-cli php5-common php5-json php5-readline
    0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
    Need to get 4,866 kB of archives.
    After this operation, 20.5 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main php5-json amd64 1.3.2-2build1 [34.4 kB]
    Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-common amd64 5.5.9+dfsg-1ubuntu4.19 [446 kB]
    Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-cli amd64 5.5.9+dfsg-1ubuntu4.19 [2,164 kB]
    Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-readline amd64 5.5.9+dfsg-1ubuntu4.19 [12.1 kB]
    Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libapache2-mod-php5 amd64 5.5.9+dfsg-1ubuntu4.19 [2,207 kB]
    Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5 all 5.5.9+dfsg-1ubuntu4.19 [1,308 B]
    Fetched 4,866 kB in 2min 21s (34.4 kB/s)
    Selecting previously unselected package php5-json.
    (Reading database ... 200595 files and directories currently installed.)
    Preparing to unpack .../php5-json_1.3.2-2build1_amd64.deb ...
    Unpacking php5-json (1.3.2-2build1) ...
    Selecting previously unselected package php5-common.
    Preparing to unpack .../php5-common_5.5.9+dfsg-1ubuntu4.19_amd64.deb ...
    Unpacking php5-common (5.5.9+dfsg-1ubuntu4.19) ...
    Selecting previously unselected package php5-cli.
    Preparing to unpack .../php5-cli_5.5.9+dfsg-1ubuntu4.19_amd64.deb ...
    Unpacking php5-cli (5.5.9+dfsg-1ubuntu4.19) ...
    Selecting previously unselected package php5-readline.
    Preparing to unpack .../php5-readline_5.5.9+dfsg-1ubuntu4.19_amd64.deb ...
    Unpacking php5-readline (5.5.9+dfsg-1ubuntu4.19) ...
    Selecting previously unselected package libapache2-mod-php5.
    Preparing to unpack .../libapache2-mod-php5_5.5.9+dfsg-1ubuntu4.19_amd64.deb ...
    Unpacking libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.19) ...
    Selecting previously unselected package php5.
    Preparing to unpack .../php5_5.5.9+dfsg-1ubuntu4.19_all.deb ...
    Unpacking php5 (5.5.9+dfsg-1ubuntu4.19) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Setting up php5-json (1.3.2-2build1) ...
    php5_invoke: Enable module json for apache2 SAPI
    php5_invoke: Enable module json for cli SAPI
    Setting up php5-common (5.5.9+dfsg-1ubuntu4.19) ...

    
    

    Creating config file /etc/php5/mods-available/pdo.ini with new version
    php5_invoke: Enable module pdo for apache2 SAPI
    php5_invoke: Enable module pdo for cli SAPI

    
    

    Creating config file /etc/php5/mods-available/opcache.ini with new version
    php5_invoke: Enable module opcache for apache2 SAPI
    php5_invoke: Enable module opcache for cli SAPI
    Setting up php5-cli (5.5.9+dfsg-1ubuntu4.19) ...
    update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode

    
    

    Creating config file /etc/php5/cli/php.ini with new version
    php5_invoke json: already enabled for cli SAPI
    php5_invoke opcache: already enabled for cli SAPI
    php5_invoke pdo: already enabled for cli SAPI
    Setting up php5-readline (5.5.9+dfsg-1ubuntu4.19) ...

    
    

    Creating config file /etc/php5/mods-available/readline.ini with new version
    php5_invoke: Enable module readline for apache2 SAPI
    php5_invoke: Enable module readline for cli SAPI
    Setting up libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.19) ...

    
    

    Creating config file /etc/php5/apache2/php.ini with new version
    php5_invoke json: already enabled for apache2 SAPI
    php5_invoke readline: already enabled for apache2 SAPI
    php5_invoke opcache: already enabled for apache2 SAPI
    php5_invoke pdo: already enabled for apache2 SAPI
    Module mpm_event disabled.
    Enabling module mpm_prefork.
    apache2_switch_mpm Switch to prefork
    * Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    [ OK ]
    apache2_invoke: Enable module php5
    * Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    [ OK ]
    Setting up php5 (5.5.9+dfsg-1ubuntu4.19) ...
    zzc@ubuntu:~$

    3.2查看php版本信息 
    ~$ php5 -v

     

    zzc@ubuntu:~$ php5 -v
    PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

    3.3确认apache是否已经加载php服务模块 

    ~$ cat /etc/apache2/mods-enabled/php5.load

     zzc@ubuntu:~$ cat /etc/apache2/mods-enabled/php5.load

    LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

    4.1 安装mysql

    ~$ sudo apt-get install mysql-server

     

    zzc@ubuntu:~$ sudo apt-get install mysql-server

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    libntdb1 python-ntdb
    Use 'apt-get autoremove' to remove them.
    The following extra packages will be installed:
    libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
    libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
    mysql-server-5.5 mysql-server-core-5.5
    Suggested packages:
    libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perl
    libipc-sharedcache-perl tinyca mailx
    The following NEW packages will be installed:
    libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
    libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
    mysql-server mysql-server-5.5 mysql-server-core-5.5
    0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
    Need to get 9,601 kB of archives.
    After this operation, 97.1 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
    Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.50-0ubuntu0.14.04.1 [12.9 kB]
    Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.50-0ubuntu0.14.04.1 [595 kB]
    Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl amd64 1.630-1 [879 kB]
    Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbd-mysql-perl amd64 4.025-1 [99.3 kB]
    Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]
    Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.50-0ubuntu0.14.04.1 [709 kB]
    Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.50-0ubuntu0.14.04.1 [1,594 kB]
    Get:9 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.50-0ubuntu0.14.04.1 [3,730 kB]
    Get:10 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.50-0ubuntu0.14.04.1 [1,871 kB]
    Get:11 http://us.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB]
    Get:12 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.50-0ubuntu0.14.04.1 [11.3 kB]
    Fetched 9,601 kB in 2min 11s (73.2 kB/s)
    Preconfiguring packages ...
    Selecting previously unselected package libaio1:amd64.
    (Reading database ... 200683 files and directories currently installed.)
    Preparing to unpack .../libaio1_0.3.109-4_amd64.deb ...
    Unpacking libaio1:amd64 (0.3.109-4) ...
    Selecting previously unselected package mysql-common.
    Preparing to unpack .../mysql-common_5.5.50-0ubuntu0.14.04.1_all.deb ...
    Unpacking mysql-common (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package libmysqlclient18:amd64.
    Preparing to unpack .../libmysqlclient18_5.5.50-0ubuntu0.14.04.1_amd64.deb ...
    Unpacking libmysqlclient18:amd64 (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package libdbi-perl.
    Preparing to unpack .../libdbi-perl_1.630-1_amd64.deb ...
    Unpacking libdbi-perl (1.630-1) ...
    Selecting previously unselected package libdbd-mysql-perl.
    Preparing to unpack .../libdbd-mysql-perl_4.025-1_amd64.deb ...
    Unpacking libdbd-mysql-perl (4.025-1) ...
    Selecting previously unselected package libterm-readkey-perl.
    Preparing to unpack .../libterm-readkey-perl_2.31-1_amd64.deb ...
    Unpacking libterm-readkey-perl (2.31-1) ...
    Selecting previously unselected package mysql-client-core-5.5.
    Preparing to unpack .../mysql-client-core-5.5_5.5.50-0ubuntu0.14.04.1_amd64.deb ...
    Unpacking mysql-client-core-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package mysql-client-5.5.
    Preparing to unpack .../mysql-client-5.5_5.5.50-0ubuntu0.14.04.1_amd64.deb ...
    Unpacking mysql-client-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package mysql-server-core-5.5.
    Preparing to unpack .../mysql-server-core-5.5_5.5.50-0ubuntu0.14.04.1_amd64.deb ...
    Unpacking mysql-server-core-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Setting up mysql-common (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package mysql-server-5.5.
    (Reading database ... 201046 files and directories currently installed.)
    Preparing to unpack .../mysql-server-5.5_5.5.50-0ubuntu0.14.04.1_amd64.deb ...
    Unpacking mysql-server-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Selecting previously unselected package libhtml-template-perl.
    Preparing to unpack .../libhtml-template-perl_2.95-1_all.deb ...
    Unpacking libhtml-template-perl (2.95-1) ...
    Selecting previously unselected package mysql-server.
    Preparing to unpack .../mysql-server_5.5.50-0ubuntu0.14.04.1_all.deb ...
    Unpacking mysql-server (5.5.50-0ubuntu0.14.04.1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Setting up libaio1:amd64 (0.3.109-4) ...
    Setting up libmysqlclient18:amd64 (5.5.50-0ubuntu0.14.04.1) ...
    Setting up libdbi-perl (1.630-1) ...
    Setting up libdbd-mysql-perl (4.025-1) ...
    Setting up libterm-readkey-perl (2.31-1) ...
    Setting up mysql-client-core-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Setting up mysql-client-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Setting up mysql-server-core-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    Setting up mysql-server-5.5 (5.5.50-0ubuntu0.14.04.1) ...
    160904 6:50:43 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
    160904 6:50:43 [Note] /usr/sbin/mysqld (mysqld 5.5.50-0ubuntu0.14.04.1) starting as process 10515 ...
    mysql start/running, process 10647
    Setting up libhtml-template-perl (2.95-1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    Setting up mysql-server (5.5.50-0ubuntu0.14.04.1) ...
    Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
    zzc@ubuntu:~$

    4.2查看mysql服务是否被正常加载 

    cat /etc/php5/mods-available/mysql.ini

    zzc@ubuntu:~$ cat /etc/php5/mods-available/mysql.ini


    cat: /etc/php5/conf.d/mysql.ini: No such file or directory

    说明mysql没有被正常加载

     4.3 执行下面命令

    zzc@ubuntu:~$ sudo apt-get install php-mysql

    zzc@ubuntu:~$ cat /etc/php5/conf.d/mysql.ini
    cat: /etc/php5/conf.d/mysql.ini: No such file or directory
    zzc@ubuntu:~$ sudo apt-get install php-mysql
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package php-mysql
    zzc@ubuntu:~$ sudo apt-get install php5-mysql
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    libntdb1 python-ntdb
    Use 'apt-get autoremove' to remove them.
    The following NEW packages will be installed:
    php5-mysql
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 62.8 kB of archives.
    After this operation, 297 kB of additional disk space will be used.
    Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-mysql amd64 5.5.9+dfsg-1ubuntu4.19 [62.8 kB]
    Fetched 62.8 kB in 1s (33.0 kB/s)
    Selecting previously unselected package php5-mysql.
    (Reading database ... 201146 files and directories currently installed.)
    Preparing to unpack .../php5-mysql_5.5.9+dfsg-1ubuntu4.19_amd64.deb ...
    Unpacking php5-mysql (5.5.9+dfsg-1ubuntu4.19) ...
    Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.19) ...
    Setting up php5-mysql (5.5.9+dfsg-1ubuntu4.19) ...

    Creating config file /etc/php5/mods-available/mysql.ini with new version
    php5_invoke: Enable module mysql for apache2 SAPI
    php5_invoke: Enable module mysql for cli SAPI

    Creating config file /etc/php5/mods-available/mysqli.ini with new version
    php5_invoke: Enable module mysqli for apache2 SAPI
    php5_invoke: Enable module mysqli for cli SAPI

    Creating config file /etc/php5/mods-available/pdo_mysql.ini with new version
    php5_invoke: Enable module pdo_mysql for apache2 SAPI
    php5_invoke: Enable module pdo_mysql for cli SAPI
    Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.19) ...

    4.4再次确认mysql

    zzc@ubuntu:~$ cat /etc/php5/mods-available/mysql.ini

    zzc@ubuntu:~$ cat /etc/php5/mods-available/mysql.ini
    ; configuration for php MySQL module
    ; priority=20
    extension=mysql.so

    5.1重启mysql命令

    ~$ sudo service mysql restart

    zzc@ubuntu:~$ sudo service mysql restart

    mysql stop/waiting
    mysql start/running, process 11517

    5.2重启apache服务

    zzc@ubuntu:~$ sudo service apache2 restart

    zzc@ubuntu:~$ sudo service apache2 restart

    * Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    [ OK ]

     

    请把你的疑问评论在下方。
  • 相关阅读:
    Oracle使用序列创建自增字段(主键自动增长)
    Oracle 增加修改删除字段
    JavaScript trim函数大赏
    js跨域问题
    document.getElementsByClassName的理想实现
    IIS启用Gzip的方法与优缺点分析
    浅释跳转漏洞
    js跨域及解决方法
    C#编写COM组件
    50种方法巧妙优化你的SQL Server数据库
  • 原文地址:https://www.cnblogs.com/zzcit/p/5821365.html
Copyright © 2011-2022 走看看