0

0

Centos6.5搭建php环境(nginx+mariadb+php7)

php中文网

php中文网

发布时间:2016-07-06 13:31:02

|

1348人浏览过

|

来源于php中文网

原创

php小菜一枚,第一次写bolg,有什么不对的地方,还请各位大大指出 1.mariaDb vim /etc/ yum .repos.d/MariaDB.repo [mariadb ] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos5-x86 gpgkey =https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgc

php小菜一枚,第一次写bolg,有什么不对的地方,还请各位大大指出

1.mariaDb

vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

sudo yum install MariaDB-server MariaDB-client
#启动MariaDB
sudo /etc/init.d/MySQL start

通过在创建MariaDB.repo,可以实现yum安装

 

对应不同linux版本配置文件,和详细方法可以参考下面链接

立即学习PHP免费学习笔记(深入)”;

https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/

https://downloads.mariadb.org/mariadb/repositories/#mirror=opencas

2.nginx

#此命令可以一键安装开发工具包
yum
-y groupinstall "Development Tools" "Development Libraries"

 #创建www组与www用户
  groupadd www
  useradd -g www -s /usr/sbin/nologin www

 # 安装Nginx

 tar zxvf nginx-1.9.9.tar.gz

 cd nginx-1.9.9.tar.gz/
 ./configure --user=www --group=www --PRefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
 make && make install

 #启动Nginx
 /usr/local/nginx/sbin/nginx
 #测试配置文件是否正确
 /usr/local/nginx/sbin/nginx -t

还可以通过service命令来操作nginx服务,如下

1.先创建一个文件,里面写入以下shell脚本如:

进入编辑模式并复制以下内容:查看nginx.shell文件

魔众盲盒系统
魔众盲盒系统

魔众盲盒系统,快速搭建在线盲盒系统。 “盲盒”已经深入到了各个行业,电商、化妆品、旅游、餐饮、 NFT等各个领域,都有自己独特的发展模式,但它们的玩法千差万别,让我们来看一看这套系统的构造。 运行环境: 操作系统Linux/Unix 或 Windows 软件环境Laravel 5.1的运行环境 Apache/Nginx PHP 5.5.9+ / PHP

下载

 

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
#
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx.pid

RETVAL=0
prog="nginx"

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x $nginxd ] || exit 0


# Start nginx daemons functions.
start() {

if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi

   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL

}


# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}


# reload nginx service functions.
reload() {

    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo

}

# See how we were called.
case "$1" in
start)
        start
        ;;

stop)
        stop
        ;;

reload)
        reload
        ;;

restart)
        stop
        start
        ;;

status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac

exit $RETVAL

2.把这个文件复制到/etc/init.d目录下

#cp ./nginx /etc/init.d

3.修改这个文件为可执行的权限

#chmod +x /etc/init.d/nginx

4.把这个可执行文件加到服务服务中去

#chkconfig --add nginx

之后就可以使用 service 命令来管理了!

3.php

#安装前先更新所需要的模块
# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
# wget  https://downloads.php.net/~ab/php-7.0.0RC1.tar.gz
# tar zxvf php-7.0.0RC1.tar.gz
# cd php-7.0.0RC1
# ./configure --prefix=/usr/local/php \
 --with-curl \
 --with-freetype-dir \
 --with-gd \
 --with-gettext \
 --with-iconv-dir \
 --with-kerberos \
 --with-libdir=lib64 \
 --with-libxml-dir \
 --with-mysqli \
 --with-openssl \
 --with-pcre-regex \
 --with-pdo-mysql \
 --with-pdo-sqlite \
 --with-pear \
 --with-png-dir \
 --with-xmlrpc \
 --with-xsl \
 --with-zlib \
 --enable-fpm \
 --enable-bcmath \
 --enable-libxml \
 --enable-inline-optimization \
 --enable-gd-native-ttf \
 --enable-mbregex \
 --enable-mbstring \
 --enable-opcache \
 --enable-pcntl \
 --enable-shmop \
 --enable-soap \
 --enable-sockets \
 --enable-sysvsem \
 --enable-xml \
 --enable-zip

# 编译安装
# make &&  make install

# 配置文件
# cp php.ini-development /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

# 启动
# /etc/init.d/php-fpm

# 查看是否启动
ps aux | grep php

修改nginx配置,监听*.php的文件

# vim /usr/local/nginx/conf/nginx.conf

简单配置如下:

user  www www;

worker_processes 10;

#error_log  /data/logs/nginx_error.log  crit;


#pid        logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
    use epoll;

    worker_connections 51200;
}

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

    #charset  gbk;
     
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    #client_max_body_size 8m;

    server_tokens off;

    expires       1h; 

    sendfile on;
    tcp_nopush     on;
    keepalive_timeout 60;
    tcp_nodelay on;

    error_page   404  /404.jpg;

     fastcgi_connect_timeout 20;
     fastcgi_send_timeout 30;
     fastcgi_read_timeout 120;
     fastcgi_buffer_size 256k;
     fastcgi_buffers 8 256k;
     fastcgi_busy_buffers_size 256k;
     fastcgi_temp_file_write_size 256k;
     fastcgi_temp_path /dev/shm;

    gzip on;
    gzip_min_length  2048;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_types  text/plain  text/CSS application/xml application/x-javascript ;

    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" $http_x_forwarded_for';



server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

    #rewrite index.php/^(.*)$ idex.php?s=/$1 last ;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
location ~ \.php$
            {
         fastcgi_pass  127.0.0.1:9000;
              fastcgi_index index.php;
             include fastcgi.conf;
            }
}


#################  include  ###################

#    include block_ips.conf ;
#    include vhost/*.conf ;

#强制域名访问对应域名的conf
#    server {
#        listen 80 default ;
#        server_name _;
#        return 404;
#    }
} 

最后phpinfo(),成功

 

 


PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

php

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
2026赚钱平台入口大全
2026赚钱平台入口大全

2026年最新赚钱平台入口汇总,涵盖任务众包、内容创作、电商运营、技能变现等多类正规渠道,助你轻松开启副业增收之路。阅读专题下面的文章了解更多详细内容。

32

2026.01.31

高干文在线阅读网站大全
高干文在线阅读网站大全

汇集热门1v1高干文免费阅读资源,涵盖都市言情、京味大院、军旅高干等经典题材,情节紧凑、人物鲜明。阅读专题下面的文章了解更多详细内容。

24

2026.01.31

无需付费的漫画app大全
无需付费的漫画app大全

想找真正免费又无套路的漫画App?本合集精选多款永久免费、资源丰富、无广告干扰的优质漫画应用,涵盖国漫、日漫、韩漫及经典老番,满足各类阅读需求。阅读专题下面的文章了解更多详细内容。

29

2026.01.31

漫画免费在线观看地址大全
漫画免费在线观看地址大全

想找免费又资源丰富的漫画网站?本合集精选2025-2026年热门平台,涵盖国漫、日漫、韩漫等多类型作品,支持高清流畅阅读与离线缓存。阅读专题下面的文章了解更多详细内容。

6

2026.01.31

漫画防走失登陆入口大全
漫画防走失登陆入口大全

2026最新漫画防走失登录入口合集,汇总多个稳定可用网址,助你畅享高清无广告漫画阅读体验。阅读专题下面的文章了解更多详细内容。

9

2026.01.31

php多线程怎么实现
php多线程怎么实现

PHP本身不支持原生多线程,但可通过扩展如pthreads、Swoole或结合多进程、协程等方式实现并发处理。阅读专题下面的文章了解更多详细内容。

1

2026.01.31

php如何运行环境
php如何运行环境

本合集详细介绍PHP运行环境的搭建与配置方法,涵盖Windows、Linux及Mac系统下的安装步骤、常见问题及解决方案。阅读专题下面的文章了解更多详细内容。

0

2026.01.31

php环境变量如何设置
php环境变量如何设置

本合集详细讲解PHP环境变量的设置方法,涵盖Windows、Linux及常见服务器环境配置技巧,助你快速掌握环境变量的正确配置。阅读专题下面的文章了解更多详细内容。

0

2026.01.31

php图片如何上传
php图片如何上传

本合集涵盖PHP图片上传的核心方法、安全处理及常见问题解决方案,适合初学者与进阶开发者。阅读专题下面的文章了解更多详细内容。

2

2026.01.31

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

相关下载

更多

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Vue 教程
Vue 教程

共42课时 | 7.5万人学习

Django 教程
Django 教程

共28课时 | 3.7万人学习

React 教程
React 教程

共58课时 | 4.4万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号