• 欢迎访问Ppabc博客网站,专注于Linux、CentOS、Apache、Nginx、MySQL、PHP等开源工具安装优化的技术博客,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入Ppabc博客
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏Ppabc博客吧

centos 5.3服务器配置nginx php mysql pureftpd备忘录[转]

Linux学习 admin 9年前 (2010-04-08) 212次浏览

服务器硬件环境:vps/20G 硬盘/256M 内存
服务器系统:centos 5.3 32 位
WEB 服务器所有相关软件:nginx/php/mysql/pureftpd/eaccelerator/ZendOptimizer/pcre 等
系统安装:text 文本安装,无任何软件。


1dmesg 查看有无错误
升级系统到最新 yum -y update
关闭防火墙
#service iptables stop
#chkconfig iptables off
2 关闭 selinux
使用文本编辑工具打开 /etc/selinux/config
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:SELINUX=disabled
保存,关闭。
3 停止 ipv6
vi /etc/sysconfig/network
NETWORKING_IPV6=no
网上所说的下面这种方法会在启动时报错。千万不要乱用。
vi /etc/modprobe.conf
在文件末尾加上
alias net-pf-10 off
alias ipv6 off
4 修改 SSH 配置
vi /etc/ssh/sshd_config
禁止空密码登录
找到
#PermitEmptyPasswords no
去掉前面的 #
5:yum 升级
yum install yum-fastestmirror -y
yum upgrade -y
yum install wget #安装 wget
yum install setuptool #安装 setup
yum install gcc gcc-c++ autoconf vixie-cron #vixie-cron 软件包是 cron 的主程序
yum install gcc gcc-c++ autoconf crontabs #crontabs 软件包是用来安装、卸装、或列举用来驱动 cron 守护进程的表格的程序

yum install make #安装 make
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2
libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl
-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel
nss_ldap openldap-clients openldap-servers
6:修改时区
修改 Linux 时区为东八区
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
将系统时间设定成 2009 年 07 月 22 日的命令如下。
#date -s 07/22/09
将系统时间设定成下午 4 点 45 分 0 秒的命令如下。
#date -s 16:45:00
#clock -w #这个命令强制把系统时间写入 CMOS
7:优化 Linux 内核参数
vi /etc/sysctl.conf#在末尾增加以下内容:
# Add
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
使配置立即生效:/sbin/sysctl -p
重启系统。
编译安装 PHP 5.2.10 所需的支持库
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure –prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
编译安装 MySQL
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a/
./configure –prefix=/usr/local/mysql –localstatedir=/var/lib/mysql –with-mysqld-user=mysql –without-debug –
with-big-tables –with-charset=utf8 –with-extra-charsets=all –with-pthread –enable-static –enable-thread-safe-
client –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –without-innodb –
without-ndb-debug –without-isam
make
make install
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql
./scripts/mysql_install_db –user=mysql –datadir=/var/lib/mysql
chown -R mysql /var/lib/mysql
chgrp -R mysql /var/lib/mysql
chown -R mysql /var/lib/mysql/mysql/
#cp my.cnf /data0/mysql/3306/my.cnf
#cp mysql /data0/mysql/3306/mysql
chmod +x /data0/mysql/3306/mysql
启动 MySQL
/data0/mysql/3306/mysql start
通过命令行登录管理 MySQL 服务器(提示输入密码时直接回车):
/usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
update user set password=password(’123456′) where user=’root’;
停止 MySQL
/data0/mysql/3306/mysql stop
netstat -atln
编译安装 PHP(FastCGI 模式)
tar zxvf php-5.2.10.tar.gz
yum install patch
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10/
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with
-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-
png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –
enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable
-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –
enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –
with-xmlrpc –enable-zip –enable-soap –without-pear –enable-pdo –with-pdo-sqlite –with-pdo-
mysql=/usr/local/mysql/bin/mysql_config
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp php.ini-dist /usr/local/php/etc/php.ini
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
mkdir -p /usr/local/eaccelerator_cache
#echo php.ini
zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/usr/local/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=””
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″
rm -f /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
启动 php-cgi 进程,监听 127.0.0.1 的 9000 端口,进程数为 200(如果服务器内存小于 3GB,可以只开启 64 个进程)
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
注:/usr/local/php/sbin/php-fpm 还有其他参数,包括:start|stop|quit|restart|reload|logrotate,修改 php.ini 后不重启 php
-cgi,重新加载配置文件使用 reload
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /data0/htdocs/blog
chmod +w /data0/htdocs/blog
chown -R www:www /data0/htdocs/blog
mkdir -p /data0/htdocs/www
chmod +w /data0/htdocs/www
chown -R www:www /data0/htdocs/www
安装 Nginx 所需的 pcre 库
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9/
./configure
make && make install
cd ../
tar zxvf nginx-0.8.4.tar.gz
cd nginx-0.8.4/
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module
make && make install
cd ../
创建 Nginx 日志目录
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs
启动 Nginx
ulimit -SHn 51200
/usr/local/nginx/sbin/nginx
修改/usr/local/nginx/conf/nginx.conf 配置文件后,请执行以下命令检查配置文件是否正确
/usr/local/nginx/sbin/nginx -t
kill -HUP `cat /usr/local/nginx/nginx.pid`
#cp cut_nginx_log.sh /usr/local/nginx/sbin/cut_nginx_log.sh
设置 crontab,每天凌晨 00:00 切割 nginx 访问日志
配置开机自动启动 Nginx + PHP
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
/data0/mysql/3306/mysql start
安装 ZendOptimizer,
# tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
# cd ZendOptimizer-3.0.1-linux-glibc21-i386
# ./install.sh
安装 pureftpd
tar -zxvf pure-ftpd*
cd pure-ftpd-1.0.21
./configure –prefix=/usr/local/pureftpd –with-puredb –with-rfc2640 –with-language=simplified-chinese;
make && make install
mkdir /usr/local/pureftpd/etc
cd configuration-file
chmod u+x pure-config.pl
cp pure-config.pl /usr/local/pureftpd/bin
cp pure-ftpd.conf /usr/local/pureftpd/etc
cd ..
cp pureftpd* /usr/local/pureftpd/etc/
#ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
修改配置文件
vim /usr/local/pureftpd/etc/pure-ftpd.conf
NoAnonymous yes
Bind 222.73.*.*,*
添加系统用户
groupadd ftpgroup
useradd -g ftpgroup -d /dev/null -s /sbin/nologin ftpuser
chown ftpuser:ftpgroup /data0/htdocs/www
chmod -R 777 /data0/htdocs/www
/usr/local/pureftpd/bin/pure-pw useradd learsu -u ftpuser -d /data0/htdocs/www -r 125.41.143.78
更新虚拟账户文件
/usr/local/pureftpd/bin/pure-pw mkdb /usr/local/pureftpd/etc/pureftpd.pdb /usr/local/pureftpd/etc/pureftpd.passwd
虚拟账户启动
/usr/local/pureftpd/sbin/pure-ftpd -j -l puredb:/usr/local/pureftpd/etc/pureftpd.pdb &
虚拟账户修改
/usr/local/pureftpd/bin/pure-pw usermod learsu -r 125.41.143.78
虚拟账户删除
/usr/local/pureftpd/bin/pure-pw userdel [-f ] [-m]
改变用户口令
/usr/local/pureftpd/bin/pure-pw [-f ] [-m]
显示用户信息
/usr/local/pureftpd/bin/pure-pw show [-f ]

 centos 5.3 服务器配置 nginx php mysql pureftpd 备忘录
http://www.evanjiang.net.cn/archives/1275.html


Selinux 中国 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:centos 5.3 服务器配置 nginx php mysql pureftpd 备忘录[转]
喜欢 (0)