lnmp环境搭建

系统运维 waitig 531℃ 百度已收录 0评论


1.安装nginx
关于nginx的安装请参考http://blog.csdn.net/qq_30256711/article/details/78588648
2.安装二进制包mysql
useradd mysql -M -s /sbin/nologin
tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32
chown -R mysql.mysql mysql-5.5.32/
scripts/mysql_install_db –basedir=/usr/local/mysql-5.5.32/ \
–datadir=/usr/local/mysql-5.5.32/data –user=mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod u+x /etc/init.d/mysqld
chkconfig mysqld on
chkconfig –list mysqld
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
service mysqld start
3.源码安装php
yum install zlib libxml2 libjpeg freetype libpng gd \
curl zlib-devel libxml2-devel libjpeg-devel freetype-devel \
libpng-devel gd-devel curl-devel libxslt libxslt-devel -y
tar zxvf libiconv-1.14.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
#install libiconv
cd libiconv-1.14
./configure –prefix=/usr/local/libiconv-1.14
make && make install
cd ../libmcrypt-2.5.8
./configure
make && make install
sleep 2
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
#install mhash
cd ../../mhash-0.9.9.9
./configure
make
make install
#install mcrypt
cd ../mcrypt-2.6.8
/sbin/ldconfig
./configure LD_LIBRARY_PATH=/usr/local/lib
make
make install
#install php
tar zxf php-5.3.27.tar.gz
cd php-5.3.27
./configure –prefix=/usr/local/php-5.3.27 \
> –with-mysql=/usr/local/mysql \
> –with-iconv-dir=/usr/local/libiconv \
> –with-freetype-dir \
> –with-jpeg-dir \
> –with-png-dir \
> –with-zlib \
> –with-libxml-dir=/usr \
> –enable-xml \
> –disable-rpath \
> –enable-safe-mode \
> –enable-bcmath \
> –enable-shmop \
> –enable-sysvsem \
> –enable-inline-optimization \
> –with-curl \
> –with-curlwrappers \
> –enable-mbregex \
> –enable-fpm \
> –enable-mbstring \
> –with-mcrypt \
> –with-gd \
> –enable-gd-native-ttf \
> –with-openssl \
> –with-mhash \
> –enable-pcntl \
> –enable-sockets \
> –with-xmlrpc \
> –enable-zip \
> –enable-soap \
> –enable-short-tags \
> –enable-zend-multibyte \
> –enable-static \
> –with-xsl \
> –with-fpm-user=nginx \
> –with-fpm-group=nginx \
> –with-libevent-dir \
> –enable-ftp \
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
make
make install
cp php.ini-production /usr/local/php-5.3.27/lib/php/php.ini
配置/usr/local/php-5.3.27/etc/php-fpm.conf配置文件
/usr/local/php-5.3.27/sbin/php-fpm 启动php-fpm
netstat -tlunp|grep php-fpm
4.配置服务开机自启动
cat >> /etc/rc.local <<EOF
/etc/init.d/mysqld start
/usr/local/php-5.3.27/sbin/php-fpm
/usr/local/nginx/sbin/nginx
EOF
5.nginx整合php
在nginx.conf中添加以下字段
location ~ .*\.(php|php5)?$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
index 添加index.php
6.php测试连接mysql
<?php
    $link_id=mysql_connect(‘localhost’,’root’,’haha123′) or mysql_error();
    if($link_id){
        echo "mysql successful by oldboy!\n";
    }else{
 echo "mysql_error()";
}
?>


本文由【waitig】发表在等英博客
本文固定链接:lnmp环境搭建
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)