一、安装前
1.基础软件:
yum -y install apr* compat* libXpm* libjpeg* libpng* ncurses* libtool*
yum -y install autoconf automake gcc gcc-c++ cmake gtk+-devel libcurl-devel zlib-devel openssl openssl-devel pcre pcre-devel gd kernel keyutils patch perl kernel-headers cpp glibc libgomp libstdc++-devel libsepol-devel libselinux-devel krb5-devel freetype-devel fontconfig fontconfig-devel php-gd gettext gettext-devel libxml2 libxml2-devel policycoreutils bison
yum -y install lrzsz curl curl-devel make gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libicu-devel openldap openldap-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
yum -y install gd2 gd-devel gd2-devel numactl openssl openssl-devel libxslt libxslt-devel pcre-devel vim bzip2 openldap openldap-clients openldap-devel openldap-servers
2. 更新系统软件:yum update
二、安装nginx,我这里采用tcp的方式安装nginx,nginx官网介绍了好几种方式运行nginx
1. 安装nginx依赖包
nginx的Rewrite模块和HTTP核心模块会使用到PCRE正则表达式语法:(已在基础软件安装)
yum -y install pcre pcre-devel
nginx的各种模块中需要使用gzip压缩:(已在基础软件安装)
yum -y install zlib zlib-devel
安全套接字层密码库:(已在基础软件安装)
yum -y install openssl openssl-devel
2.下载nginx包并解压(我都习惯把软件安装在/usr/local)
mkdir /root/lnmp
cd /root/lnmp
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
mv nginx-1.8.0 /usr/local
cd /usr/local/nginx-1.8.0
./configure --prefix=/usr/local/nginx
make
make install
(make 和 make install 这两步执行后有些机器会报----make[1]: Leaving directory `/usr/local/nginx-1.8.0',这种错误只要nginx能正常访问就可以不用管)
3. 创建并设置nginx运行账号:
groupadd www
useradd -M -g www -s /sbin/nologin www
cd /usr/local/nginx/conf
vim nginx.conf,设置user参数如下:
user www www;
其他配置参数暂时无需改动。
4.把nginx服务加入开机自启动,详见这篇博客(https://www.cnblogs.com/dyj--php/p/10609604.html)
先要把nginx加入开机自启动,才能使用以下命令启动,停止,重启nginx
开启:service nginx start
重启:service nginx restart
关闭:service nginx stop
5.然后去访问下,云服务器用域名和ip就可以去访问,出现----welcome to nginx代表成功了,到这里nginx安装成功,下面可以看下配置
6.配置nginx请详见这篇博客(https://www.cnblogs.com/dyj--php/p/9298491.html)
7. 防火墙开放80端口(nginx默认使用80端口,可在nginx.conf中配置,若无需进行远程访问则不需要开放端口)
永久开放80端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
(如果出现----FirewallD is not running,详见这篇文章https://www.cnblogs.com/kccdzz/p/8110143.html)
重启防火墙:
firewall-cmd --reload
查看防火墙开启状态:
systemctl status firewalld
查看80端口是否开放成功:
firewall-cmd --zone=public --query-port=80/tcp
8.nginx负载均衡搭建(tcp方式)
三、安装PHP,详见这篇博客(https://www.cnblogs.com/dyj--php/p/9207932.html)
四.php.ini配置(详见这篇博客:https://www.cnblogs.com/dyj--php/p/10614931.html)
五.MySQL安装详见这篇博客(https://www.cnblogs.com/dyj--php/p/9207742.html)