软件源代码包存放位置 /usr/local/src
源码包编译安装位置(prefix) /usr/local/software_name
脚本以及维护程序存放位置 /usr/local/sbin
MySQL 数据库位置 /var/lib/mysql(可按情况设置)
网站根目录 /home/www/wwwroot(可按情况设置)
虚拟主机日志根目录 /home/www/logs(可按情况设置)
运行账户 www:www
# more /var/log/messages (检查有无系统级错误信息) # dmesg (检查硬件设备是否有错误信息) # ifconfig(检查网卡设置是否正确) # ping www.163.com (检查网络是否正常) # cat /proc/cpuinfo (检查CPU频率是否正常) # top (按1检测CPU核数是否正常,内存大小是否正常)
# ntsysv以下仅列出需要启动的服务,未列出的服务一律推荐关闭:
atd crond irqbalance microcode_ctl network sendmail sshd syslog关闭SElinux:修改/etc/selinux/config文件中的SELINUX= 为 disabled
# cd /etc/yum.repos.d # mv CentOS-Base.repo CentOS-Base.repo.save # 网易YUM源地址:http://mirrors.163.com/.help/centos.html ,你可根据服务器版本指定源文件进行下载(此行不做为命令运行 ) # wget http://mirrors.163.com/.help/CentOS5-Base-163.repo # mv CentOS5-Base-163.repo CentOS-Base.repo # yum clean all
#data (检查时间是否正确,是否是中国时间CST) #cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime (如果时区不对,则执行,时间正常的跳过) #yum -y install ntp (安装ntp对时工具) #chkconfig ntpd on (让对时服务开机启动)
#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
# init 6
# 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位系统) #wget http://download.scientificlinux.net/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz (64位系统) #wget http://download.scientificlinux.net/mysql-5.1.39-linux-i686-glibc23.tar.gz (32位系统) #wget http://download.scientificlinux.net/mysql-5.1.39-linux-x86_64-glibc23.tar.gz (64位系统)
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个数*2
将 log-bin 注释
service mysqld start bin/mysqladmin -u root password 'password_for_root'
其中引号内的password_for_root是要设置的root密码
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
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
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放入一个index.php,内容为
打开浏览器访问,即可看到phpinfo页面