安装环境: Asianux3 内核版本:Asianux 3.1
软件包 : nginx-1.2.9.tar.gz
cmake-2.8.10.2.tar.gz
mysql-5.5.16.tar.gz
mhash-0.9.9.9.tar.gz
libiconv-1.13.1.tar.gz
libmcrypt-2.5.7.tar.gz
php-5.4.10.tar.gz
安装过程:
准备工作:
查看是否系统默认安装MySQL服务
#RPM -qa mysql
MySQL-5.0.45-7.1AXS3
MySQL-5.0.45-7.1AXS3
要先卸载MySQL软件,但是又不能使用yum卸载,要不然会报错。只能使用--nodeps 选项忽略依赖关系,但是又因为有俩个相同的MySQL版本,这是需要使用--allmaches选项, (即匹配所有的包)来卸载MySQL
#RPM -e --nodeps MySQL-5.0.45-7.1AXS3 --allmaches
1.安装nginx软件
#tar zxf nginx-1.2.9.tar.gz
#cd nginx-1.2.9
#useradd nginx
#groupadd nginx
#./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/usr/local/nginx/client --http-proxy-temp-path=/usr/local/nginx/proxy --http-fastcgi-temp-path=/usr/local/nginx/fcgi --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre
#make
#make install
#/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2.安装cmake软件,mysql5.0版本以后需要用cmake命令来编译,而不是make
#tar zxf cmake-2.8.10.2.tar.gz
#cd cmake-2.8.10.2
#./bootstrap --prefix=/usr/local/cmake
#make
#make install
#/usr/local/cmake/bin/cmake --version //查看版本
3.安装MySQL
#groupadd mysql
#useradd -g mysql mysql
#groupadd -g 306 mysql
#id mysql //查看用户ID号
#tar zxf mysql-5.5.16.tar.gz
#cd mysql-5.5.16
#/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tem/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_EBGINE=1
#make
#make install
#chown -R mysql:mysql /usr/local/mysql/*
#/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
#chown root:mysql /usr/local/mysql/*
#chown mysql:mysql /usr/local/mysql/data
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld
#chmod +R /etc/init.d/mysqld
#/etc/init.d/mysqld start
#vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/use/local/mysql/bin //写入MySQL的路径
#source ~/.bash_profile
#vim /etc/ld.so.conf
/usr/local/mysql/lib/ //写入库文件路径
#ldconfig //更新库文件
4.安装PHP扩展软件
#tar zxf mhash-0.9.9.9.tar.gz //哈希函数库
#cd mhash-0.9.9.9
#./configure
#make
#make install
#tar zxf libiconv-1.13.1.tar.gz //处理各种中文编码之间转换
#cd libiconv-1.13.1
#./configure
#make
#make install
#tar zxf libmcrypt-1.13.1.tar.gz //提供加密功能的库文件
#cd libmcrypt-2.5.7
#./configure
#make
#make install
#ldconfig -v
#cd libltdl/
#./configure --with-gmetad --enable-gexec --enable-ltdl-install
#make
#make install
#ln -sv /usr/local/lib/libmcrypt* /usr/lib/
#ln -sv /usr/local/lib/libmhash.* /usr/lib/ //对库文件做链接
#ldconfig -v //更新链接库
5.安装PHP
#tar zxf php-5.4.10.tar.gz
#cd php-5.4.10
#./configure --prefix=/usr/local/phpnginx --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/phpnginx/etc --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-openssl --with-mcrypt --with-gd --enable-gd-native-ttf --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
#make ZEND_EXTRA_LIBS=‘-liconv‘
#make instal
#cp php.ini-production /usr/local/phpnginx/etc/php.ini
//准备PHP配置文件
6.配置fast-cgi结合
#cd /usr/local/phpnginx/etc/
#cp php-fpm.conf.default php-fpm.conf
#vim php-fpm.conf
[global]
pid=run/php-fpm.pid
error_log=log/php-fpm.log
log_level=error
daemonize=yes
[nginx]
user=nginx
group=nginx
listen=127.0.0.1:9000
pm=dynamic
pm.max_children=32
pm.start_servers=15
pm.min_spare_servers=5
pm.max_spare_servers=32
#cd /root/php-5.4.10/sapi/fpm/
#cp init.d.php-fpm /etc/rc.d/init.d/php-fpm
#chmod +x /etc/rc.d/init.d/php-fpm
#chkconfig --add php-fpm
#chkconfig --list php-fpm
#service php-fpm start
7.编辑nginx配置文件
#vim /usr/local/nginx/cong/nginx.conf
location / {
root html;
index index.php index index.html;
}
location ~\.php${
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
incude fastcgi_params;
}
#vim /usr/local/nginx/conf/fastcgi_params
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $doument_root$/script$fastcgi_script_name; #/usr/local/nginx/sbin/nginx -c //usr/local/nginx/conf/nginx.conf
#/etc/rc.d/init.d/php-fpm restart
#vim /usr/local/nginx/
8.测试PHP与nginx,MySQL
#vim index.php
<?php
phpinfo();
$links=mysql_connect("localhost""root""");
if($links){
echo "link ok"
}
else{
echo "links faild"
}
?>
本文出自 “未来的一片蓝天” 博客,请务必保留此出处http://9052689.blog.51cto.com/9042689/1694448
原文地址:http://9052689.blog.51cto.com/9042689/1694448