一、安装mysql
上传mysql的rpm包
tar -zxvf mysql-community-release-el7-5.noarch.rpm 解压
yum -y install mysql-server yum安装mysql
yum -y install mysql-devel yum安装mysql-devel
systemctl restart mysqld 重启mysql服务
mysql -uroot -p 登陆mysql(装好后root用户是没有密码的)
进入mysql库
update user set password=password('storm') where user='root'; 给root用户设置密码
FLUSH PRIVILEGES; 刷新内存
update user set host='%' where host='rnmmp'; 给root用户所有人都可以连接的权限
FLUSH PRIVILEGES;
systemctl stop firewalld.service 关闭防火墙
systemctl disable firewalld.service 永久关闭(关闭后可自行安装iptables)
关闭selinux
vim /etc/sysconfig/selinux
将SELINUX=enforcing改成SELINUX=disabled
setenforce 0 立即生效
二、yum安装nginx
vim /etc/yum.repos.d/nginx.repo
写入
# nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
保存并退出
yum -y install nginx
systemctl restart nginx
在浏览器里访问localhost出现欢迎界面,成功
三、安装php
yum -y install libmcrypt-devel mhash-devel libxslt-devel \
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 \
bison bison-devel mcrypt mhash-devel libcurl-devel readline-devel libedit-devel sqlite-devel \
gcc gcc-c++ glibc epel-release php-bcmath
上传php安装包
tar -jxvf php-5.4.37.tar.bz2
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar 编译安装
make && make install
cp php.ini-production /usr/local/php/etc/php.ini 为php提供配置文件
为php-fpm提供配置文件
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vim etc/php-fpm.conf
修改
user = www
group = www
如果www用户不存在,那么先添加www用户
groupadd www
useradd -g www www
修改
pm.max_children = 150
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pid = /usr/local/php/var/run/php-fpm.pid
/usr/local/php/sbin/php-fpm 启动php-fpm
ps aux | grep php-fpm 查看是否存在php进程
nginx和php-fpm整合
vim /etc/nginx/conf.d/default.conf 编辑nginx配置文件
如下图
修改完成后nginx -s reload
在/usr/local/nginx/html下创建index.php文件,输入如下内容
在浏览器里输入ip/index.php