lamp环境搭建(ubuntu14.04 LTS)

lamp环境搭建(ubuntu14.04 LTS)

步骤:

1.获取源码包

$ sudo apt-get update

注意:

  使用以上命令可能会出现以下问题:用于apt-get操作时的lock(应该是用于互斥的锁),出现了不能够得到锁的问题

       E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

      E: Unable to lock directory /var/lib/apt/lists/

      E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

      E: Unable to lock the administration directory (/var/lib/dpkg/), is another process  using it?

  解决方法:

    方法一: $ sudo rm /var/lib/apt/lists/lock

                 $ sudo rm /var/cache/apt/archives/lock

      方法二:    

                $ apt-get update

           E: Could not open lock file /var/lib/apt/lists/lock open (13: Permission denied)

           E: Unable to lock directory /var/lib/apt/lists/

           E: Could not open lock file /var/lib/dpkg/lock open (13: Permission denied)

          E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

                sudo!!

       sudoapt-get update

     [ sudo ] password  for server:
 
     
 
     ..
      Fetched 474 kB  in 16s (28.0 kB /s )
         Reading package lists... Done
         server@localhost:~$
 
2.安装apache
 
  $ sudo apt-get install apache2
 
  检查apache2是否安装成功:显示以下apache2安装成功
 
  bybelief@ubuntu:~$ apache2 -v   Server version: Apache/2.4.7 (Ubuntu)   Server built: Jan 14 2016 17:45:23
 
 
3.安装php5
 
  $ sudo apt-get install php5
 
  查看libphp5是否被apache加载:
 
  bybelief@ubuntu:~$ cat /etc/apache2/mods-enabled/php5.load
  LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
 
4.安装mysql
  $ sudo apt-get install mysql-server 
  注意:安装mysql时,输入的是mysql的root密码
 
  查看mysql.ini是否安装:
  12.04版本的系统:cat /etc/php5/conf.d/mysql.ini
  14.04版本:cat /etc/php5/mods-available/mysql.ini 
 
  bybelief@ubuntu:~$ cat /etc/php5/mods-available/mysql.ini
  cat: /etc/php5/conf.d/mysql.ini: No such file or directory
  无安装,因为php默认不安装mysql.so扩展,需要手动安装,使用一下命令安装mysql扩展
  $ sudo apt-get install php5-mysql
 
  再次检查mysql.so是否加载:成功加载
  bybelief@ubuntu:~$ cat /etc/php5/mods-available/mysql.ini  
  ; configuration for php MySQL module
  ; priority=20
  extension=mysql.so
 
   5.重启服务
 
  保证服务正常,重启mysql服务
  $ sudo service mysql restar 
 
  保证服务正常,重启apache服务
  $ sudo service apache2 restart
 
  以上的可以通过一条命令实现安装
  方法一:sudo apt-get install apache2 php5 mysql-server php5-mysql
  方法二:sudo tasksel install lamp- server
 
6.测试
 
  切换到apache的www目录
  $ cd /var/www
 
  安装vim编辑器
  $ sudonstall  vim 
 
  创建phpinfo服务器指针:
  $ sudo vim info.php
 
7. 添加常用扩展
  $ sudo apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl
 
8.安装ssh
$  sudo ufw disable   关闭防火墙
$ sudo apt-get install openssh-server
$  sudo apt-get install ssh
 
如果无法远程登录:
$ sudo vim /etc/ssh/sshd_config
把配置文件中的"PermitRootLogin without-password"加一个"#"号,把它注释掉
把PermitRootLogin no 改为 yes
 
eg:
 $ sudo vim /etc/ssh/sshd_config
然后重启:
$  sudo service ssh restart
 
bybelief@ubuntu:/$ sudo vim /etc/ssh/sshd_config
[sudo] password for bybelief: 
Sorry, try again.
[sudo] password for bybelief: 
Sorry, try again.
[sudo] password for bybelief: 

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
#PermitRootLogin without-password
StrictModes yes
PermitRootLogin yes

RSAAuthentication yes
PubkeyAuthentication no

#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
PermitRootLogin yes
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

  

 
 
 
 
 
 

你可能感兴趣的:(lamp环境搭建(ubuntu14.04 LTS))