LNMP

1.0安装MySQL

参见http://www.51centos.com/?p=90

1.1 php编译安装

[root@xclinux src]# ls
123 nginx-1.4.4 php-5.3.27.tar.gz
mysql-5.1.72-linux-i686-glibc23 nginx-1.4.4.tar.gz
mysql-5.1.72-linux-i686-glibc23.tar.gz php-5.3.27

[root@xclinux src]# cd php-5.3.27
[root@xclinux php-5.3.27]# useradd -s /sbin/nologin php-fpm 创建相关账户

[root@xclinux php-5.3.27]# make

[root@xclinux php-5.3.27]# echo $?
0
[root@xclinux php-5.3.27]# make install
[root@xclinux php-5.3.27]# echo $?
0
[root@xclinux php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini
拷贝配置文件
[root@xclinux php-5.3.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
拷贝启动文件

[root@xclinux php-5.3.27]# vim !$ 查看文件,启动的shell脚本
vim /etc/init.d/php-fpm

[root@xclinux php-5.3.27]# chmod 755 /etc/init.d/php-fpm 授予执行权限

[root@xclinux php-5.3.27]# chkconfig –add php-fpm 加入服务列表

[root@xclinux php-5.3.27]# chkconfig php-fpm on 开机启动

[root@xclinux php-5.3.27]# service php-fpm start 启动服务
Starting php-fpm [19-Jul-2016 14:51:17] ERROR: failed to open configuration file ‘/usr/local/php/etc/php-fpm.conf’: No such file or directory (2)
[19-Jul-2016 14:51:17] ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf’
[19-Jul-2016 14:51:17] ERROR: FPM initialization failed
failed
报错。配置文件不存在。

[root@xclinux php-5.3.27]# cd /usr/local/php/etc/

[root@xclinux etc]# ls
pear.conf php-fpm.conf.default php.ini

[root@xclinux etc]# mv php-fpm.conf.default php-fpm.conf 将样本重命名

[root@xclinux etc]# /usr/local/php/sbin/php-fpm -t

[root@xclinux php-5.3.27]# service php-fpm start
Starting php-fpm done

[root@xclinux etc]# ps aux |grep php-fpm
root 10855 0.0 0.4 25956 2928 ? Ss 14:55 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
php-fpm 10856 0.0 0.3 25956 2632 ? S 14:55 0:00 php-fpm: pool www
php-fpm 10857 0.0 0.3 25956 2632 ? S 14:55 0:00 php-fpm: pool www
root 10859 0.0 0.1 5980 740 pts/0 S+ 14:55 0:00 grep php-fpm

[root@xclinux php-5.3.27]# vim /usr/local/php/etc/php-fpm.conf
[root@xclinux etc]# /usr/local/php/sbin/php-fpm -t 检查错误
[24-Apr-2016 12:38:17] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

1.2 Nginx编译安装

[root@xclinux local]# cd /usr/local/src/
[root@xclinux src]# tar zxvf nginx-1.4.4.tar.gz
[root@xclinux src]# ls
123 nginx-1.4.4 php-5.3.27
mysql-5.1.72-linux-i686-glibc23.tar.gz nginx-1.4.4.tar.gz php-5.3.27.tar.gz

./configure: error: the HTTP rewrite module requires the PCRE library. 报错

[root@xclinux nginx-1.4.4]# yum install pcre-devel -y
[root@xclinux nginx-1.4.4]# echo $?

0
[root@xclinux nginx-1.4.4]# make

[root@xclinux nginx-1.4.4]# echo $?
0

[root@xclinux nginx]# make install

[root@xclinux nginx-1.4.4]# echo $?
0
[root@xclinux nginx-1.4.4]# cd /usr/local/nginx/
[root@xclinux nginx]# ls
conf html logs sbin

[root@xclinux nginx]# ls sbin/nginx
sbin/nginx nginx的可执行文件

[root@xclinux nginx]# /usr/local/nginx/sbin/nginx 启动nginx

[root@xclinux nginx]# ps aux |grep nginx
root 7467 0.0 0.0 5372 624 ? Ss 12:57 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 7468 0.0 0.1 5544 956 ? S 12:57 0:00 nginx: worker process
root 7470 0.0 0.1 5980 740 pts/0 S+ 13:00 0:00 grep nginx

[root@xclinux nginx]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 31105/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 12788/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 847/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7467/nginx

1.3 配置nginx解析php,测试php解析。

[root@xclinux ~]# vim /usr/local/nginx/html/info.php

[root@xclinux ~]# vim /usr/local/nginx/conf/nginx.conf

[root@xclinux ~]# /usr/local/nginx/sbin/nginx -t
[root@xclinux ~]# /usr/local/nginx/sbin/nginx -s reload 重新加载配置文件

1.4 nginx启动脚本和配置文件
nginx没有自己的启动脚本,需要自己写。

[root@xclinux ~]# chmod 755 /etc/init.d/nginx 可执行权限
[root@xclinux ~]# chkconfig –add nginx 加入启动项
[root@xclinux ~]# chkconfig nginx on 开机启动

未经允许不得转载: » LNMP
微信公众号:这是个测试
关注我们,每天分享更多有趣的事儿,有趣有料!
12000人已关注
分享到:
赞(0) 打赏

评论抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏