ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[info] 适用于 CentOS 6.x x64 # 关闭SELinux ~~~ vi /etc/selinux/config SElinux=disabled ~~~ 然后重启 >[danger] 注意:如果不关闭SELinux,可能会导致所有php文件的访问都报404错误 # 添加软件源镜像 ~~~ # CentOS mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo # 包含nginx及其它常用软件 yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo # 包含 php71 yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm # MySQL yum localinstall --nogpgcheck https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm # 安装yum-utils yum install yum-utils #生成缓存 yum makecache ~~~ # * Nginx ~~~ yum install nginx chkconfig nginx on ~~~ >[info] 修改/etc/nginx/nginx.conf 将 user nginx 改为 user apache ~~~ service nginx start ~~~ ### 使能 HTTP2(可选) #### 进入源码编译目录 ~~~ cd /usr/local/src ~~~ ### 安装编译相关依赖 ~~~ yum install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed dpkg-dev libpcrecpp0 libgd2-xpm-dev libgeoip-dev libperl-dev -y ~~~ ### 下载源码包 >[info] 这里最好下载与通过 `yum` 安装的 `nginx` 相同版本源码, `openssl` 则必须高于 `1.0.2` ~~~ wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz tar -xf openssl-1.0.2n.tar.gz wget http://nginx.org/download/nginx-1.10.2.tar.gz tar -xf nginx-1.10.2.tar.gz ~~~ ### 查看编译参数 ~~~ nginx -V ~~~ 复制编译参数,并加上 ~~~ --with-openssl=/usr/local/src/openssl-1.0.2n ~~~ ### 编译 ~~~ ./configure 编译参数 make service nginx stop make install service nginx start ~~~ >[success] 执行install后,原有配置不会丢失 ### 最后 执行 ``nginx -V`` 查看 ``openssl`` 版本 >[info] 可能需要手动在 `/etc/nginx/nginx.conf` 末尾加上 `include /etc/nginx/conf.d/*.conf;` # * MySQL 5.7 ~~~ yum install mysql-community-server chkconfig mysqld on service mysqld start ~~~ ~~~ # 查看默认密码 grep 'temporary password' /var/log/mysqld.log # 修改默认密码 mysqladmin -u root -p password Dd123456@c # 清除记录 history -c ~~~ >[danger] 修改密码回车之后,输入旧密码 # * PHP 7.1 ~~~ yum install php71 ln -s /usr/bin/php71 /usr/bin/php ~~~ ~~~ yum install php71-php-gd php71-php-mbstring php71-php-mcrypt php71-php-mysqlnd php71-php-opcache php71-php-pdo php71-php-pecl-apcu php71-php-pecl-zip php71-php-process php71-php-xml php71-php-pecl-xdebug php71-php-pecl-memcached ~~~ >[info] 配置文件路径: `/etc/opt/remi/php71/` >[info] 日志文件路径: `/var/opt/remi/php71/log/php-fpm/www-error.log` # * PHP-FPM ``` bash yum install php71-php-fpm chkconfig php71-php-fpm on ``` 修改 FPM 配置 ~~~ /etc/opt/remi/php71/php-fpm.d/www.conf ~~~ ``` ini pm.status_path = /status listen = 127.0.0.1:9999 #不要改成9000,与xdebug默认端口冲突 pm.max_requests=500 request_terminate_timeout=600s request_slowlog_timeout = 30 //使能慢日志 ``` ~~~ service php71-php-fpm start ~~~ 安装 php 插件 ~~~ # php71-php-pecl-redis 插件名称 yum install php71-php-pecl-redis ~~~ 重启服务 ~~~ service php71-php-fpm start ~~~ # * Memcached ``` bash yum install memcached chkconfig memcached on ``` 修改配置文件 `/etc/sysconfig/memcached`,只监听本地地址 `OPTIONS="-l 127.0.0.1"` ```bash service memcached start ``` 默认端口为 `11211` # * Composer ```bash php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" mv composer.phar /usr/bin/composer ``` 设置composer国内镜像(**需要切换到非root用户**) ```base # 设置国内镜像 composer config -g repo.packagist composer https://packagist.phpcomposer.com ``` # * 其它修改 ## 启用 apache 用户 > nginx是默认以apache身份运行的,所以网页文件都应该以apache身份上传和创建,否则会出现权限问题 ```bash # 修改apache用户密码 passwd apache mkdir -p /var/www ``` ``` base # apache 用户相关权限 chown apache:apache /var/www chown apache:apache /var/opt/remi/php71/log ``` ## 启用 apache 用户 SSH 登录 修改 `/etc/passwd` ![输入图片说明](https://git.oschina.net/uploads/images/2017/0710/205927_4bdcec1c_354044.png "在这里输入图片标题") ## 开放服务端口 阿里云服务器默认只开放了几个默认端口,所以需要在 ECS 的安全组中添加规则允许80、443等端口的访问 ![输入图片说明](https://git.oschina.net/uploads/images/2017/0710/210354_0e84e00b_354044.png "在这里输入图片标题") # * 其它软件 ``` bash yum install lrzsz yum install unzip ```