秀米云香港服务器

CentOS5.5(32bit)

所需软件包:

序列号 CPU RAM HDD 带宽 售价(美元) 免费试用
香港服务器1 E5-2620 32G 1T HDD 50M/无限流量 $196.00 立即申请
香港服务器2 E5-2650 32G 1T HDD 50M/无限流量 $256.00 立即申请
香港服务器3 E5-2680 32G 1T HDD 50M/无限流量 $316.00 立即申请
香港服务器4 E5-2690 32G 1T HDD 50M/无限流量 $336.00 立即申请
香港服务器5 E5-2697 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器6 E5-2620*2 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器7 E5-2650*2 32G 1T HDD 50M/无限流量 $436.00 立即申请
香港服务器8 E5-2680*2 32G 1T HDD 50M/无限流量 $476.00 立即申请
香港服务器9 E5-2690*2 32G 1T HDD 50M/无限流量 $556.00 立即申请
香港服务器10 E5-2697*2 32G 1T HDD 50M/无限流量 $596.00 立即申请
香港服务器11 E5-2680v4*2 32G 1T HDD 50M/无限流量 $696.00 立即申请
香港服务器12 E5-2698v4*2 32G 1T HDD 50M/无限流量 $796.00 立即申请

gd-2.0.35.tar.gzlibxml2-2.7.7.tar.gzlibmcrypt-2.5.8.tar.bz2cronolog-1.6.2.tar.gzhttpd-2.2.8.tar.gzmysql-5.1.44.tar.gzphp-5.2.14.tar.gzxcache-1.3.0.tar.gzZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

修改系统参数,编写脚本执行init.sh

cd /opt

vi init.sh

将下列内容拷贝至init.sh脚本中

#welcomecat << EOF+--------------------------------------------------------------+| === Welcome toCentos System init===|+--------------http://www.linuxtone.org------------------------++----------------------Author:NetSeek--------------------------+EOF#disable ipv6cat << EOF+--------------------------------------------------------------+| === Welcome toDisable IPV6===|+--------------------------------------------------------------+EOFecho "alias net-pf-10 off" >> /etc/modprobe.confecho "alias ipv6 off" >> /etc/modprobe.conf/sbin/chkconfig --level 35 ip6tables offecho "ipv6 is disabled!"#disable selinuxsed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/configecho "selinux is disabled,you must reboot!"#vimsed -i "8 s/^/alias vi='vim'/" /root/.bashrcecho 'syntax on' > /root/.vimrc#zh_cnsed -i -e 's/^LANG=.*/LANG="zh_CN.GB18030"/'/etc/sysconfig/i18n#tunoff services#--------------------------------------------------------------------------------cat << EOF+--------------------------------------------------------------+| === Welcome toTunoff services===|+--------------------------------------------------------------+EOF#---------------------------------------------------------------------------------for i in `ls /etc/rc3.d/S*`doCURSRV=`echo $i|cut -c 15-`echo $CURSRVcase $CURSRV in crond |irqbalance | microcode_ctl | network | random | sendmail | sshd |syslog | local | mysqld ) echo "Base services, Skip!" ;; *) echo "change$CURSRV to off" chkconfig--level 235 $CURSRV off service$CURSRV stop ;;esacdone

执行脚本:

sh init.sh

重启系统

reboot

二、编译安装基本环境

使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)

rpm --importhttp://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bisonautoconf automake bzip2-devel ncurses-devel zlib-devellibjpeg-devel libpng-devel libtiff-devel freetype-devellibXpm-devel gettext-devel pam-devel libtool libtool-ltdlopenssl openssl-devel fontconfig-devel

解释如下:

安装基本的编译工具 # yum install -y gcc gcc-c++ flex bison autoconfautomake libtool bzip2-devel zlib-devel ncurses-devel pam-devel

安装编译 GD 需要的库# yum install -y xorg-x11-server-Xorgfontconfig-devel libXpm-devel libjpeg-devel libpng-devellibtiff-devel freetype-devel

安装mysql需要的库# yum install -y libxml2-devel curl-devel

编译安装软件包

1)GD2

tar -zxvf gd-2.0.35.tar.gz

cd gd-2.0.35

./configure --prefix=/usr/local/gd2

make && make install

2) LibXML2

tar -zxvf libxml2-2.7.7.tar.gz

cd libxml2-2.7.7

./configure --prefix=/usr/local/libxml2

make && make install

3) LibMcrypt

tar xvf libmcrypt-2.5.8.tar.bz2

cd libmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt

make && make install

4) Apache日志截断程序

tar zxvf cronolog-1.6.2.tar.gz

cd cronolog-1.6.2

./configure --prefix=/usr/local/cronolog

make && make install

5)安装mysql

tar -zxvf mysql-5.1.44.tar.gz

cd mysql-5.1.44

./configure --prefix=/usr/local/mysql --enable-assembler--with-extra-charsets=complex --enable-thread-safe-client--with-big-tables --with-readline --with-ssl --with-embedded-server--enable-local-infile

make && make install

创建MySQL数据库,用默认的配置my.cnf

groupadd mysql

useradd -g mysql mysql

cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql/.

添加Mysql启动服务,并且设置root密码

cp /usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysql

chmod 755 /etc/init.d/mysql

chkconfig --level 345 mysql on

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

echo "/usr/local/lib" >>/etc/ld.so.conf

ldconfig

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/mysql/include/mysql /usr/include/mysql

service mysql start

/usr/local/mysql/bin/mysqladmin -u root passwordroot //root改为你需要的密码

service mysql restart

6)安装apache

groupadd httpd

useradd -g httpd -s /sbin/nologin -M httpd

tar -zxvf httpd-2.2.8.tar.gz

cd httpd-2.2.8

./configure --prefix=/usr/local/apache2 --with-included-apr--enable-so --enable-deflate=shared --enable-expires=shared--enable-rewrite=shared --enable-static-support --disable-userdir--enable-dav --enable-maintainer-mode红色字体为部署SVN服务器所用,否则编译svn的时候会报错make

make install

7)安装php

tar -zxvf php-5.2.14.tar.gz

cd php-5.2.14

mkdir -p /usr/local/php/etc

./configure --prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2--with-gd=/usr/local/gd2 --with-jpeg-dir --with-png-dir --with-bz2--with-freetype-dir --with-iconv-dir --with-zlib-dir--with-openssll --with-mcrypt=/usr/local/libmcrypt --enable-soap--enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif--disable-ipv6 --disable-cgi --disable-cli

make

make install

cp php.ini-dist /usr/local/php/etc/php.ini

7)安装Xcache

tar -zxvf xcache-1.3.0.tar.gz

cd xcache-1.3.0

/usr/local/php/bin/phpize ./configure --enable-xcache--enable-xcache-coverager--with-php-config=/usr/local/php/bin/php-config--enable-inline-optimization --disable-debug

vi /usr/local/php/etc/php.ini

在最后添加以下内容

[xcache-common]zend_extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so[xcache.admin]xcache.admin.user = "admin";create md5 password: echo -n "password"| md5sumxcache.admin.pass ="f3dfd37a03b1356d6380b41e524f903b" #password is hx10.com[xcache]; Change xcache.size to tune the size of the opcode cachexcache.size =24Mxcache.shm_scheme = "mmap"xcache.count = 4xcache.slots = 8Kxcache.ttl =0xcache.gc_interval = 0; Change xcache.var_size to adjust the size of variable cachexcache.var_size = 8Mxcache.var_count = 1xcache.var_slots = 8Kxcache.var_ttl = 0xcache.var_maxttl = 0xcache.var_gc_interval = 300xcache.test =Offxcache.readonly_protection = Onxcache.mmap_path = "/tmp/xcache"xcache.coredump_directory = ""xcache.cacher = Onxcache.stat =Onxcache.optimizer = Off[xcache.coverager]xcache.coverager = Onxcache.coveragedump_directory = ""

8)安装Zend Optimizer系统如果是64位的,请安装64位的ZendOptimizer-3.3.9-linux-glibc23文件;

tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

mv ZendOptimizer-3.3.9-linux-glibc23-i386 /usr/local/Zend

cp /usr/local/Zend/data/5_2_x_comp/ZendOptimizer.so/usr/local/Zend/

vi /usr/local/php/etc/php.ini最后一行加入以下内容

zend_optimizer.optimization_level=15zend_extension=/usr/local/Zend/ZendOptimizer.so

9)整合Apache与PHP及系统初化配置

vi /usr/local/apache2/conf/httpd.conf

查找AddType application/x-gzip .gz .tgz,在该行下面添加

AddType application/x-httpd-php .php

查找DirectoryIndex index.html 把该行修改成

DirectoryIndex index.html index.htm index.php

找到

#Include conf/extra/httpd-mpm.conf#Include conf/extra/httpd-info.conf#Include conf/extra/httpd-vhosts.conf #Include conf/extra/httpd-default.conf

去掉这4行前面的#注意:以上 4 个扩展配置文件中的设置请按照相关原则进行合理配置!

vi /usr/local/apache2/conf/extra/httpd-vhosts.conf

ServerAdmin [email protected] DocumentRoot "/www/wwwroot/" ServerName www.test.com ServerAlias www.test.com ErrorLog "logs/www.test.com-error_log" CustomLog "logs/www.test.com-access_log"common

新建一个虚拟主机,删除原有的虚拟主机配置;

mkdir -p /www/wwwroot/

然后PHP探针放到这个目录

vi /usr/local/apache2/conf/httpd.conf

找到

Options FollowSymLinks AllowOverride None Order deny,allow Deny fromall//把这里的Deny改成Allow

找到

#ServerName www.example.com:80 在这一行后面加入下一行ServerName 127.0.0.1:80

找到

User httpdGroup httpd

把原来的daemon修改成httpdApache 运行账户httpd:httpd

chown -R httpd:httpd /www/wwwroot

重启apache

# /usr/local/apache2/bin/apachectl restart

输入探针的地址访问

http://ip/php.php

安装apache服务

cd httpd-2.2.8

cp support/apachectl /etc/init.d/httpdvi /etc/init.d/httpd加入以下的代码,使apache可以用chkconfig方式启动(保留#):# Startup script for the Apache Web Server# chkconfig: 2345 10 90# description: Apache is a World Wide Web server.# processname: httpd# pidfile: /usr/local/apache2/log/httpd.pid# config: /usr/local/apache2/conf/httpd.conf

安装服务并开机启动chmod 755 /etc/init.d/httpdchkconfig --add httpdchkconfig --level 345 httpd onservice httpd start10)安全和性能优化

vi /usr/local/php/etc/php.ini

查找disable_functions =

等号后面加入以下参数,注意不能换行

phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,get_cfg_var

查找以下2项,把on改成off

expose_php = Offdisplay_errors = Off

vi /usr/local/apache2/conf/extra/httpd-default.conf修改后的内容如下

Timeout 15KeepAlive OffMaxKeepAliveRequests 50KeepAliveTimeout 5UseCanonicalName OffAccessFileName .htaccessServerTokens ProdServerSignature OffHostnameLookups Off

vi /usr/local/apache2/conf/extra/httpd-mpm.conf修改一个模块后的内容如下

原来的配置如下:

ServerLimit 256 StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 256 MaxRequestsPerChild 0

修改后配置如下

ServerLimit2000StartServers2000MinSpareServers 10 MaxSpareServers10MaxClients2000 MaxRequestsPerChild 10000

查看是什么模式

/usr/local/apache2/bin/apachectl -l

如果出现prefork.c那就说明是prefork模式

标题:CentOS 5系统安装配置Apache+PHP+MySQL 5过程记录

地址: https://www.yunhk.xyz/26446.html