1.静态地址配置
通过修改 /etc/sysconfig/network-scripts/ifcfg-eth0 文件配置静态IP
- DEVICE=eth0 //网卡ID
- BOOTPROTO=static //设置成静态IP
- TYPE=Ethernet //网络类型
- BROADCAST=192.168.1.255 //广播地址
- HWADDR=00:0C:29:49:E2:90 //网卡Mac地址
- IPADDR=192.168.1.201 //IP 地址
- NETMASK=255.255.255.0 //子网掩码
- GATEWAY=192.168.1.1 //网关
- ONBOOT=yes //开机自动开启网卡
通过修改 /etc/resolv.conf 设置DNS
- nameserver 192.168.1.1
重启网络
- service network restart
查看是否生效
- ifconfig
您可以根据自己的网络情况设置相应的IP和DNS
2.修改yum源为163
- cd /etc/yum.repos.d/
- wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
- mv CentOS-Base.repo CentOS-Base.repo.bak
- mv CentOS6-Base-163.repo CentOS-Base.repo
- yum makecache
3.安装中文语言包
- yum groupinstall chinese-support
4.安装Vim
- yum -y install vim
5.增加用户
- useradd frankwong //注:把frankwong改成你要增加的用户名
- passwd frankwong //注:设置密码
6.安装sudo
- yum -y install sudo
- chmod u+w /etc/sudoers
- vim /etc/sudoers
找到这一行:"root ALL=(ALL) ALL"
在下面添加"*** ALL=(ALL) ALL"(这里的***是你的用户名),然后保存
- chmod u-w /etc/sudoers //注:撤销写权限。
7.安装常用基本工具
- yum -y install wget make gcc gcc-c++ bison ncurses-devel
8.安装JDK7
从官网下载对应你操作系统的JDK安装文件
这边我用的是64位的jdk-7-linux-x64.rpm
- sudo rpm -ivh jdk-7-linux-x64.rpm //安装JDK
- vim /etc/profile //编辑环境变量
在profile文件下面追加写入下面信息:
- export JAVA_HOME=/usr/java/jdk1.7.0_17
- export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- export PATH=$PATH:$JAVA_HOME/bin
让环境变量生效
- source /etc/profile
输入
- java -version
如果出现如下信息
- java version "1.7.0_17"
- Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
- Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
恭喜您,安装成功
9.安装Cmake
从官网下载 cmake-2.8.10.2.tar.gz
- tar -zxv -f cmake-2.8.10.2.tar.gz
- cd cmake-2.8.10.2
- ./configure
- make
- make install
配置环境变量
- vi /etc/profile
在文件末尾追加以下两行代码:
- PATH=/opt/cmake-2.8.10.2/bin:$PATH
- export PATH
使之生效
- source /etc/profile
10.安装Mysql
下载 mysql-5.5.29.tar.gz
- groupadd mysql //增加Mysql 组
- useradd -r -g mysql mysql //增加Mysql用户
- tar -zxv -f mysql-5.5.29.tar.gz //解压
- cd mysql-5.5.29
- cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
- -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
- -DDEFAULT_CHARSET=utf8 \
- -DDEFAULT_COLLATION=utf8_general_ci \
- -DWITH_MYISAM_STORAGE_ENGINE=1 \
- -DWITH_INNOBASE_STORAGE_ENGINE=1 \
- -DWITH_MEMORY_STORAGE_ENGINE=1 \
- -DWITH_READLINE=1 \
- -DENABLED_LOCAL_INFILE=1 \
- -DMYSQL_DATADIR=/usr/local/mysql/data \
- -DMYSQL_USER=mysql \
- -DMYSQL_TCP_PORT=3306
- make
- make install
- cd /usr/local/mysql
- chown -R root:mysql .
- chown -R mysql:mysql data
- cp support-files/my-medium.cnf /etc/my.cnf
- scripts/mysql_install_db --user=mysql
- vi /root/.bash_profile //修改环境变量
将
- PATH=$PATH:$HOME/bin
修改成
- PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
- source /root/.bash_profile //使刚才的修改生效
- cp support-files/mysql.server /etc/init.d/mysql
- chown -R mysql:mysql /usr/local/mysql
输入mysql –u root 进入mysql
- GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //设置root用户可以远程访问
- update user set Password = password('123456') where User='root';//设置root用户密码为123456
- flush privileges ;
同时别忘记开放Mysql服务端口3306
- sudo vim /etc/sysconfig/iptables
在-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT下增加
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //此处顺便开放Nginx 80端口
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT //开放tomcat 8080端口
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
重启防火墙,使其配置生效:
- # /etc/init.d/iptables restart
11.安装tomcat
下载 apache-tomcat-7.0.37.tar.gz
- sudo tar -zxvf apache-tomcat-7.0.37.tar.gz -C /opt/
- cd /opt/apache-tomcat-7.0.37/bin
- sudo vim catalina.sh
在文件开头注释增加如下
- JAVA_HOME="/usr/java/jdk1.7.0_17"
创建tomcat快捷方式
- vim ~/.bashrc
增加如下内容
- alias starttomcat="sudo /opt/apache-tomcat-7.0.37/bin/startup.sh"
- alias stoptomcat="sudo /opt/apache-tomcat-7.0.37/bin/shutdown.sh"
- alias restarttomcat="stoptomcat && starttomcat"
- source ~/.bashrc
现在你可以通过用starttomcat启动tomcat
12.安装Nginx
下载 安装pcre
- wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.32/pcre-8.32.tar.gz
- tar -zxvf pcre-8.32.tar.gz
- cd pcre-8.32
- sudo ./configure
- sudo make
- sudo make install
- sudo yum -y install zlib-devel //安装zlib
下载 nginx-1.2.7.tar.gz到 /opt
- tar zxvf nginx-1.2.7.tar.gz
- cd nginx-1.2.7
- ./configure --with-http_stub_status_module --with-http_gzip_static_module --prefix=/usr/local/nginx
- make make install
启动nginx
- /usr/local/nginx/sbin/nginx
报错
- /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
缺少libpcre.so.1 => not found
- cd /lib
- ln -s /usr/local/lib/libpcre.so.1 /lib64 //因为我的系统是64位,所以为lib64
OK,再起开启 nginx,成功
转载于:https://blog.51cto.com/frankwong1213/1166960