新裝Linux服務器操作指南

  • 發布時間:2015-05-06 21:02:10
  • 閱讀次數:101

CentOS 6.5 64位服務器 - 虛擬主機配置

一、初始設置

1、刪除不必要的軟件組 yum groupremove,只保留E-mail server,Security Tools這兩個

2、修改時區和時間

rm -f /etc/localtime

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

date -s "14:00:00"

hwclock -w

3、禁用防火墻

vi /etc/sysconfig/selinux

修改:SELINUX=disabled

service iptables stop && chkconfig iptables off

service ip6tables stop && chkconfig ip6tables off

4、安裝增強版yum庫

yum install epel-release -y

5、網絡設置

vi /etc/sysconfig/network-scripts/ifcfg-eth0

<pre class="brush:bash;toolbar:false">DEVICE=eth0
Type=Ethernet
ONBOOT=yes
BOOTPROTO=none(這里原來是dhcp)
IPADDR=**.**.**.**(這行需要添加的,就是分配的IP地址)
NETMASK=255.255.255.0
GATEWAY=**.**.**.**
DNS1=114.114.114.114
DNS2=8.8.8.8
IPV6INIT=no
IPV6_AUTOCONF=no

6、服務器更新并重啟

yum update -y

reboot

二、安裝軟件

1、Apache + VSFTP

yum install httpd -y

yum install mod_bw -y

yum install httpd-itk -y

yum install vsftpd -y

2、PHP + MySQL

yum install php -y

yum install php-bcmath php-gd php-mcrypt php-mbstring php-mysql -y

yum install mysql-server -y

service mysqld start && chkconfig mysqld on

mysql_secure_installation

3、Zend Guard (64 bit for PHP 5.3)

下載并解壓:http://www.zend.com/en/products/guard/downloads

tar -xzvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

cp ZendGuardLoader.so /usr/lib64/php/modules/ (PHP模塊地址)

vi /etc/php.d/zendguard.ini

<pre class="brush:bash;toolbar:false">添加內容:
zend_extension=/usr/lib64/php/modules/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=0

service httpd graceful

php -m 驗證是否加載成功

三、配置軟件

vi /etc/sysconfig/httpd

改成HTTPD=/usr/sbin/httpd.itk,并刪除注釋

vi /etc/httpd/conf/httpd.conf

禁用代理模塊,注釋掉LoadModule proxy_這幾行。
ServerName localhost.localdomain
<Directory "/">  AllowOverride 從None改成All
<Directory "/var/www/html"> Options -Indexes(加上減號)
修改默認首頁,DirectoryIndex index.php index.html index.htm default.html default.htm<br></br>

rm -f /var/www/html/*.*

cd /etc/httpd/conf.d

rm -f mod_bw.conf welcome.conf README

vi 0host.conf (用0開頭的意義是讓該文件在其他虛擬主機conf文件之前加載)

添加內容:
LoadModule bw_module modules/mod_bw.so

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /var/www/html
</VirtualHost>

vi php.conf

添加內容:
<IfModule itk.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
注釋掉#DirectoryIndex index.php這行

service httpd start && chkconfig httpd on 重啟Apache檢查是否有報錯

vi /etc/vsftpd/vsftpd.conf

<pre class="brush:bash;toolbar:false">anonymous_enable改成NO
刪除注釋:chroot_local_user=YES

service vsftpd start && chkconfig vsftpd on

vi /etc/php.ini

<pre class="brush:bash;toolbar:false">short_open_tag = 改成On<p>date.timezone = 去掉注釋,改成"US/Pacific"</p><p>session.save_path = "/tmp"</p><p>disable_functions = mail(禁用mail函數)</p>

四、啟用磁盤配額(一般是/home分區)

vi /etc/fstab

在要修改的分區defaults后面加上,usrquota

mount -o remount /home

yum install quota -y

quotacheck -vum /home

quotaon -av

查看某用戶的磁盤配額:quota -u username

五、設置API網站

cd /home

mkdir -p zhaomuapi/{wwwroot,logfiles}

vi /etc/httpd/conf.d/0host.conf

添加內容:
Listen 8188
<VirtualHost *:8188>
   DocumentRoot /home/zhaomuapi/wwwroot
   ErrorLog /home/zhaomuapi/logfiles/error_log
   CustomLog /home/zhaomuapi/logfiles/access_log common
   <Directory />
      Order deny,allow
      Deny from all
      Allow from 58.215.65.49
   </Directory>
</VirtualHost>

chmod +w /etc/sudoers

vi /etc/sudoers

<pre class="brush:bash;toolbar:false">按2次PgDn鍵,注釋掉#Defaults    requiretty這行
再按3次PgDn鍵,在root All這行下添加
apache  ALL=(ALL)       NOPASSWD:/home/zhaomuapi/wwwroot/*.sh

chmod -w /etc/sudoers

最后復制API程序到/home/zhaomuapi/wwwroot中,并測試是否可以開通空間,注意其中的.sh文件要給x執行權限。

六、啟用備份

yum remove postfix

yum install crontabs

crontab -e

30 2 * * 2 /home/zhaomuapi/wwwroot/backup.sh

七、其他設置

vi /root/.bashrc

加上這行:alias ls='ls -la' (默認顯示隱藏文件)

更改遠程端口為8322:http://www.1160305.live/help/detail-487.html

添加一塊硬盤作為備份:http://www.sudu.cn/service/detail.php?id=11831

安裝RAR和ZIP,以支持文件壓縮解壓

yum install zip unzip -y

cd /root

wget http://www.rarlab.com/rar/rarlinux-x64-5.4.0.tar.gz

tar -zxvf rarlinux-x64-5.4.0.tar.gz

cd rar

cp rar unrar /bin

=============================

Extend a LVM volume in a Hyper-V Linux VM

Creating the LVM partition

All of the commands need to be done with root or a user with sudo rights as root.

First we need to create the LVM partition in fdisk

linuxapptest # fdisk /dev/hda

Type p to print current partition configuration

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          31      248976   83  Linux
/dev/hda2              32        3263    25961040   8e  Linux LVM

Type n for a new partition

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)

Type p for primary

Partition number (1-4): 3

Type 3 since it is next partition number available

Just enter at the next two prompts to use the full amount of storage we added to the hard drive. Your cylinder numbers will probably be different then my example.

First cylinder (1-10443, default 7000):

Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443):

Now we need to change the new partition’s system id/type to LVM

Command (m for help): t
Partition number (1-4):

Type partition 3

Hex code (type L to list codes): 8e

Type 8e to change the partition type to LVM

Changed system type of partition 1 to 8e (Linux LVM)

We aren’t finished yet. Be sure to type w so the changes will be committed to the disk.

Command (m for help): w
The partition table has been altered!

Adding the additional storage

Create a Physical volume from the new partition

linuxapptest # pvcreate /dev/hda3

Display the LVM information so we grow the correct Volume Group

linuxapptest # lvdisplay
  --- Logical volume ---
  LV Name                /dev/linuxapptest/root
  VG Name                linuxapptest
  LV UUID                jvOih8-hex2-s2Ec-avuL-wtG2-M1KI-JVY6PG
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                23.69 GB
  Current LE             6064
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

  --- Logical volume ---
  LV Name                /dev/linuxapptest/swap_1
  VG Name                linuxapptest
  LV UUID                qOASw0-GmoL-dipj-ORrP-qRxv-yOdE-g9i7dE
  LV Write Access        read/write
  LV Status              available
  # open                 2
  LV Size                1.07 GB
  Current LE             274
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

We now add the new partition to the Volume Group. You see that our Volume Group name (VG Name) is linuxapptest.

 linuxapptest # vgextend linuxapptest /dev/hda3

Next we add the new storage to the logical volume. We want to expand the “root” logical volume. The command will add all of the free storage to logical volume.

linuxapptest # lvresize -l +100%FREE /dev/linuxapptest/root

Online expansion of the filesystem

linuxapptest # resize2fs /dev/linuxapptest/root

At this point your Linux VM has the additional storage to use. I also like to reboot the server at this point to make sure everything works after a clean boot.

【全文完】

< 上一篇:VPS云主機在線監控和流量統計功能正式上線 下一篇:每日網站推廣工作表 >
网赌ag真人是骗局吗 江西11选五技巧 安徽省十一选五 吉林快三是什么彩票 股票高频数据下载 股票微信群哪个好 广西快3走势图一定牛 福彩3d怎么下载下载不来 明天涨停股票推荐骗局 广西快3开奖记录 辽宁快乐12十大遗漏