centos 5 php 几能安装 fpm,在CentOS 6.2上安装Nginx+PHP5(PHP-FPM)+MySQL

1.使用非官方软件源

rpm --import https://fedoraproject.org/static/0608B895.txt

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum install yum-priorities

编辑/etc/yum.repos.d/epel.repo文件,启用这个源,使其优先级最高

[epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 priority=10 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [...]

同样的,也需要对remi源进行优先级编辑和启用

[remi] name=Les RPM de remi pour Enterprise Linux $releasever - $basearch #baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/ mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror enabled=1 priority=10 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi failovermethod=priority

[remi-test]

name=Les RPM de remi en test pour Enterprise Linux $releasever – $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/test/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/test/mirror

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

2.安装MYSQL

yum install mysql mysql-server

设置系统启动时,在235的运行级运行mysqld守护进程

chkconfig --levels 235 mysqld on /etc/init.d/mysqld start

需要按系统配置优化my.cnf文件,之后设置root的密码,否则任何人都能访问你的数据库。

[root@server1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank, so you should just press enter here.   Enter current password for root (enter for none): < -- ENTER OK, successfully used password, moving on...   Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.   Set root password? [Y/n]

installation should now be secure.

Thanks for using MySQL!

[root@server1 ~]#

3.安装nginx

nginx在epel源中有包,可以直接yum安装。

yum install nginx

之后创建nginx的系统启动连接并启动它

chkconfig --levels 235 nginx on

service nginx start

之后在浏览器中打开服务器的IP地址,应该能看到nginx的欢迎页面。

0818b9ca8b590ca3270a3433284dd417.png

4.安装php和php-fpm

yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

其中使用的php-x扩展,可以根据自己的需要添加。之后,编辑php.ini文件,修改cgi.fix_pathinfo为0。为什么要这么做?请查阅该文档。

vi /etc/php.ini

cgi.fix_pathinfo = 0 date.timezone = "Asia/Shanghai"

5.配置nginx

关于配置nginx可以查阅官方的两个例子,例子1,例子2。

6.让PHP-FPM使用unix套接字

默认情况下,php-fpm使用127.0.0.1:9000监听请求,当然也可以使用unix套接字,这样可以避免TCP的额外流量。编辑/etc/php-fpm.d/www.conf文件就可以了。

vi /etc/php-fpm.d/www.conf

[...] ;listen = 127.0.0.1:9000 listen = /tmp/php5-fpm.sock [...]

之后,重启php-fpm。

service php-fpm restart

之后编辑nginx的虚拟主机配置文件,将fastcgi_pass这一行内容改为unix套接字。

[...] location ~ \.php$ { try_files $uri =404;

root /usr/share/nginx/html;

fastcgi_pass unix:/tmp/php5-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params; } [...]

最后,重启nginx。

service nginx reload

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值