CentOS6.5 LNMP环境搭建

来源:互联网 发布:帕森斯火箭数据 编辑:程序博客网 时间:2024/04/29 19:00

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/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1priority=10gpgcheck=1gpgkey=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/mirrorenabled=1priority=10gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remifailovermethod=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:9000listen = /tmp/php5-fpm.sock[...]

service php-fpm reload

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


service nginx reload









0 0
原创粉丝点击