ubuntu 11.04服务器安装全过程
来源:互联网 发布:吉他弹唱手机录音软件 编辑:程序博客网 时间:2024/05/18 00:30
1.安装ubuntu 11.04 server 64位。
2.安装ssh客户端服务
sudo apt-get install openssh-server
生成密钥
ssh-keygen
将公钥改名留在服务器上
mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
将私钥 id_rsa 从服务器上复制出来,并删除掉服务器上的 id_rsa 文件
scp ~/.ssh/id_rsa wangbin@192.168.0.XXX:/home/XXX/.ssh/id_rsa_local_101
rm ~/.ssh/id_rsa -f
(注意:可能无密码仍不能登陆,将~/.ssh/authorized_keys文件属性改为600即可)
安装rzsz
sudo apt-get install lrzsz
安装rsync
sudo apt-get install rsync
3.设置静态ip地址:
vim /etc/network/interfaces
如果配置动态获取ip,则在上述文件中加入以下内容:
auto eth0
iface eth0 inet dhcp
如果配置静态ip,则添加如下内容:
auto eth0
iface eth0 inet static
address 192.168.33.201
netmask 255.255.255.0
gateway 192.168.33.1
要是配置生效,需要重启网卡:
ifconfig eth0 down
ifconfig eth0 up
若还有没有配置成功,则需重启下网络服务
/etc/init.d/networking restart
配置dns
vim /etc/resolv.conf
nameserver 202.112.125.53
修改计算机名
sudo vim /etc/hostname
sudo reboot
设置root密码
sudo passwd root
设置sudo不需要密码
su root
vim /etc/sudoers
%admin ALL=(ALL) ALL 改为%admin ALL=(ALL) NOPASSWD: ALL
设置sudo不需要密码
su root
vim /etc/sudoers
%admin ALL=(ALL) ALL 改为%admin ALL=(ALL) NOPASSWD: ALL
4.优化ubuntu系统
修改语言,解决乱码问题
vim /etc/default/locale
LANG="zh_CN.UTF-8"
5.拷贝所需软件
将以下软件 mysql-5.1.53.tar.gz, php-5.3.3.tar.gz, eaccelerator-0.9.6-rc2.tar.bz2, memcache-2.2.6.tgz, nginx-0.8.53.tar.gz, memcached-1.4.5.tar.gz 拷贝到~/tmp/目录下
6.安装mysql
sudo groupadd mysql
sudo useradd -g mysql mysql
cd ~/tmp/
tar -zxvf mysql-5.1.53.tar.gz
cd mysql-5.1.53/
sudo apt-get install g++ gcc make automake perl
sudo apt-get install libncurses5-dev
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make
sudo make install
sudo mkdir /usr/local/webserver/mysql/data
sudo chown -R mysql:mysql /usr/local/webserver/mysql/data
sudo /usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=mysql
/usr/local/webserver/mysql/bin/mysqld_safe&
/usr/local/webserver/mysql/bin/mysqladmin -uroot password 'XXX'
sudo mkdir /usr/local/webserver/mysql/conf
sudo cp ~/tmp/mysql-5.1.53/support-files/my-medium.cnf /usr/local/webserver/mysql/conf/my.cnf
/usr/local/webserver/mysql/bin/mysqld_safe--defaults-file=/usr/local/webserver/mysql/conf/my.cnf 2>&1 >/dev/null &
7.安装php
cd ~/tmp/
tar -zxvf php-5.3.3.tar.gz
cd php-5.3.3/
sudo apt-get install libevent-dev libxml2-dev curl libssl-dev libcurl3 libcurl4-gnutls-dev libpng12-dev libjpeg62-dev
sudo cp /usr/lib/x86_64-linux-gnu/libjpeg.* /usr/lib/
sudo cp /usr/lib/x86_64-linux-gnu/libpng* /usr/lib/
sudo apt-get install libfreetype6-dev
sudo apt-get install libmcrypt-dev
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir= --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-exif --enable-soap --without-pear --enable-fpm
(php5.2
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir= --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-exif --enable-soap --without-pear --enable-fpm)
make
sudo make install
sudo cp ~/tmp/php-5.3.3/php.ini-production /usr/local/webserver/php/etc/php.ini
sudo mv /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
sudo groupadd www
sudo useradd -g www www
sudo mkdir -p /www/webroot
sudo chmod 775 /www/webroot -R
sudo chown -R www:www /www/webroot
sudo chmod 775 /www/webroot -R
sudo chown -R www:www /www/webroot
#安装php扩展eaccelerator
cd ~/tmp/
tar -jxvf eaccelerator-0.9.6-rc2.tar.bz2
cd eaccelerator-0.9.6-rc2/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
sudo make install
#sudo vim /etc/sysctl.conf
#kernel.shmmax = 134217728
#/sbin/sysctl –p
#php.ini配置
[eaccelerator]
;zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
extension="eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file="/usr/local/webserver/eaccelerator/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
;zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
extension="eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file="/usr/local/webserver/eaccelerator/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
#安装php扩展memcache
cd ~/tmp/
tar -zxvf memcache-2.2.6.tgz
cd memcache-2.2.6/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
sudo make install
8.安装nginx
cd ~/tmp/
tar -zxvf nginx-0.8.53.tar.gz
cd nginx-0.8.53/
sudo apt-get install libpcre3-dev
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make
sudo make install
sudo mkdir -p /www/logs
sudo chmod +w /www/logs
sudo chown -R www:www /www/logs
sudo chmod +w /www/logs
sudo chown -R www:www /www/logs
9.安装memcached
./configure --prefix=/usr/local/webserver/memcached --enable-64bit --with-libevent=/usr/lib64/
#/usr/local/webserver/memcached/bin/memcached -p 11211 -d -m 1024
10.开机自启动配置
#直接更改rc.local
sudo vim /etc/init.d/rc.local
/usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/conf/my.cnf 2>&1 >/tmp/logs/mysql_sart.log &
/usr/local/webserver/php/sbin/php-fpm 2>&1 >/tmp/logs/php_start.log
/usr/local/webserver/nginx/sbin/nginx 2>&1 >/tmp/logs/nginx_start.log
/usr/local/webserver/memcached/bin/memcached -p 11211 -d m 1024 -u ry
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf
#通过update-rc.d设置
sudo cp ~/tmp/mysql-5.1.53/support-files/mysql.server /etc/init.d/mysql
#将datadir= 改为 datadir=/usr/local/webserver/mysql/data
#将$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & 改为 $bindir/mysqld_safe --defaults-file=$basedir/conf/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
sudo chmod +x /etc/init.d/mysql
update-rc.d -f mysql defaults
sudo update-rc.d -f mysql defaults
#将datadir= 改为 datadir=/usr/local/webserver/mysql/data
#将$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & 改为 $bindir/mysqld_safe --defaults-file=$basedir/conf/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
sudo chmod +x /etc/init.d/mysql
update-rc.d -f mysql defaults
sudo update-rc.d -f mysql defaults
11.更改配置文件
#php
/usr/local/webserver/php/etc/php.ini
/usr/local/webserver/php/etc/php-fpm.conf
/usr/local/webserver/php/etc/php-fpm.conf
#nginx
/usr/local/webserver/nginx/conf/nginx.conf
#rsync
/etc/rsyncd/rsyncd.conf
/etc/rsyncd/rsyncd.secrets
/etc/rsyncd/rsyncd.motd
#mysql
/usr/local/webserver/mysql/conf/my.cnf
12.配置iptables
su root
iptables -F #清除预设表filter中的所有规则链的规则
iptables -X #清除预设表filter中使用者自定链中的规则iptables -L -n
/etc/init.d/iptables save
service iptables restart
iptables -p INPUT DROP#如果你是远程SSH登陆的话,当你输入第一个命令回车的时候就应该掉了.因为你没有设置任何规则
iptables -p OUTPUT ACCEPT
iptables -p FORWARD DROP
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT #如果你把OUTPUT 设置成DROP的就要写上
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT #如果你把OUTPUT 设置成DROP的就要写上
iptables -A INPUT -p tcp --dport 80 -j ACCEPT #http port
iptables -A INPUT -p tcp --dport 110 -j ACCEPT #mail port
iptables -A INPUT -p tcp --dport 25 -j ACCEPT #mail port
iptables -A INPUT -p tcp --dport 21 -j ACCEPT #ftp port
iptables -A INPUT -p tcp --dport 20 -j ACCEPT #ftp port
iptables -A INPUT -p tcp --dport 53 -j ACCEPT #dns port
iptables -A OUTPUT -p icmp -j ACCEPT #如果你把OUTPUT 设置成DROP的就要写上
iptables -A INPUT -p icmp -j ACCEPT #ping prot
IPTABLES -A INPUT -i lo -p all -j ACCEPT #allow loopback
IPTABLES -A OUTPUT -o lo -p all -j ACCEPT #allow loopback
#iptables -A INPUT -s 192.168.0.3 -p tcp --dport 22 -j ACCEPT #如果要允许,或限制一段IP地址可用 192.168.0.0/24 表示192.168.0.1-255端的所有IP
#配置forward
iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o eh0 -j ACCEPT
- ubuntu 11.04服务器安装全过程
- 安装 Ubuntu 9.10 服务器版本系统全过程
- ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- Ubuntu Server安装全过程
- ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- ubuntu 安装全过程
- ubuntu安装jdk全过程
- Ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- ubuntu安装jdk全过程
- ubuntu安装svn全过程
- Ubuntu Server安装全过程(ubuntu服务器安装图文详解,gxk9933原创,欢迎转载)
- linux 安装jabberd2服务器全过程
- Ubuntu上安装glassfish全过程
- EUnit——erlang的轻量级单元测试框架(3)
- eWebEditor不支持IE8的解决方法
- E4X教程[2] - 访问 XML 子节点
- JSTL和EL表达式的使用
- 静态库
- ubuntu 11.04服务器安装全过程
- 资源管理
- 学习的方法
- 进程管理
- VPN基础
- unplumb the vip.
- 实例 c语言
- 远程服务器返回错误: (404) 未找到。
- 插入及删除