一、安装nginx
上传安装包
解压到指定目录
[root@localhost ~]# tar -zxvf libevent-2.0.16-stable.tar.gz -C /usr/local/src/
[root@localhost ~]# tar -zxvf nginx-1.0.11.tar.gz -C /usr/local/src
查看目录
安装libevent-2.0.16-stable
[root@localhost src]# cd libevent-2.0.16-stable/
[root@localhost libevent-2.0.16-stable]# ./configure
[root@localhost libevent-2.0.16-stable]# make
[root@localhost libevent-2.0.16-stable]# make install
[root@localhost src]# groupadd -r nginx
[root@localhost src]# useradd -r -g nginx -s /bin/false -M nginx
安装nginx-1.0.11
[root@localhost nginx-1.0.11]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --with-pcre
[root@localhost nginx-1.0.11]# make
[root@localhost nginx-1.0.11]# make install
执行nginx
[root@localhost src]# nginx
nginx安装完成.
在客户端测试
二、安装mysql
首先把源mysql-5.5.15-linux2.6-i686 mysql移到/usr/local/src
在解压到上一级目录/usr/local/里面把文件名改为mysql(便于记忆)
进到mysql目录打开INSTALL-BINARY文件操作划线命令即可
创建库文件
[root@localhost etc]# cd ld.so.conf.d
[root@localhost ld.so.conf.d]# vim mysql.conf //建一conf后缀的文件打开
打开在里面输入mysql库路径/usr/local/mysql/lib
创建头文件
添加/usr/local/mysql/bin到环境变量PATH中
#export PATH=$PATH:/usr/local/mysql/bin
启动mysql(启动前务必杀死mysql进程)
mysql安装好了。
三、安装php
首先安装一依赖包
[root@localhost Server]# rpm -ivh libpng-devel-1.2.10-7.1.el5_0.1.i386.rpm
解压php安装包
[root@localhost ~]# tar -jzvf php-5.3.7.tar.bz2 -C /usr/local/src
[root@localhost ~]# cd /usr/local/src/php-5.3.7/
[root@localhost ~]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/nginx/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/bin/mysql_config --enable-mbstring=all
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make install
[root@localhost php-5.3.7]# cp php.ini-development /usr/local/php5/php.ini
[root@localhost php-5.3.7]# ln -s /usr/local/php5/bin/* /usr/local/bin/
[root@localhost php-5.3.7]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/
[root@localhostphp-5.3.7]#cp -p /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
[root@localhost php-5.3.7]# vim /usr/local/php5/etc/php-fpm.conf
[root@localhost local]# mkdir /var/run/php-fpm
[root@localhost local]# cd /usr/local/php5/sbin/
[root@localhost sbin]# ./php-fpm
编辑/etc/nginx/nginx.conf
[root@localhost ~]# vim /etc/nginx/nginx.conf
重启nginx
测试php
[root@localhost local]# cd /usr/html
[root@localhost html]# vim index.php
<?php
phpinfo();
?>
在客户端测试成功
测试mysql
[root@localhost html]# vim index.php
<?php $link=mysql_connect('127.0.0.1','root','');
if($link)
echo sccess;
else
echo fail;
?>
在客户端测试成功
到此为止lnmp架设成功。
学而时习之,可以为师矣。