Nginx
MYSQL5.7
PHP7
Nginx latest
- 配置epel yum 源
shell>wget http://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
shell>rpm -ivh epel-release-latest-7.noarch.rpm
- 配置nginx
shell>yum install nginx -y
- 启动nginx
shell>systemctl start nginx
- 设置开机启动
shell>systemctl enable nginx
MYSQL5.7
- 安装mysql源
shell>yum localinstall mysql57-community-release-el7-8.noarch.rpm
- 检查mysql源是否安装成功
shell>yum repolist enabled | grep "mysql.*-community.*"
看到上图所示表示安装成功。
可以修改源vim /etc/yum.repos.d/mysql-community.repo
,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1
改成enabled=0
。然后再将5.6源的enabled=0
改成enabled=1
即可。改完之后的效果如下所示:
- 安装MySQL
shell>yum install mysql-community-server
- 启动MySQL服务
shell>systemctl start mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago Main PID: 2888 (mysqld)
CGroup: /system.slice/mysqld.service
└─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...
6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.- 开机启动
shell>systemctl enable mysqld
shell>systemctl daemon-reload
- 修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell>grep 'temporary password' /var/log/mysqld.log
shell>mysql -uroot -p
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!’;
或者
mysql>set password for 'root'@'localhost'=password('MyNewPass4!');
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误- 添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'%' IDENTIFIED BY 'DBadmin123456!' WITH GRANT OPTION;
mysql>flush privileges;
PHP7
- 安装epel-release
shell>rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- 安装PHP7的rpm源
shell>rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- 安装PHP7
shell>yum install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml
- 配置PHP
shell>vim /etc/php.ini
添加配置date.timezone=PRC expose_php=Off default_charset = "UTF-8"
- 配置PHP-fpm
shell>vim /etc/php-fpm.d/www.conf
- 启动php-fpm
shell>systemctl start php-fpm
Git安装
- 下载编译工具
shell>yum -y groupinstall "Development Tools"
- 下载依赖包
shell>yum -y install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
- 下载 Git 最新版本的源代码
shell>wget https://www.kernel.org/pub/software/scm/git/git-2.18.0.tar.gz
- 解压
shell>tar -zxvf git-2.18.0.tar.gz
- 进入目录配置
shell>cd git-2.18.0
shell>./configure --prefix=/usr/local/git
- 安装
shell>make && make install
- 配置全局路径
shell>export PATH="/usr/local/git/bin:$PATH"
shell>source /etc/profile
shell>PATH=$PATH:/usr/libexec/git-core
- 查看git版本
shell>git --version
PHP扩展
- 安装yaf
shell>wget -c http://pecl.php.net/get/yaf-3.0.7.tgz
shell>tar -zxvf yaf-3.0.7.tgz
shell>cd yaf-3.0.7
shell>phpize
shell>./configure
shell>make && make install
shell>vim /etc/php.ini
添加extension=yaf.so
重启服务
shell>service php-fpm restart
shell>service nginx restart
shell>php -m
(查看安装的扩展)
- 安装phpredis
shell>git clone https://github.com/phpredis/phpredis
shell>cd phpredis
shell>phpize
shell>./configure
shell>make && make install
shell>vim /etc/php.ini
添加extension=redis.so
安装swoole
shell>wget -c https://github.com/swoole/swoole-src/archive/v2.1.3.tar.gz
shell>tar -zxvf v2.1.3.tar.gz
shell>cd v2.1.3.tar
shell>phpize
shell>./configure
shell>make && make install
shell>vim /etc/php.ini
添加extension=swoole.so
安装redis
shell>yum install redis
shell>bind 127.0.0.1 ->bind 0.0.0.0
shell>requirepass ->requirepass xxxx
安装出现进程问题
shell>
rm -f /var/run/yum.pid