安装epel
yum install epel-release
提示:EPEL,即Extra Packages for Enterprise Linux,企业版linux附加包。这个软件仓库里有很多非常常用的软件,而且是专门针对RHEL设计的,对RHEL标准yum源是一个很好的补充,完全免费使用,由Fedora项目维护,所以如果你使用的是RHEL,或者CentOS,Scientific等RHEL系的linux,可以非常放心的使用EPEL的yum源。
更新yum
yum update
安装Nginx
yum install nginx
systemctl start nginx 启动nginx
systemctl enable nginx 设置开机启动
安装mysql
CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件
cd /usr/local/src/
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-server
systemctl enable mysqld 开机自启动
systemctl start mysqld 启动mysql
grep "password" /var/log/mysqld.log
设置mysql密码
mysql -uroot
mysql> set password for 'root'@'localhost' = password('root');//大小写特殊字符数字
mysql> exit;
安装redis
yum install redis
安装PHP
备用rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -ivh webtatic-release.rpm
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-pecl-redis.x86_64 php70w-mysql.x86_64 php70w-devel.x86_64 php70w-fpm.x86_64
开启php-fpm
systemctl start php-fpm 开启php-fpm
systemctl enable php-fpm 开机自动启动
配置
修改php.ini的配置
vim /etc/php.ini
cgi.fix_pathinfo=0 关闭PHP的pathinfo伪静态功能。
max_execution_time = 0 脚本运行的最长时间,默认30秒
memory_limit = 512M 脚本运行最大消耗的内存,根据你的需求更改数值,默认128M
修改php-fpm的配置
vim /etc/php-fpm.d/www.conf
找到以下两行,解除注释
listen.owner = nobody
listen.group = nobody
找下以下两行,改为nginx
user = nginx
group = nginx
修改nginx的配置
vim /etc/nginx/nginx.conf
location / {
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?s=$1 last;
break;
}
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
调试
PHP-FPM 监听9000 端口正常
netstat -npa | grep 9000
ps -aux | grep php/nginx/mysql/redis
源码编码swoole失败了,果断放弃,但是后来编译swoole异步redis给我坑了
安装swoole
pecl install swoole
源码编译yaf,这里不多说了,我没有用过
安装yaf 下载yaf源码
tar -zxvf taf.tar.gz
phpize
./configure
make
make install
添加扩展到php.ini
echo "extension=swoole.so" >> /etc/php.ini
echo "extension=yaf.so" >> /etc/php.ini
全局composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com 全局国内镜像
composer dump-autoload