CentOS3 Linux 服务器环境配置以及优化详解(2)
# useradd username
# passwd username
# vi /etc/passwd (将passwd文件中username的登录shell改为/bin/sh)
# vi /etc/ssh/sshd_config (将#protocol 1,2一行改为protocol 2)
# vi /etc/ssh/sshd_config (将#PermitRootLogin yes一行改为PermitRootLogin no)
# vi /usr/etc/sshd_config (将#protocol 1,2一行改为protocol 2)
# vi /usr/etc/sshd_config (将#PermitRootLogin yes一行改为PermitRootLogin no)
# /etc/rc.d/init.d/sshd restart
[编辑]安装配置Apache+PHP+MySQL+Zend Optimizer
1) 下载软件
# cd /usr/local/src
# wget http://download.discuz.net/env/httpd-2.0.58.tar.bz2
# wget http://download.discuz.net/env/mysql-standard-5.0.22-linux-i686.tar.gz
# wget http://download.discuz.net/env/php-5.1.4.tar.bz2
# wget http://download.discuz.net/env/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
2) 安装MySQL
# tar xzvf mysql-standard-5.0.22-linux-i686.tar.gz
# useradd mysql
# mv mysql-standard-5.0.22-linux-i686 /usr/local/mysql
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql data
# chgrp -R mysql .
# mv data /var/lib/mysql
# ln -s /var/lib/mysql ./data
# cp support-files/my-large.cnf /etc/my.cnf
# bin/mysqld_safe --user=mysql &
# bin/mysqladmin -u root password newpassword_for_root
# bin/mysqladmin -u root -p shutdown
# cp support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start
3) 编译安装Apache
# cd /usr/local/src
# tar xjvf httpd-2.0.58.tar.bz2
# cd httpd-2.0.58
# ./configure --prefix=/usr/local/apache2 --mandir=/usr/ share/man --enable-module=so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-gzip --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache
# make
# make install
4) 编译安装PHP
# cd /usr/local/src
# tar xjvf php-5.1.4.tar.bz2
# cd php-5.1.4
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/ apache2/bin/apxs --with-zlib --with-bz2 --with-tiff-dir --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/ gd2 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-config-file-path=/etc --disable-ipv6 --enable-gd- native-ttf
# make
# make install
# cp php.ini-dist /etc/php.ini
5) 安装Zend Optimizer
# cd /usr/local/src
# tar xzvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
# ./ZendOptimizer-3.0.1-linux-glibc21-i386/install.sh
6) 整合Apache与PHP
# vi /usr/local/apache2/conf/httpd.conf
搜索:
DirectoryIndex index.html index.html.var
将其改为:
DirectoryIndex index.html index.htm index.php
搜索:
AddType application/x-gzip .gz .tgz
在下面添加一行:
AddType application/x-httpd-php .php
保存退出后重启Apache
# /usr/local/apache2/bin/apachectl restart
[编辑]更改Apache运行账户以及建立虚拟主机
1. 更改Apache运行账户默认情况下Apache在Linux系统上使用nobody账户运行,我们下面将要更改运行账户提升Apache的安全性和权限可控性。
# useradd www
# su www
$ mkdir -p /home/www/wwwroot/discuz
$ exit
# vi /usr/local/apache2/conf/httpd.conf
找到:
User nobody
Group #-1
改为:
User www
Group www
2. 建立一个虚拟主机此处我们为Apache建立一个虚拟主机。
# vi /usr/local/apache2/conf/httpd.conf
找到:
- 上一篇:Varnish Cache网站加速器
- 下一篇:LINUX减少TIME_WAIT