安装yum插件:
sudo yum install yum-plugin-fastestmirror
配置防火墙: sudo systemctl enable firewalld sudo systemctl start firewalld 设置规则: sudo firewall-cmd --set-default-zone=public 编辑开启的服务: vi /etc/firewalld/zones/public.xml 或者 sudo firewall-cmd --permanent --zone=public --add-service=http 如果是开发环境可以禁止ssh登录: sudo firewall-cmd --permanent --zone=public --remove-service=ssh 重载firewalld配置: sudo firewall-cmd --reload 查看当前开通的服务: sudo firewall-cmd --zone=public --list-services 或者端口: sudo firewall-cmd --zone=public --list-ports
关闭SELinux:
sudo vi /etc/sysconfig/selinux
SELINUX=disabled
安装Remi源:
sudo rpm -Uhv http://rpms.famillecollet.com/fedora/remi-release-23.rpm
安装 Nginx + PHP-fpm,可参考 CentOS 7 安装 Nginx + PHP
安装完毕需要修改:
sudo vi /etc/nginx/conf.d/php-fpm.conf
server unix:/var/run/php-fpm/php-fpm.sock;
sudo vi /etc/php-fpm.d/www.conf
listen.mode = 0666
安装Apache + PHP: sudo yum install httpd sudo systemctl enable httpd.service sudo systemctl start httpd.service 测试:http://localhost sudo yum install php php-devel sudo systemctl restart httpd.service sudo vi /var/www/html/info.php 输入: <?php phpinfo(); ?> 测试:http://localhost/info.php
安装MySQL: 默认安装的是MariaDB,需要替换为MySQL的要先去 http://dev.mysql.com/downloads/repo/yum/ 下载安装 repository provides sudo yum install mysql mysql-server sudo systemctl enable mysqld sudo systemctl start mysqld mysql_secure_installation 设置时区: vi /etc/my.cnf 在 [mysqld] 节点添加: default-time_zone = '+8:00' 如果在线安装下载速度太慢,可以去 http://repo.mysql.com/yum/mysql-5.7-community/fc/25/x86_64/ 用下载工具直接下载rpm文件进行安装 下载 mysql-community-server-5.7.16-1.fc25.x86_64.rpm mysql-community-client-5.7.16-1.fc25.x86_64.rpm mysql-community-common-5.7.16-1.fc25.x86_64.rpm mysql-community-libs-5.7.16-1.fc25.x86_64.rpm mysql-community-embedded-5.7.16-1.fc25.x86_64.rpm mysql-community-embedded-compat-5.7.16-1.fc25.x86_64.rpm 安装: yum install mecab-devel mecab-ipadic rpm -Uvh --force --nodeps /home/li/下载/mysql-community-common-5.7.16-1.fc25.x86_64.rpm rpm -Uvh --force --nodeps /home/li/下载/mysql-community-libs-5.7.16-1.fc25.x86_64.rpm rpm -Uvh --force --nodeps /home/li/下载/mysql-community-client-5.7.16-1.fc25.x86_64.rpm rpm -Uvh --force --nodeps /home/li/下载/mysql-community-embedded-5.7.16-1.fc25.x86_64.rpm rpm -Uvh /home/li/下载/mysql-community-embedded-compat-5.7.16-1.fc25.x86_64.rpm rpm -Uvh /home/li/下载/mysql-community-server-5.7.16-1.fc25.x86_64.rpm 如需管理工具,可以安装 yum install mysql-workbench
设置PHP环境:
sudo vi /etc/php.ini
date.timezone = PRC
display_errors = On
安装PHP模块: sudo yum install php-bcmath php-gd libjpeg* php-intl php-ldap php-mysqlnd php-mbstring php-mcrypt php-mhash php-odbc php-pdo php-pear pcre-devel php-pecl-memcache php-pecl-zendopcache php-pecl-xdebug php-soap php-xml php-xmlrpc 修改xdebug参数: sudo vi /etc/php.d/xdebug.ini xdebug.remote_enable=on xdebug.idekey="PHPSTORM" ;xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 ;需要多客户端调试的话请开启remote_connect_back ;xdebug.remote_connect_back=1 ;xdebug.profiler_enable=0 ;xdebug.profiler_output_dir=/tmp/xdebug_profiler ;xdebug.trace_format = 0 ;xdebug.overload_var_dump = 0 注: 如果无法远程调试,请先web方式查看phpinfo检查xdebug设置是否生效, 如已生效,则使用telnet访问phpinfo中的remote ip的9000端口,如果无法访问,则说明有网络问题或者防火墙设置问题 禁用 eval 语句: 到 http://rpmfind.net/linux/rpm2html/search.php?query=php-suhosin 下载安装 RPM 文件 sudo vi /etc/php.d/40-suhosin.ini suhosin.executor.disable_eval = On
sudo systemctl restart httpd
or
sudo systemctl restart php-fpm
sudo systemctl restart nginx
安装Memcache:
sudo yum install memcached
sudo systemctl start memcached
sudo systemctl enable memcached