5.创建web运行用户
# groupadd www
# useradd -g www www
# mkdir -p /home/www/wwwroot
# chmod +w /home/www/wwwroot
# chown www:www /home/www/wwwroot -R
6.重新启动
# init 6
编译安装环境
1. 安装MySQL
# cd /usr/local/src
# tar zxvf mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
# mv mysql-5.0.86-linux-i686-icc-glibc23 /usr/local/
# ln -s /usr/local/mysql-5.0.86-linux-i686-icc-glibc23/ /usr/local/mysql
# groupadd mysql
# useradd -g mysql mysql -d /home/mysql -s /sbin/nologin
# chown -R mysql:mysql /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql-5.0.86-linux-i686-icc-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
其中红色的password是要设置的root密码
2.编译安装Nginx
# cd /usr/local/src/
# tar zxvf nginx-0.7.65.tar.gz
# cd nginx-0.7.65
# ./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 clean
# cp /usr/local/src/nginx /etc/init.d/nginx
# chmod 755 /etc/init.d/nginx
# chkconfig –add nginx
# chkconfig nginx on
3. 编译安装PHP 所需的支持库
Libiconv
# cd /usr/local/src/
# tar zxvf libiconv-1.13.1.tar.gz
# cd libiconv-1.13.1/
# ./configure –prefix=/usr/local
# make
# make install
# cd ..
Libmcrypt
# 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 /usr/local/src/
Mhash
# 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
4.编译安装PHP
# cd /usr/local/src
# tar zxvf php-5.2.13.tar.gz
# gzip -cd php-5.2.13-fpm-0.5.14.diff.gz | patch -d php-5.2.13 -p1
# cd php-5.2.13
# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/etc/cgi –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir=/usr –with-jpeg-dir=/usr –with-png-dir=/usr –with-zlib –with-libxml-dir=/usr –with-xmlrpc –enable-xml –enable-mbstring –enable-ftp –with-gd –enable-magic-quotes –with-pear –enable-sockets –with-ttf –enable-gd-native-ttf –enable-sysvsem –enable-sysvshm –enable-shmop –enable-force-cgi-redirect –enable-fastcgi –enable-zip –enable-fpm –with-mhash –with-mcrypt –enable-discard-path –enable-bcmath –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –with-openssl
# make ZEND_EXTRA_LIBS=’-liconv’
# 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/php/etc/php-fpm.conf
# echo ‘ulimit -SHn 65535’ >> /etc/rc.local
# echo ‘/usr/local/php/sbin/php-fpm start’ >> /etc/rc.local
5.安装PHP扩展模块
Memcache
# cd /usr/local/src
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5/
# /usr/local/php/bin/phpize
# ./configure –with-php-config=/usr/local/php/bin/php-config
# make
# make install
修改php.ini文件,路径/usr/local/etc/cgi/
查找:extension_dir = “./”
修改成:extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
在此句下面一行
添加:extension = “memcache.so”
查找:output_buffering = Off
修改成:output_buffering = On
保存。
Memcached
# cd /usr/local/src
#tar zxvf libevent-1.4.13-stable.tar.gz
# cd libevent-1.4.13-stable
# ./configure –prefix=/usr/lib
# make
# make install
# cd ../
# tar zxvf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure –prefix=/usr/local –with-libevent=/usr/lib/
# make
# make install
# /usr/local/bin/memcached -d -u www -m 128
-p
监听的TCP端口(缺省: 11211)
-d
以守护进程方式运行 以守护进程方式运行 Memcached Memcached
-u
运行运行 Memcached的账户 非root用户
-m
最大的内存使用单位是MB 缺省是64MB
-c
软连接数量缺省是1024
-v
输出警告和错误信息
-vv
打印客户端的请求和返回信息
-h
打印帮助信息
-i
打印memcached和libevent的版权信息
6.安装ZendOptimizer
# cd ..
# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-i386
# ./install
Please specify the location for installing
Zend Optimizer:
这里填写Zend的安装路径,按下面写即可
/usr/local/Zend
Confirm the location of your
php.ini file:
这里填写的是php.ini的路径,按下面写即可
/usr/local/etc/cgi
Are you using Apache Web server?
这里选No
7.启动Nginx和PHP
# mv -f /usr/local/src/fcgi.conf /usr/local/nginx/conf/
# cp -f /usr/local/src/nginx.conf /usr/local/nginx/conf/nginx.conf
# ulimit -SHn 65535
# /usr/local/php/sbin/php-fpm start
# service nginx start
8.关于安全设置
查找/usr/local/etc/cgi/php.ini里的
; cgi.fix_pathinfo=0
把这句前的分号去掉,变成
cgi.fix_pathinfo=0
好了…恭喜你,配置完成!
ps:如有不对,欢迎指正!在错误中成长!
编译这块学的不好!
顶起!
哦,本地模版修改中,上传之后再搞来搞去不好。
那你应该禁止搜索引擎访问,网上很多。。。或不解析域名,等准备上传了在解析!要不同样的页面改版太大!
大师,怎么用cpanel的时钟守护作业脚本自动备份网站数据和数据库啊,网上那些代码到我这边都用不了啊。。
手动备份吧!自动备份脚本爱出错!
好文章呀,说得太详细了,收藏下来,谢谢提供。
看了你的站,居然用kloxo面板的一键安装!
这样有什么问题吗?
没问题…但定制性不好!
不爱折腾的无所谓了
怎么还是默认页面?
饮食健康站?
2天了啊!