国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > CentOS > 正文

CentOS 5 服務(wù)器 Nginx 環(huán)境推薦教程

2020-06-21 13:12:39
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
一、系統(tǒng)約定
軟件源代碼包存放位置 /usr/local/src
源碼包編譯安裝位置(prefix) /usr/local/software_name
腳本以及維護(hù)程序存放位置 /usr/local/sbin
MySQL 數(shù)據(jù)庫(kù)位置 /var/lib/mysql(可按情況設(shè)置)
網(wǎng)站根目錄 /home/www/wwwroot(可按情況設(shè)置)
虛擬主機(jī)日志根目錄 /home/www/logs(可按情況設(shè)置)
運(yùn)行賬戶 www:www
二、系統(tǒng)環(huán)境部署及調(diào)整
1、檢查系統(tǒng)是否正常
# more /var/log/messages (檢查有無(wú)系統(tǒng)級(jí)錯(cuò)誤信息)
# dmesg (檢查硬件設(shè)備是否有錯(cuò)誤信息)
# ifconfig(檢查網(wǎng)卡設(shè)置是否正確)
# ping www.163.com (檢查網(wǎng)絡(luò)是否正常)
# cat /proc/cpuinfo (檢查CPU頻率是否正常)
# top (按1檢測(cè)CPU核數(shù)是否正常,內(nèi)存大小是否正常)
2、關(guān)閉不需要的服務(wù)
# ntsysv
以下僅列出需要啟動(dòng)的服務(wù),未列出的服務(wù)一律推薦關(guān)閉:
atd
crond
irqbalance
microcode_ctl
network
sendmail
sshd
syslog
關(guān)閉SElinux:修改/etc/selinux/config文件中的SELINUX= 為 disabled
3、更換yum國(guó)內(nèi)源
# cd /etc/yum.repos.d
# mv CentOS-Base.repo CentOS-Base.repo.save
# wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
# mv CentOS-Base.repo.5 CentOS-Base.repo
# yum clean all
4、服務(wù)器時(shí)間檢查和設(shè)置
#data (檢查時(shí)間是否正確,是否是中國(guó)時(shí)間CST)
#cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime (如果時(shí)區(qū)不對(duì),則執(zhí)行,時(shí)間正常的跳過(guò))
#yum -y install ntp (安裝ntp對(duì)時(shí)工具)
#chkconfig ntpd on (讓對(duì)時(shí)服務(wù)開(kāi)機(jī)啟動(dòng))
5、使用 yum 對(duì)系統(tǒng)進(jìn)行更新并且安裝必要軟件包
#yum update –y
#yum -y install make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
6. 重新啟動(dòng)系統(tǒng)
# init 6
三、編譯安裝L.A.M.P環(huán)境
1、下載軟件(截止到09年10月的最新版本)
# cd /usr/local/src
#wget http://sysoev.ru/nginx/nginx-0.7.63.tar.gz
#wget http://download.scientificlinux.net/nginx
#wget http://download.scientificlinux.net/php-fpm.conf
#wget http://download.scientificlinux.net/nginx.conf
#wget http://download.scientificlinux.net/fcgi.conf
#wget http://download.scientificlinux.net/php-5.2.10.tar.gz
#wget http://download.scientificlinux.net/php-5.2.10-fpm-0.5.13.diff.gz
#wget http://download.scientificlinux.net/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz (32位系統(tǒng))
#wget http://download.scientificlinux.net/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz (64位系統(tǒng))
#wget http://download.scientificlinux.net/mysql-5.1.39-linux-i686-glibc23.tar.gz (32位系統(tǒng))
#wget http://download.scientificlinux.net/mysql-5.1.39-linux-x86_64-glibc23.tar.gz (64位系統(tǒng))
2、安裝MySQL

復(fù)制代碼
代碼如下:

cd /usr/local/src
tar zxvf mysql-5.1.39-linux-i686-glibc23.tar.gz
mv mysql-5.1.39-linux-i686-glibc23 /usr/local/
ln -s /usr/local/mysql-5.1.39-linux-i686-glibc23/ /usr/local/mysql
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql-5.1.39-linux-i686-glibc23/
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
cp ./support-files/my-huge.cnf /etc/my.cnf
mv /usr/local/mysql/data /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql

編輯/etc/my.cnf
在 [mysqld] 段增加
datadir = /var/lib/mysql
skip-innodb
wait-timeout = 10
max_connections = 512
max_connect_errors = 10000000
在 [mysqld] 段修改
max_allowed_packet = 16M
thread_cache_size = CPU個(gè)數(shù)*2
將 log-bin 注釋
service mysqld start
bin/mysqladmin -u root password 'password_for_root'
其中引號(hào)內(nèi)的password_for_root是要設(shè)置的root密碼
3、安裝Nginx

復(fù)制代碼
代碼如下:

cd /usr/local/src/
tar zxvf nginx-0.7.63.tar.gz
cd nginx-0.7.63
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module
make
make install
cp /usr/local/src/nginx /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on

4、安裝PHP和Zend

復(fù)制代碼
代碼如下:

cd /usr/local/src
tar zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/etc/cgi --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes --with-mysql=/usr/local/mysql --with-pear --enable-sockets --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --enable-sysvsem --enable-sysvshm --with-libxml-dir=/usr --enable-force-cgi-redirect --enable-fastcgi --with-xmlrpc --enable-zip --enable-fpm
make
make install
mkdir -p /usr/local/etc/cgi/
cp php.ini-dist /usr/local/etc/cgi/php.ini
mv -f /usr/local/src/php-fpm.conf /usr/local/php5/etc/php-fpm.conf
groupadd www
useradd -g www www
echo 'ulimit -SHn 65535' >> /etc/rc.local
echo '/usr/local/php5/sbin/php-fpm start' >> /etc/rc.local
cd /usr/local/src
tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install

(注意第一個(gè)要填的路徑是Zend安裝路徑,第二個(gè)是php.ini所在的路徑,即/usr/local/etc/cgi)
(不要選重啟apache)
5、啟動(dòng)Nginx和php

復(fù)制代碼
代碼如下:

mv -f /usr/local/src/fcgi.conf /usr/local/nginx/conf/
cp -f /usr/local/src/nginx.conf /usr/local/nginx/conf/nginx.conf
mkdir -p /home/www/wwwroot
ulimit -SHn 65535
/usr/local/php5/sbin/php-fpm start
service nginx start

在/home/www/wwwroot放入一個(gè)index.php,內(nèi)容為
打開(kāi)瀏覽器訪問(wèn),即可看到phpinfo頁(yè)面
6、設(shè)置系統(tǒng)防火墻
編輯/usr/local/sbin/fw.sh
復(fù)制以下內(nèi)容進(jìn)去

復(fù)制代碼
代碼如下:

#!/bin/bash
# Stop iptables service first
service iptables stop
# Load FTP Kernel modules
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
# Inital chains default policy
/sbin/iptables -F -t filter
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
# Enable Native Network Transfer
/sbin/iptables -A INPUT -i lo -j ACCEPT
# Accept Established Connections
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# ICMP Control
/sbin/iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
# WWW Service
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# FTP Service
/sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT
# SSH Service
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT

退出編輯,執(zhí)行以下命令

復(fù)制代碼
代碼如下:

# chmod 755 /usr/local/sbin/fw.sh
# echo '/usr/local/sbin/fw.sh' >> /etc/rc.local
# /usr/local/sbin/fw.sh

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 新蔡县| 林州市| 兴和县| 崇左市| 宜宾县| 哈密市| 安平县| 家居| 武隆县| 义马市| 寿光市| 盘锦市| 卓尼县| 同江市| 东光县| 临沧市| 友谊县| 博爱县| 京山县| 德庆县| 沙坪坝区| 翼城县| 五家渠市| 双鸭山市| 封丘县| 长海县| 鸡泽县| 荔浦县| 卢湾区| 和平区| 芦山县| 静乐县| 云安县| 岳普湖县| 句容市| 辰溪县| 邳州市| 三原县| 亚东县| 扶绥县| 南宫市|