CentOS6.5 LNMP环境搭建

CentOS6.5 配置好IP后,开始LNMP环境配置。

1,添加repo源

rpm --import https://fedoraproject.org/static/0608B895.txt 
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum install yum-priorities

编辑 /etc/yum.repos.d/epel.repo...

vi /etc/yum.repos.d/epel.repo

... and add the line priority=10 to the [epel] section:

[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
[...]

Then do the same for the [remi] section in /etc/yum.repos.d/remi.repo, plus change enabled to 1:

编辑remi

vi /etc/yum.repos.d/remi.repo

[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

2, Installing MYSQL 5

yum install mysql mysql-server

chekconfig --levels 235 mysqld on

service mysqld start

检查

netstat -tap | grep mysql

It should show something like this:

[root@server1 ~]# netstat -tap | grep mysql
tcp        0      0 *:mysql                     *:*                         LISTEN      1279/mysqld         
[root@server1 ~]# 

设置mysql用户名密码

mysql_secure_installation


3,Installing Nginx

yum install nginx

chkconfig --level 235 nginx on

service nginx start

如果自带了apache 先删除

apachectl stop
yum remove httpd
chkconfig --level 235 httpd off

chekconfig --levels 235 nginx on

service nginx start

打开浏览器输入IP看看是否显示welconme to nginx

如果未显示,设置开放80端口

vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

service iptables restart


4,Installing PHP5

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

yum install php-pecl-apc

vi /etc/php.ini

cgi.fix_pathinfo=1

date.timezone = "Asia/Shanghai"

chkconfig --levels 235 php-fpm on

service php-fpm start


5,Configuting nginx

vi /etc/nginx/nginx.conf

[...]
worker_processes  4;
[...]
    keepalive_timeout  2;
[...]

mkdir /usr/wwwroot

vi /etc/nginx/conf.d/default.conf



service nginx reload


vi /usr/wwwroot/info.php



6,

Making PHP-FPM Use A Unix Socket

By default PHP-FPM is listening on port 9000 on 127.0.0.1. It is also possible to make PHP-FPM use a Unix socket which avoids the TCP overhead. To do this, open /etc/php-fpm.d/www.conf...

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

... and make the listen line look as follows:

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

service php-fpm reload

vi /etc/nginx/conf.d.default.conf


service nginx reload









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值