前言
所有的环境包都可以在此目录下载
http://learning.happymmall.com/
1.jdk环境安装
查看默认环境
[johnson@localhost ~]$ rpm -qa|grep jdk [johnson@localhost ~]$ java -version
如果有的话删除掉
sudo yum remove jdkk
下载地址
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
安装JDK
安装之前需要赋予权限,否则有些文件无法正确安装
sudo chmod 777 jdk-7u80-linux-x64.rpm
执行安装
sudo rpm -ivh '/var/run/vmblock-fuse/blockdir/52cdae8f-16d8-65ca-c2ae-d6122688ebee/jdk-7u80-linux-x64.rpm'
配置环境变量
``#set java env
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH`
2.tomcat安装
下载和安装
登录http://learning.happymmall.com/
wget http://learning.happymmall.com/tomcat/apache-tomcat-7.0.73.tar.gz
解压缩
tar -xzvf apache-tomcat-7.0.73.tar.gz
配置环境变量
sudo vim /etc/profile
export CATALINA_HOME=/home/johnson/server_home/apache-tomcat-7.0.73
source /etc/profile
配置tomact
配置UTF-8字符集
sudo vim $CATALINA_HOME/conf/server.xml
找到配置8080默认端口的位置,在xml节点末尾增加URIEncoding="UTF-8"
验证tomcat安装
cd $CATALINA_HOME/bin
./startup.sh
得到如下的输出,表示启动成功
[johnson@localhost bin]$ ./startup.sh Using CATALINA_BASE: /home/johnson/server_home/apache-tomcat-7.0.73 Using CATALINA_HOME: /home/johnson/server_home/apache-tomcat-7.0.73 Using CATALINA_TMPDIR: /home/johnson/server_home/apache-tomcat-7.0.73/temp Using JRE_HOME: /usr/java/jdk1.7.0_80 Using CLASSPATH: /home/johnson/server_home/apache-tomcat-7.0.73/bin/bootstrap.jar:/home/johnson/server_home/apache-tomcat-7.0.73/bin/tomcat-juli.jar Tomcat started
访问8080端口,看是否能启动
3.Maven的安装配置
下载和安装
wget http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz
tar -zxvf apache-maven-3.0.5-bin.tar.gz
path配置
[johnson@localhost apache-maven-3.0.5]$ sudo vim /etc/profile
#写profile
export MAVEN_HOME=/home/johnson/server_home/apache-maven-3.0.5 set PATH 这个是再之前的path上再添加 export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
[johnson@localhost apache-maven-3.0.5]$ source /etc/profile
验证配置
[johnson@localhost apache-maven-3.0.5]$ mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28-0800) Maven home: /home/johnson/server_home/apache-maven-3.0.5 Java version: 1.7.0_80, vendor: Oracle Corporation Java home: /usr/java/jdk1.7.0_80/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-642.el6.x86_64", arch: "amd64", family: "unix"
表明配置成功
4.vsftpd的安装配置
####### 下载和安装
[johnson@localhost apache-maven-3.0.5]$ sudo yum -y install vsftpd
根目录下创建ftp目录
[johnson@localhost apache-maven-3.0.5]$ cd / [johnson@localhost /]$ sudo mkdir ftpfile
####### 配置用户
配置一个只有访问ftpfile权限的用户
[johnson@localhost /]$ sudo useradd ftpuser -d /ftpfile -s /sbin/nologin useradd: warning: the home directory already exists. Not copying any file from skel directory into it. [johnson@localhost /]$ sudo chown -R ftpuser.ftpuser /ftpfile/ [johnson@localhost /]$ ll | grep ftp drwxr-xr-x. 2 ftpuser ftpuser 4096 Jun 15 09:25 ftpfile [johnson@localhost /]$ sudo passwd ftpuser Changing password for user ftpuser. New password: Retype new password: passwd: all authentication tokens updated successfull
####### 配置ftp的配置文件,指向配置的用户,目录
创建index文件
[johnson@localhost /]$ cd ftpfile/ [johnson@localhost ftpfile]$ sudo vim index.html [johnson@localhost ftpfile]$ more index.html here is the ftpfile /ftpfile [johnson@localhost ftpfile]$ whereis vsftpd vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz [johnson@localhost ftpfile]$ sudo vim /etc/vsftpd/vsftpd.conf
#修改如下的信息
#是否允许匿名访问
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#You may fully customise the login banner string:
ftpd_banner=Welcome to zhenyu FTP service. local_root=/ftpfile use_localtime=yes
#把我们新建的用户添加到chroot_list中 You may specify an explicit list of local users to chroot() to their home directory. If chroot_local_user is YES, then this list becomes a list of users to NOT chroot().
#chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
#配置被动链接端口范围
pasv_min_port=61001 pasv_max_port=62000
####### 重启服务
[johnson@localhost ~]$ sudo service vsftpd restart
5.Iptable配置
[johnson@localhost sysconfig]$ pwd /etc/sysconfig [johnson@localhost sysconfig]$ sudo vim iptables
#vsftpd
-A INPUT -p TCP --dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT
-A INPUT -p TCP --dport 20 -j ACCEPT
-A OUTPUT -p TCP --dport 20 -j ACCEPT
-A INPUT -p TCP --dport 21 -j ACCEPT
-A OUTPUT -p TCP --dport 21 -j ACCEPT
####### 重启服务
[johnson@localhost ~]$ sudo service iptables restart iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ]
####### 额外提醒
如果出现550错误修改下面的
[johnson@localhost ~]$ sudo vim /etc/selinux/config selinux=disabled
如果index.html主页没出现,重启主机
[johnson@localhost ~]$ reboot' ####### 额外提醒2 默认情况下,很多linux服务器是没有安装ftp指令的,我们需要安装一下
[johnson@localhost ~]$ sudo yum install ftp`
6.配置nginx服务器
####### 下载和安装
首先安装nginx依赖包
[johnson@localhost Desktop]$ sudo yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel'
nginx下载和解压
[johnson@localhost Desktop]$ wget http://learning.happymmall.com/nginx/linux-nginx-1.10.2.tar.gz
然后解压并放到相关目录(略)
#######检查依赖以及编译
[johnson@localhost nginx-1.10.2]$ ./configure [johnson@localhost nginx-1.10.2]$ make [johnson@localhost nginx-1.10.2]$ sudo make install
#######启动和检查安装情况
[johnson@localhost nginx-1.10.2]$ whereis nginx nginx: /usr/local/nginx [johnson@localhost nginx-1.10.2]$ cd /usr/local/nginx [johnson@localhost nginx]$ ls conf html logs sbin [johnson@localhost nginx]$ cd sbin/ [johnson@localhost sbin]$ ls nginx [johnson@localhost sbin]$ sudo ./nginx [johnson@localhost sbin]$ ps aux|grep nginx root 5678 0.0 0.0 23968 820 ? Ss 20:12 0:00 nginx: master process ./nginx nobody 5679 0.0 0.1 24388 1400 ? S 20:12 0:00 nginx: worker process johnson 5682 0.0 0.0 103316 844 pts/2 S+ 20:13 0:00 grep nginx
#######转发配置举例
[johnson@localhost conf]$ pwd /usr/local/nginx/conf [johnson@localhost conf]$ sudo vim nginx.conf
此文件有几个地方需要修改(可选)
1)配置启动用户的权限
#user nobody 以当前用户启动nginx, 修改为 user root 可以以root用户启动nginx,在访问nginx出现权限问题的时候可能需要修改此处
2)添加各个需要转发域名的配置信息
http { include mime.types; include vhost/*.conf;
上面的include vhost/*.conf会将vhost目录下的各个域名的配置规则都加载进来,具体的规则写在各个.conf文件中,如下所示
[johnson@localhost vhost]$ ls image.imoc.com.conf www.imoc.com.conf
当然对应的域名解析或本地/etc/hosts,或通过域名服务器都要提前做好
7.mysql的安装配置
####### 删除现有数据库
[johnson@localhost etc]$ yum list installed | grep mysql mysql.x86_64 5.1.73-8.el6_8 @base mysql-devel.x86_64 5.1.73-8.el6_8 @base mysql-libs.x86_64 5.1.73-8.el6_8 @base mysql-server.x86_64 5.1.73-8.el6_8 @base [johnson@localhost etc]$ yum -y remove mysql.x86_64 (此处为对应的版本)
####### mysql 安装和配置
[johnson@localhost sbin]$ sudo yum install mysql-server [johnson@localhost sbin]$ sudo vim /etc/my.cnf `#添加下面几行` character-set-server = utf8
这时候要先检查一下mysql能否正常启动
[johnson@localhost ~]$ sudo service mysqld start
如果返回dameon启动失败
MySQL Daemon failed to start. Starting mysqld:
并且通过log查看出如下的错误
/usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 170615 23:31:33 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 。。。
说明你需要初始化你的系统数据库,执行如下命令
[johnson@localhost ~]$ sudo mysql_install_db
重启服务,发现ok
#######设置随机启动
[johnson@localhost sbin]$ sudo chkconfig mysqld on [johnson@localhost sbin]$ sudo chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
####### 权限设置
刚开始的时候进入mysql
[johnson@localhost ~]$ mysql -u root
查看当前所有的user
mysql> select user,host from mysql.user; +---------+-----------------------+ | user | host | +---------+-----------------------+ | johnson | % | | mmall | % | | root | 127.0.0.1 | | johnson | localhost | | root | localhost | | root | localhost.localdomain | +---------+-----------------------+ 6 rows in set (0.00 sec)
赋予johnson给所有访问的权限
mysql> GRANT ALL PRIVILEGES ON mmall.* TO 'johnson'@'%' WITH GRANT OPTION;
查看权限是否赋予成功
mysql> SHOW GRANTS FOR johnson -> ; +--------------------------------------------------------------------------------------------------------+ | Grants for johnson@% | +--------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'johnson'@'%' IDENTIFIED BY PASSWORD '*E44906C147933E2BAB32483950C8FA04041146CE' | | GRANT ALL PRIVILEGES ON `mmall`.* TO 'johnson'@'%' WITH GRANT OPTION | | GRANT SELECT, DELETE, CREATE ON `johnson`.* TO 'johnson'@'%' WITH GRANT OPTION | | GRANT SELECT, DELETE, CREATE ON `mmall`.`mmall.*` TO 'johnson'@'%' WITH GRANT OPTION | +--------------------------------------------------------------------------------------------------------+ 4 rows in set (0.00 sec)
刷新权限
mysql> flush privileges;
设置root用户密码(默认是无密码进入)
mysql> set password for root@127.0.0.1=password('root'); mysql> set password for root@localhost=password('root');
查看密码
mysql> select user,host,password from mysql.user ; +---------+-----------------------+-------------------------------------------+ | user | host | password | +---------+-----------------------+-------------------------------------------+ | root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | | root | localhost.localdomain | | | root | 127.0.0.1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | | johnson | localhost | 181158621 | | johnson | % | *E44906C147933E2BAB32483950C8FA04041146CE | | mmall | % | *E44906C147933E2BAB32483950C8FA04041146CE |
退出mysql,重新进入
[johnson@localhost ~]$ mysql -u root -p
之后输入密码‘root’,进入mysql
######## 最后利用本机的navicat进行测试,看是否能登录成功
8.配置git
####### 安装git
所需要的依赖包
sudo yum -y install wget curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker gcc asciidoc xmlto docbook2x
下载git
[johnson@localhost .ssh]$ wget https://github.com/git/git/archive/v2.12.0.tar.gz
解压缩以及安装
[johnson@localhost Desktop]$ tar -zxf v2.12.0.tar.gz [johnson@localhost Desktop]$ cd git-2.12.0/ [johnson@localhost Desktop]$ sudo make prefix=/usr/local all [johnson@localhost Desktop]$ sudo make prefix=/usr/local install
查看是否安装成功
[johnson@localhost Desktop]$ git --version
配置ssh-key以链接github
[johnson@localhost Desktop]$ ssh-keygen -t rsa -C 'ncatyu@126.com'
添加私钥到系统
[johnson@localhost Desktop]$ ssh-add ~/.ssh/id_rsa
查看共匙,复制其到github之上
[johnson@localhost Desktop]$ more id_rsa.pub
#########配置完成