💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
1.如果是阿里云新买的服务器,请确认是否挂载数据盘,参考链接:https://jingyan.baidu.com/article/2c8c281db7e6990009252a10.html?qq-pf-to=pcqq.c2c 2.#依赖库和开发工具 ~~~ yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers ~~~ #Nginx ~~~ yum -y install pcre-devel zlib-devel ~~~ #Php ~~~ yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel ~~~ #Mysql ~~~ yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel ~~~ 一、安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++、gcc、openssl-devel、pcre-devel和zlib-devel 所以执行如下命令安装. ~~~ yum install gcc-c++ yum install pcre pcre-devel yum install zlib zlib-devel yum install openssl openssl--devel ~~~ 二、安装Nginx 安装之前,最好检查一下是否已经安装有nginx ~~~ $ find -name nginx ~~~ 如果系统已经安装了nginx,那么就先卸载 ~~~ $ yum remove nginx ~~~ 首先进入/usr/local/src目录 ~~~ $ cd /usr/local/src ~~~ 从官网下载最新版的nginx ~~~ $ wget http://nginx.org/download/nginx-1.12.0.tar.gz ~~~ 解压nginx压缩包 ~~~ $ tar -zxvf nginx-1.12.0.tar.gz ~~~ 会产生一个nginx-1.12.0 目录,这时进入nginx-1.12.0目录 ~~~ $ cd nginx-1.12.0 ~~~ 创建www组www用户 ~~~ $ /usr/sbin/groupadd www $ /usr/sbin/useradd -g www www ~~~ 1.5 安装cmake编译工具 ~~~ $ yum install cmake -y ~~~ 配置编译Nginx ~~~ ./configure --user=www --group=www --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-pcre --lock-path=/var/run/nginx.lock --pid-path=/var/run/nginx.pid; make && make install ~~~ nginx自启动 1、 创建 vim /etc/init.d/nginx文件 来源:https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit 或:http://blog.csdn.net/u013870094/article/details/52463026 2、修改ngxin文件执行权限 ~~~ $ chmod 775 nginx ~~~ 3、配置chkconfig (增加所指定的系统服务来自: http://man.linuxde.net/chkconfig) ~~~ $ chkconfig --add nginx $ chkconfig --level 35 nginx on ~~~ 4、修改nginx文件夹权限为www:www ~~~ $ chown -R www:www nginx/ ~~~ 5、启动nginx ~~~ $ service nginx start ~~~ 1.1 卸载原有的Mysql 在root用户下操作 找出mysql的相关目录 ~~~ # find / -name mysql cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.18.tar.gz (搜狐源) yum install gcc gcc-c++ ncurses-devel perl /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql tar -zxvf mysql-boost-5.7.18.tar.gz cd mysql-5.7.18 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 \ -DWITH_BOOST=boost -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysql \ -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 \ -DSYSCONFDIR=/etc/ make && make install cd /usr/local/mysql/ chown -R mysql:mysql . cd /usr/local/mysql/ bin/mysqld --initialize --user=mysql --datadir=/data/mysql/ ~~~ 5.7和5.6,5.7的不一样,不能像以前一样cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf了。 *需要进入到/etc/my.cnf 修改datadir=/data/mysql socket=/usr/local/mysql/mysql.sock 注: /data/mysql为前面定义的数据存放目录,/usr/local/mysql/ 是数据安装目录, log-error, pid-file 我暂时没有修改(注意创建并修改日志文件) ![](https://qqadapt.qpic.cn/txdocpic/0/63ea581a07a8dadcbe71c9e130ea499f/0) 修改上面这两个日志路径,并赋予权限 ~~~ Chown -R mysql:mysql /var/log/mysql cd /usr/local/mysql/ cp support-files/mysql.server /etc/init.d/mysqld service mysqld start chkconfig --level 35 mysqld on netstat -tulnp | grep 3306 ln -s /usr/local/mysql/bin/mysql /usr/bin/ mysql --version ~~~ 登录MySQL:mysql -uroot -p (使用安装时显示默认密码登录) 设置密码:SET PASSWORD = PASSWORD('密码'); 如果忘记登录密码: 修改MySQL的登录设置: ~~~ # vi /etc/my.cnf ~~~ 在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi。 重新启动:service mysqld restart Mysql -uroot -p 直接enter两下,进入mysql>控制台 ~~~ update mysql.user set authentication_string=password('TL20171227') where user='root' and Host = 'localhost'; flush privileges; quit; ~~~ 注意:千万要注意mysql的版本,mysql5.4以前密码字段是password 然后,修改MySQL的登录设置: ~~~ # vi /etc/my.cnf ~~~ 在[mysqld]的段中去掉:skip-grant-tables 保存并且退出vi。 重新启动:service mysqld restart 直接进入就好了 安装redis ~~~ yum -y install gcc gcc-c++ wget cd /usr/local/src wget http://source.goyun.org:8000/source/Redis/redis-3.2.9.tar.gz tar -zxvf redis-3.2.9.tar.gz cd redis-3.2.9 make && make install mkdir /usr/local/redis/ && mkdir -p /data/redis/ mkdir /usr/local/redis/bin/ ~~~ 执行安装脚本进行安装: ~~~ cd utils/ ./install_server.sh ~~~ 依次配置如下配置 ( /usr/local/redis/redis.conf redis配置文件 /usr/local/redis/redis.log redis日记文件 /data/redis/ redis数据存放目录 /usr/local/redis/bin/redis-server redis服务启动文件 )![](https://qqadapt.qpic.cn/txdocpic/0/2fb9fbd2fcef7eaf7d1bfd0dd2a24f44/0) 创建redis用户禁止登陆shell ~~~ useradd redis -s /sbin/nologin -M mv /etc/init.d/redis_6379 /etc/init.d/redis vim /etc/init.d/redis ~~~ 修改成( /usr/local/redis/redis.pid sudo -u redis $EXEC $CONF --pidfile $PIDFILE ) ![](https://qqadapt.qpic.cn/txdocpic/0/54be9dcf94e0127ea6090325934f1e30/0) ![](https://qqadapt.qpic.cn/txdocpic/0/03742b0fe33855a398d34e14d6a815f2/0) ~~~ chown -R redis:redis /usr/local/redis/ chown -R redis:redis /data/redis/ chkconfig redis on 开启自启动 ~~~ 安装PHP ~~~ yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel cd /usr/local/src wget http://cn2.php.net/distributions/php-7.1.5.tar.gz tar zxvf php-7.1.5.tar.gz cd php-7.1.5 ######开始配置 [root@typecodes php-7.1.5]# ./configure \ --prefix=/usr/local/php \ --exec-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 \ --with-mysql-sock=/usr/local/mysql/mysql.sock \ --with-mcrypt=/usr/include \ --with-mhash \ --with-openssl \ --with-mysql=shared,mysqlnd \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --enable-redis \ --enable-fpm \ --enable-fastcgi \ --with-fpm-user=www \ --with-fpm-group=www \ --without-gdbm \ --disable-fileinfo make && make install cp /usr/local/src/php-7.1.5/php.ini-production /usr/local/php/etc/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 /usr/local/src/php-7.1.5/sapi/fpm/php-fpm.service /lib/systemd/system/php-fpm.service ~~~ 安装phpredis ~~~ cd /usr/local/src wget https://github.com/phpredis/phpredis/archive/3.1.3RC1.tar.gz -O php-redis.tar.gz tar -zxvf php-redis.tar.gz cd phpredis-3.1.3RC1 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install (/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/记住目录,配置php.ini要用) ~~~ 安装swoole ~~~ cd /usr/local/src wget https://github.com/swoole/swoole-src/archive/v2.0.7.tar.gz tar -zxvf v2.0.7.tar.gz cd swoole-src-2.0.7 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install ~~~ 1.配置php-fpm.conf ~~~ vim /usr/local/php/etc/php-fpm.conf ~~~ ![](https://qqadapt.qpic.cn/txdocpic/0/0e245804dd7d50b618a12574313bd8a8/0) 2.配置www.conf ~~~ vim /usr/local/php/etc/php-fpm.d/www.conf ~~~ ![](https://qqadapt.qpic.cn/txdocpic/0/ed1aead0ade5e1c0a7ebe53f870e4bea/0) 3 .配置php.ini ~~~ vim /usr/local/php/etc/php.ini ~~~ ![](https://qqadapt.qpic.cn/txdocpic/0/d4af781a47d0bf31b8ec9d4fc92e4aa0/0) 创建好相应的目录,并赋予权限 ~~~ mkdir -p /var/log/php/ mkdir -p /var/log/php-fpm/ mkdir -p /run/php-fpm/ mkdir -p /var/lib/php/session chown -R www:www /var/lib/php ~~~ 4.设置php开机自启动 ![](https://qqadapt.qpic.cn/txdocpic/0/aebfd6f9a3663198f8c6f980a17bbb55/0) ![](https://qqadapt.qpic.cn/txdocpic/0/f7e64aca7d44ba1b0918c5431c607cdc/0)