nginx配置,php mysql Nginx配置方法

Linux+Nginx+PHP+MySQL(LAMP依然是当今最流行的Web开发平台虽然有Nginx取代Apache的趋向....)

nginx配置,php mysql Nginx配置方法

安装LAMP有一键傻瓜式安装,不过本人不太喜欢而已,就好像我从不用Ghost安装系统一样。毕竟那是别人写好的,心里总是不放心。
废话不多说,下面开始讲解:
环境:
系统:CnetOS 5.5
内核:2.6.18
Part 1.
(1)删除Linux系统默认安装的web服务器软件包,如:httpd、mysql、php等,卸载可以用以下命令:
[[email protected]~]#rpm -e httpd
[[email protected]~]#rpm -e php
[[email protected]~]#rpm -e mysql
(2)使用yum更新系统组件
[[email protected]~]#yum -y install yum-fastestmirror
[[email protected]~]#yum -y update
[[email protected]~]#yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file
[[email protected]~]#yum -y install libtool libtool-libs autoconf kernel-devel
[[email protected]~]#yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
[[email protected]~]#yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
[[email protected]~]#yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
[[email protected]~]#yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
[[email protected]~]#yum -y install openssl openssl-devel vim-minimal nano sendmail
[[email protected]~]#yum -y install fonts-chinese gettext gettext-devel
[[email protected]~]#yum -y install ncurses-devel
[[email protected]~]#yum -y install gmp-devel pspell-devel
[[email protected]~]#yum -y install unzip
(3)准备安装需要使用的软件包,使用wget下载
>1.php-5.2.10
>2.php-5.2.10-fpm-0.5.13
>3.sohusin-patch-5.2.10-0.9.7.patch.gz
>4.PDO_MySQL-1.0.2
>5.memcache2.2.5
>6.Pcre7.9
>7.Nginx0.7.65
>8.MySQL5.1.44
>9.libiconv
>10.libmcrypt
>11.mhash
>12.mcrypt
Part 2.安装
//install libiconv
[[email protected]~]#tar zxvf libiconv-1.13.tar.gz
[[email protected]~]#cd libiconv-1.13/
[[email protected]~]#./configure --prefix=/usr/local
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//install libmcrypt
[[email protected]~]#tar zxvf libmcrypt-2.5.8.tar.gz
[[email protected]~]#cd libmcrypt-2.5.8/
[[email protected]~]#./configure
[[email protected]~]#make && make install
[[email protected]~]#/sbin/ldconfig
[[email protected]~]#cd libltdl/
[[email protected]~]#./configure --enable-ltdl-install
[[email protected]~]#make && make install
[[email protected]~]#cd ../../
//install mhash
[[email protected]~]#tar zxvf mhash-0.9.9.9.tar.gz
[[email protected]~]#cd mhash-0.9.9.9/
[[email protected]~]#./configure
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//使用ln -s 命令给lib组件建立软连接
[[email protected]~]#ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
[[email protected]~]#ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
[[email protected]~]#ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[[email protected]~]#ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
[[email protected]~]#ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
[[email protected]~]#ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
[[email protected]~]#ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
[[email protected]~]#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
//install mcrypt
[[email protected]~]#tar zxvf mcrypt-2.6.8.tar.gz
[[email protected]~]#cd mcrypt-2.6.8/
[[email protected]~]#./configure
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//install mysql
[[email protected]~]#tar -zxvf mysql-5.1.44.tar.gz
[[email protected]~]#cd mysql-5.1.44/
[[email protected]~]#./configure --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//使用独立用户运行mysql
[[email protected]~]#groupadd mysql
[[email protected]~]#useradd -g mysql mysql
[[email protected]~]#cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
[[email protected]~]#/usr/local/mysql/bin/mysql_install_db --user=mysql
[[email protected]~]#chown -R mysql /usr/local/mysql/var
[[email protected]~]#chgrp -R mysql /usr/local/mysql/.
[[email protected]~]#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
[[email protected]~]#chmod 755 /etc/init.d/mysql
[[email protected]~]#chkconfig --level 345 mysql _disibledevent=>mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin
make ZEND_EXTRA_LIBS='-liconv'
[[email protected]~]#make install
[[email protected]~]#cp php.ini-dist /usr/local/php/etc/php.ini
[[email protected]~]#cd ../
//install memcache
[[email protected]~]#tar zxvf memcache-2.2.5.tgz
[[email protected]~]#cd memcache-2.2.5/
[[email protected]~]#/usr/local/php/bin/phpize
[[email protected]~]#./configure --with-php-config=/usr/local/php/bin/php-config
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//install PDO_MySQL
[[email protected]~]#tar zxvf PDO_MYSQL-1.0.2.tgz
[[email protected]~]#cd PDO_MYSQL-1.0.2/
[[email protected]~]#/usr/local/php/bin/phpize
[[email protected]~]#./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
[[email protected]~]#make
[[email protected]~]#make install
[[email protected]~]#cd ../
[root@permit~]#groupadd www
[root@permit~]#useradd -g www www
[root@permit~]#mkdir -p /web/wwwroot
[root@permit~]#chmod +w /web/wwwroot
[root@permit~]#mkdir -p /web/wwwroot/logs
[root@permit~]#chmod 777 /web/wwwroot/logs
//install pcre
[[email protected]~]#tar zxvf pcre-7.9.tar.gz
[[email protected]~]#cd pcre-7.9/
[[email protected]~]#./configure
[[email protected]~]#make && make install
[[email protected]~]#cd ../
//install nginx
[[email protected]~]#tar zxvf nginx-0.7.65.tar.gz
[[email protected]~]#cd nginx-0.7.65/
[[email protected]~]#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[[email protected]~]#make && make install
[[email protected]~]#cd ../
Tags:  nginx配置

延伸阅读

最新评论

发表评论