CentOS 6.9 yum安装LNMP环境方法

php 5.6.31的安装方法:https://webtatic.com/packages/php56/

yum list installed | grep php
yum remove php*
rpm -qa | grep webstatic
rpm -e php56w
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum list | grep php56w
yum -y install php56w.x86_64 php56w-bcmath.x86_64 php56w-dba.x86_64 php56w-embedded.x86_64 php56w-enchant.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-devel.x86_64 php56w-fpm.x86_64 php56w-gd.x86_64 php56w-imap.x86_64 php56w-intl.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysqlnd.x86_64 php56w-opcache.x86_64 php56w-pdo.x86_64 php56w-pecl-apcu.x86_64 php56w-pecl-apcu-devel.x86_64 php56w-pecl-gearman.x86_64 php56w-pecl-geoip.x86_64 php56w-pecl-igbinary.x86_64 php56w-pecl-igbinary-devel.x86_64 php56w-pecl-imagick.x86_64 php56w-pecl-imagick-devel.x86_64 php56w-pecl-memcache.x86_64 php56w-pecl-memcached.x86_64 php56w-pecl-mongodb.x86_64 php56w-pecl-redis.x86_64 php56w-pecl-xdebug.x86_64 php56w-phpdbg.x86_64 php56w-process.x86_64 php56w-pspell.x86_64 php56w-recode.x86_64 php56w-snmp.x86_64 php56w-soap.x86_64 php56w-tidy.x86_64 php56w-xml.x86_64 php56w-xmlrpc.x86_64
php -v

mysql 5.7的安装方法:http://www.cnblogs.com/jimboi/p/6405560.html

下载配置mysql的yum源的rpm包htttp://www.mysql.com

wget https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm

rpm -Uvh mysql57-community-release-el6-11.noarch.rpm

yum install mysql-community-server

service mysqld start

mysql安装成功后创建的超级用户'root'@'localhost'的密码会被存储在<strong>/var/log/mysqld.log</strong>,可以使用如下命令查看密码

grep ‘temporary password’ /var/log/mysqld.log

<span data-wiz-span="data-wiz-span">使用mysql生成的</span>‘root’@’localhost’用户和密码登录数据库,并修改 其密码,具体命令

mysql -uroot -p

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPassword!’;

use mysql;

update user set host =’%’ where user =’root’;

flush privileges;

 

nginx 1.12的安装方法:https://zhangzifan.com/centos-nginx-yum-source.html

vim /etc/yum.repos.d/nginx.repo

[nginx] name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

 

yum list |grep nginx

yum -y install nginx

rpm -q nginx

 

设置启动项,修改配置文件,nginx+php-fpm:http://www.cnblogs.com/afan/p/7219841.html

nginx的配置文件nginx.conf

include /etc/nginx/conf.d/*.conf;

default.conf

server {
listen 80;
server_name phpfig.com www.phpfig.com;

location / {
root /wwwroot;
index index.html index.htm index.php;
}

location ~ \.php$ {
root /wwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

1.nginx

service nginx start #启动

chkconfig nginx on #设为开机启动

/etc/init.d/nginx restart #重启

2.mysql

/etc/init.d/mysqld start #启动MySQL

chkconfig mysqld on #设为开机启动

/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #启动
service mysqld restart #重启

3.php

/etc/init.d/mysqld restart #重启MySql
/etc/init.d/nginx restart #重启nginx
/etc/rc.d/init.d/php-fpm start #启动php-fpm
chkconfig php-fpm on #设置开机启动

 

 

关于nginx的配置:

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

 

events {
worker_connections 2048;
}

 

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {
listen 8888;
charset utf-8;

location / {
root /home/bona/quxue/course_client;
index hzbnGame.html;
}
}

server {
listen 80;
server_name word.quxueabc.com;
charset utf-8;

location / {
root /home/bona/quxue/course_client;
index hzbnGame.html;
}
}

server {
listen 80;
server_name www.quxueabc.com;
charset utf-8;

location / {
root //home/FantasyWorld/page;
index index.html;
}
}

server
{
listen 8083;
server_name localhost;
index index.html index.htm index.php;
root /www;

location /www {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ [^/]\.php(/|$) {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
}

}

server {
listen 8082;
server_name 127.0.0.1;
root /www/wp;
index index.html index.htm index.php;
access_log /www/log/error.log;

location / {
#try_files $uri $uri/ index.php$is_args$query_string;
try_files $uri $uri/ /index.php/$request_uri;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
#expires 30d;
}

location ~ .*\.(js|css)?$
{
#expires 12h;
}

}

server {
listen 8084;
server_name 127.0.0.1;
root /www/oauth2/demo/web;
index index.html index.htm index.php;
access_log /www/log/error.log;

location / {
#try_files $uri $uri/ index.php$is_args$query_string;
try_files $uri $uri/ /index.php/$request_uri;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
#expires 30d;
}

location ~ .*\.(js|css)?$
{
#expires 12h;
}

}

server {
listen 80;
server_name bbs.quxueabc.com;

location / {
root /www/startbbs;
index index.php index.htm index.html;
autoindex on;
}

location ~ \.php.*$ {
root /www/startbbs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?$1 last;
}
}
}

include /etc/nginx/conf.d/*.conf;

 

server
{
listen 8083;
server_name localhost;
index index.html index.htm index.php;
root /www;

location /www {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ [^/]\.php(/|$) {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
}

 }

server {
listen 8082;
server_name 127.0.0.1;
root /www/wp;
index index.html index.htm index.php;
access_log /www/log/error.log;

     location / {
#try_files $uri $uri/ index.php$is_args$query_string;
try_files $uri $uri/ /index.php/$request_uri;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
#expires  30d;
}

location ~ .*\.(js|css)?$
{
#expires 12h;

 }

 server {
listen 8084;
server_name 127.0.0.1;
root /www/oauth2/demo/web;
index index.html index.htm index.php;
access_log /www/log/error.log;

     location / {
#try_files $uri $uri/ index.php$is_args$query_string;
try_files $uri $uri/ /index.php/$request_uri;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
#expires  30d;
}

location ~ .*\.(js|css)?$
{
#expires 12h;

 }

 server {
listen 80;
server_name bbs.quxueabc.com;

     location / {
root /www/startbbs;
index index.php index.htm index.html;
autoindex on;
}

location ~ \.php.*$ {
root /www/startbbs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?$1 last;
}
}
}

参考:

http://www.cnblogs.com/jianxie/p/3990377.html

https://webtatic.com/packages/php56/

http://www.blogjava.net/nkjava/archive/2015/01/20/422289.html

http://www.cnblogs.com/chy1000/p/5594562.html

http://repo.webtatic.com/yum/el6/x86_64/

http://rpms.famillecollet.com/enterprise/6/remi/x86_64/

 

http://www.cnblogs.com/chy1000/p/5594562.html

http://my.oschina.net/lxrm/blog/542706

原文链接:https://www.hertzdance.com/blog/centos-6-9-yum-lnmp,转载请注明出处。

0

评论0

请先
欢迎光临频率跳动资源网
显示验证码
没有账号?注册  忘记密码?