服务器配置
1.购买好vps后登录服务器首先修改密码passwd root
2.修改ssh的超时时间
代码如下 | 复制代码 |
vi /etc/ssh/sshd_config ClientAliveInterval 60 ClientAliveCountMax 30 |
3.安装setup
代码如下 | 复制代码 |
#安装setuptool yum install setuptool #可以发现执行setup后不全,再安装一个用于系统服务管理 yum install ntsysv #再安装个防火墙,以及setup中配套的防火墙设置、网络设置 yum install iptables #安装setup中配套的防火墙设置 yum install system-config-securitylevel-tui #安装setup中配套的网络设置 yum install system-config-network-tui |
4.格式化磁盘,挂载磁盘
客户端环境:Mac OSX
远程连接方式:运行 Terminal,输入命令 ssh username@ip
硬盘分区及挂载操作步骤:
1. 查看未挂载的硬盘(名称为/dev/xvdb)
代码如下 | 复制代码 |
# fdisk -l Disk /dev/xvdb doesn't contain a valid partition table 2. 创建分区 # fdisk /dev/xvdb ... 输入n Command (m for help):n 输入p Command action e extended p primary partition (1-4) p 输入1 Partition number (1-4): 1 回车 First cylinder (1-2610, default 1): Using default value 1 回车 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): Using default value 2610 输入w Command (m for help): w The partition table has been altered! 3. 格式化分区 # mkfs.ext3 /dev/xvdb1 4. 建立挂载目录 # mkdir /data 5. 挂载分区 # mount /dev/xvdb1 /data 6. 设置开机自动挂载 vi /etc/fstab 在vi中输入i进入INERT模式,将光标移至文件结尾处并回车,将下面的内容复制/粘贴,然后按Esc键,输入:x保存并退出 www.111cn.net /dev/xvdb1 /data ext3 defaults 0 0 7. 确认是否挂载成功 重启服务器 # reboot 查看硬盘分区 # df /dev/xvdb1 20635700 176196 19411268 1% /data |
5.首先安装gcc
6.安装nginx
代码如下 | 复制代码 |
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz tar zxvf pcre-8.31.tar.gz cd pcre-8.31/ ./configure make && make install cd ../ checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/web/soft/pcre-8.31': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details 如果出现这样的错误,则表示系统没有编译gcc yum install gcc即可解决此问题 libtool: compile: unrecognized option `-DHAVE_CONFIG_H' libtool: compile: Try `libtool --help' for more information. make[1]: *** [pcrecpp.lo] 错误 1 make[1]: Leaving directory `/web/soft/pcre-8.31' make: *** [all] 错误 2 缺少gcc-c++ yum install gcc-c++ 可编译通过 |
二.安装nginx
代码如下 | 复制代码 |
官方网址:http://www.nginx.org/ wget http://www.nginx.org/download/nginx-1.2.5.tar.gz tar zxvf nginx-1.2.5.tar.gz cd nginx-1.2.5/ ./configure --user=www --group=www --prefix=/web/server/nginx --with-http_stub_status_module --with-http_ssl_module make && make install cd ../ 错误提示总结: 安装提示错误libpcre.so.1,则需要执行命令ln -s /usr/local/lib/libpcre.so.1 /lib64 如果没有安装pcre库,则在编译安装nginx的时候会提示./configure: error: the HTTP rewrite module requires the PCRE library. 如果提示错误nginx: [emerg] getpwnam("www") failed 则表示系统中没有www用户 用groupadd -f www useradd -g www www 如果提示错误./configure: error: SSL modules require the OpenSSL library. 则需要安装openssl ssl官网地址:http://www.openssl.org/source/ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz 编译安装ssl后重新安装nginx ./configure --user=www --group=www --prefix=/web/server/nginx --with-http_stub_status_module --with-openssl=/usr/local/ssl 如果系统没有安装gcc,则需要先安装gcc. 命令yum install gcc* 其他错误: 编译Nginx提示gzip module requires the zlib library 新手在尝试安装nginx时,常常会因为缺少依赖组件,导致nginx相应模块无法安装,在执行“./configure”时常出现错误。 若在“./configure”后方加入了“--with-http_gzip_static_module”(添加gzip压缩模块)提示以下错误: ./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using –without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using –with-zlib= option. 则需要安装“zlib-devel”即可。SSH执行以下命令: yum install -y zlib-devel或者去官方网站下载zlib安装wget http://zlib.net/zlib-1.2.7.tar.gz
|
7.安装mysql
代码如下
复制代码
rpm -ivh mysql.rpm
8.安装php参见
安装php5.4.0,编译安装php-5.4.0 ,php5.4.0 Zend Guard Loader暂时不支持,等待zend官方更新。
代码如下 | 复制代码 |
1.下载 wget wget http://cn.php.net/distributions/php-5.4.0.tar.gz wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0" wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0" wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0" wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.5-9.tar.gz wget http://pecl.php.net/get/imagick-3.0.1.tgz2.编译安装PHP 5.4.0所需的支持库 wget http://pecl.php.net/get/memcache-3.0.7.tgz tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./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 ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make make install cd ../ 3.编译mysql5.5.21 wget http://mysql.stu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz tar xvzf cmake-2.8.7.tar.gz ./configure make make install 编译安装mysql tar xvzf mysql-5.5.21.tar.gz cd mysql5.5.21 rm CMakeCache.txt cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.21/ -DMYSQL_DATADIR=/usr/local/mysql5.5.21/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/mysql5.5.21/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0 make && make install 4.编译php 安装依赖包 yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel tar xvzf php-5.4.0.tar.gz cd php-5.4.0 ./configure --prefix=/web/server/php --with-config-file-path=/web/server/php/etc --with-mysql --with-mysqli --with-pdo-mysql --with-iconv-dir=/usr/local --enable-fpm --disable-phar --with-fpm-user=www-data --with-fpm-group=www-data --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt --enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip --enable-bcmath --with-snmp --disable-ipv6 make ZEND_EXTRA_LIBS='-liconv' make test make install cp php.ini-production /usr/local/php5.4.0/etc/php.ini5.编译安装PHP5扩展模块 如果运行/web/server/php/bin/phpize,出现如下提示,则要安装m4 autoconf Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. yum install autoconf yum install m4 tar zxvf memcache-3.0.7.tgz cd memcache-3.0.7/ /web/server/php/bin/phpize ./configure --with-php-config=/web/server/php/bin/php-config make make install cd ../ /*暂时没有编译成功*/ tar xvzf memcached-1.0.2.tgz cd memcached-1.0.2 /web/server/php/bin/phpize ./configure --with-php-config=/web/server/php/bin/php-config make make install cd ../ /*没有编译*/ tar zxvf ImageMagick.tar.gz cd ImageMagick-6.5.1-2/ ./configure make make install cd ../ /*没有编译*/ tar zxvf imagick-2.3.0.tgz cd imagick-2.3.0/ /usr/local/php5.4.0/bin/phpize ./configure --with-php-config=/usr/local/php5.4.0/bin/php-config make make install cd ../6.修改配置 vi /web/server/php/etc/php.ini 最后增加: ;change for hugwww extension_dir = /usr/local/php5.4.0/lib/php/extensions/no-debug-non-zts-20090626/ extension = "memcache.so" extension = "memcached.so" extension = "imagick.so" 修改为: cgi.fix_pathinfo=0 open_basedir = /tmp:/www/web expose_php = Off allow_url_fopen = Off disable_functions =phpinfo,passthru,ini_restore,eval完成! |
.开机启动参见
编辑/etc/rc.d/rc.local文件,加入要启动的文件即可
代码如下 | 复制代码 |
/web/server/nginx/sbin/nginx /web/server/php/sbin/php-fpm /web/server/subversion/bin/svnserve -d -r /web/svn/repos /web/server/memcached/bin/memcached -d -m 100 -u www -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid /web/server/apache/bin/apachectl |
以上是启动nginx服务
启动php服务
启动svn服务
启动memcached服务
时间: 2024-11-03 21:21:55