CentOS 5 服务器 Nginx 环境推荐教程

2020-01-30 13:02:39刘景俊

#wget http://download.scientificlinux.net/mysql-5.1.39-linux-x86_64-glibc23.tar.gz (64位系统)
2、安装MySQL

复制代码
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密码
3、安装Nginx

复制代码
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

复制代码
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