半个月搞定Nginx+PHP+MariaDB+Redis+phpredis+Swoole
Tofloor
poster avatar
xboss1975
deepin
2020-02-25 14:31
Author
本帖最后由 xboss1975 于 2020-2-25 06:55 编辑

Nginx 1.17.8
PHP 7.3.6
MariaDB 10.1.37
Redis 5.9
php 扩展 redis-5.2
Swoole-4.4
环境搭建

有了这些基本上 web开发够用了,而且都是最新版本


Reply Favorite View the author
All Replies
1 / 2
To page
avatar
xboss1975
deepin
2020-02-25 14:34
#1
一 、Nginx 1.17.8

    1、网络下载:wget -O nginx-1.17.8.tar.gz http://nginx.org/download/nginx-1.17.8.tar.gz

    2、解压缩,root 进入 nginx-1.17.8

    3、编译:./configure

    4、安装:make && make install

    5、启动位置:/usr/local/nginx/sbin/ (root)

    6、默认文档:/usr/local/nginx/html/index.html

    6、nginx 配置文件 /usr/local/nginx/conf/nginx.conf
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:37
#2
二、安装php-fpm、pdo

    1、网络下载:wget -O php7.tar.gz https://www.php.net/distributions/php-7.3.6.tar.gz

    2、解压缩,root 进入 php-7.3.6

    3、更新安装依赖包:

    sudo apt-get update
    sudo apt-get -y install  build-essential
    sudo apt-get -y install libssl-dev
    sudo apt-get -y install curl
    sudo apt-get install libcurl4-gnutls-dev
    sudo apt-get -y install libjpeg-dev
    sudo apt-get -y install libpng-dev
    sudo apt-get -y install libmcrypt-dev
    sudo apt-get -y install libreadline6-dev
    sudo apt-get -y install autoconf

    3、编译安装:./configure --prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir  --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl  --enable-ftp --with-gd --enable-gd-jis-conv --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc  --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --without-gdbm

    4、安装:make && make install

    5、启动位置:/usr/local/php/bin

    6、编辑配置文件 /usr/local/php/etc/php-fpm.d/*.conf.default(将原有文件修改名称为*.conf)

    user = www-data
    group = www-data
(此处可略过,因为在./configure 中已经指定用户)


    7、/usr/local/php/etc/php-fpm.conf.default 重命名为  php-fpm.conf

    8、php-fpm 启动目录 /usr/local/php/sbin/php-fpm
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:41
#3
本帖最后由 xboss1975 于 2020-2-25 13:49 编辑

叁 、nginx 运行 php

    1、配置文件  /usr/local/nginx/conf/nginx.conf

    2、修改其中root 和index 设置网站主目录和默认文档

    3、添加内容,*.php 文件交给php处理

       location ~ .php$ {
           root /home/xboss/Desktop/web;
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME /home/xboss/Desktop/web$fastcgi_script_name;
           include fastcgi_params;
       }

     server {

            listen       80;
            server_name  localhost;
            charset     utf-8;  
             ......
其中 /home/xboss/Desktop/web是 nginx的默认目录, xboss是我的用户目录,每个人不同,我的这个是放在了桌面上web目录中
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:42
#4
四、安装 MariaDB 数据库

    1、通过deepin更新安装:sudo apt-get -y install mariadb*
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:43
#5
本帖最后由 xboss1975 于 2020-3-2 16:36 编辑

五、PHP 扩展 swoole

    1、下载页面   http://pecl.php.net/package/swoole

    2、进入 解压缩目录执行   

        /usr/local/php/bin/phpize

        ./configure --with-php-config=/usr/local/php/bin/php-config

        make && make install

    3、将php解压目录中的   php.ini-production 或 php.ini-development 复制到 /usr/local/php/etc/ 目录中,

    4、重命名为 php.ini , 添加 extension=swoole.so
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:44
#6
六、Deepin安装Redis

    1、编译安装最新版本:http://download.redis.io/releases/

        下载后解压,进入目录执行

        make

        make PREFIX=/usr/local/redis install

        cp redis.conf /usr/local/redis/

    2、修改配置文件 /usr/local/redis/redis.conf   daemonize yes,让redis后台运行

    3、启动   /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf

    4、检查Redis服务器系统进程  ps -aux|grep redis

    5、查看redis端口状态    netstat -nlt|grep 6379

    6、停用: /usr/local/redis/bin/redis-cli shutdown
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:45
#7
七、php安装 Redis 扩展

    1、下载:https://codeload.github.com/phpredis/phpredis/tar.gz/5.2.0RC2

    2、加压缩,进入phpredis-5.2.0RC2

    3、生成configure: /usr/local/php/bin/phpize

    4、./configure --with-php-config=/usr/local/php/bin/php-config

    5、make && make install

    6、redis.so 扩展存放在/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/目录下

    7、/usr/local/php/etc/php.ini 文件添加  extension=redis.so
Reply View the author
avatar
xboss1975
deepin
2020-02-25 14:49
#8
最后,因为之前没用 linux过系统,刚接触deepin,所以前前后后搞了半个多月,重做系统10多次,反复验证
Reply View the author
avatar
superendermansm
deepin
2020-02-25 16:22
#9
宝塔好像可以一键php+nginx+mariadb
Reply View the author
avatar
ghostry
deepin
2020-02-25 16:29
#10
不建议用这种方式做环境.

这方式用来学习还行.
Reply View the author
avatar
chijz
deepin
2020-02-25 16:32
#11
辛苦了,感谢分享!!
Reply View the author
avatar
xboss1975
deepin
2020-02-25 21:37
#12
https://bbs.deepin.org/post/189261
不建议用这种方式做环境.

这方式用来学习还行.

都是最新版本的原生态,为什么不建议?
Reply View the author
avatar
陈思煜
deepin
2020-02-25 21:54
#13
用docker就不用重装了
Reply View the author
avatar
ghostry
deepin
2020-02-25 23:02
#14
https://bbs.deepin.org/post/189261
都是最新版本的原生态,为什么不建议?

因为都是源***编译,自定义环境.

在生产环境应该使用通用环境.这样在遇到问题的时候,才能到网上找到解决方案.

自定义环境,没有别人的经验可以参考.摸着石头过河.

解决问题变的困难.
Reply View the author
avatar
xboss1975
deepin
2020-02-26 00:40
#15
本帖最后由 xboss1975 于 2020-2-25 17:07 编辑
https://bbs.deepin.org/post/189261
因为都是源***编译,自定义环境.

在生产环境应该使用通用环境.这样在遇到问题的时候,才能到网上找到解决 ...

我倒觉得你所说的通用环境就是集成过的,才会出千奇百怪问题,而且大部分都不是最新版本,系统性能和优化升级的后期工作也不少
而这种原生态的编译安装才是最根本的,涉及到的问题都是有迹可循,解决问题也是都有标准的官方文档作参考,这些都是最直接有效,也是最根本的
其实在win下面也有类似的问题,比如是用原版官方IOS安装还是Ghost版?Ghost版同样给你集成了很多常用软件和环境,但是都不是最新版本,后期一样要去卸载旧版,安装新版,更何况win 的Ghost水太深,垃圾、漏洞一大堆。所以我都是下载原版iso,然后自己找破解方案


Reply View the author
avatar
a2035274
deepin
2020-02-27 20:38
#16
量力而为 我就比较害怕直接编译安装 都是用docker   因为我想用来做web开发 而不是运维  直接编译有的时候会弄乱我的依赖   再用商店安装软件的时候容易出问题  而且以前在站内好像看过一个 deepin 官方人员也是推荐docker  还专门出了一个教程   所以我也认为docker比较好
Reply View the author
avatar
181******81
deepin
2020-02-28 18:35
#17
我用docker  宝塔 等,纯粹是因为懒。O(∩_∩)O哈哈~
Reply View the author
avatar
xboss1975
deepin
2020-02-28 19:01
#18
https://bbs.deepin.org/post/189261
我用docker  宝塔 等,纯粹是因为懒。O(∩_∩)O哈哈~

懒,就要付出被阉割的代价
其实专门用一段时间来搞这个环境,之后安装包、操作过程、shell脚本都做一下备份,最后很快就搞定,我现在重新搞一下也就半个多小时,只有那个php 7.3.6 编译过程时间长点,还是终端在跑绿码,我就是看着

这个过程,比在win10下面安装 SQL server 都要快
Reply View the author
avatar
BG7ZAG
deepin
2020-02-28 19:10
#19
用宝塔方便
Reply View the author
avatar
181******81
deepin
2020-02-28 19:27
#20
https://bbs.deepin.org/post/189261
懒,就要付出被阉割的代价
其实专门用一段时间来搞这个环境,之后安装包、操作过程、shell脚本都做一下备 ...

我以前也是真么想的,这个过程真的能搞懂很多东西的。O(∩_∩)O哈哈~  加油!!!
我现在能满足需求的前提下,怎么容易怎么快怎么方便维护怎么来。
Reply View the author
1 / 2
To page