编辑iptables,开启端口
cd /etc/sysconfig
vim iptables
加入
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
/etc/init.d/iptables restart
vim /etc/selinux/config
备注原来的信息,修改选项 SELINUX=disabled
wq保存退出
重启系统
shutdown -r now
#安装下载工具
yum install wget
#下载
wget http://www.atomicorp.com/installers/atomic
#安装
sh ./atomic
#更新yum源
yum check-update
删除wget的内容
rm -rf RPM-GPG-KEY.atomicorp.txt
rm -rf RPM-GPG-KEY.art.txt
rm atomic
#删除系统自带的软件包
yum remove httpd* php*
#查看可安装的nginx
yum list nginx*
#安装nginx
yum install -y nginx
#设置nginx开机启动
chkconfig nginx on
#启动nginx
service nginx start
查看nginx安装情况
yum list installed | grep nginx
检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们, 如:
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64
配置安装包源:
# Centos 5.X
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
# CentOs 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
# CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
如果想删除上面安装的包,重新安装
rpm -qa | grep webstatic
rpm -e [上面搜索到的包即可]
执行安装
yum -y install php56w.x86_64
yum -y --enablerepo=webtatic install php56w-devel
yum -y install php56w-xml.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64
安装PHP FPM
yum -y install php56w-fpm
#设置php-fpm开机启动
chkconfig php-fpm on
#启动php-fpm
/etc/init.d/php-fpm start
注:如果想更换到php5.5或5.4版本, 直接把上面的56w换成55w或者54w就可以了
yum install -y mysql mysql-server
#启动MySQL
/etc/init.d/mysqld start
#设为开机启动
chkconfig mysqld on
#拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
mysql_secure_installation
# 回车,根据提示输入Y,输入2次密码,回车,根据提示一路输入Y,最后出现:Thanks for using MySQL!
# MySql密码设置完成,重新启动 MySQL:
#重启
/etc/init.d/mysqld restart
#停止
/etc/init.d/mysqld stop
#启动
/etc/init.d/mysqld start
rm -rf /etc/nginx/conf.d/*
vi /etc/nginx/conf.d/default.conf
添加如下内容
添加如下内容 :
server{
listen 80;
server_name _;
index index.php index.html index.htm;
root /var/www;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
说明: /var/www 为web根目录, location / ... 为url的rewrite,隐藏 index.php
vi /etc/php-fpm.d/www.conf
将用户和用户组设置为nginx, 默认为 Apache, 如:
#修改用户为nginx
user = nginx
#修改组为nginx
group = nginx
启动命令:
# nginx 重启 | 启动 | 停止
service nginx restart | start | stop
# php-fpm 重启 | 启动 | 停止
service php-fpm restart | start | stop
# mysql 重启 | 启动 | 停止
service mysqld restart | start | stop
一些文件的目录:
# nginx.conf
/etc/nginx/nginx.conf
# php.ini
/etc/php.ini
# my.cnf
/etc/my.cnf
# 项目根目录
/var/www
出现 “/etc/nginx/fastcgi.conf” failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf:12
解决办法:
将上述1.配置nginx里配置修改
vi /etc/nginx/conf.d/default.conf
将
include fastcgi.conf
改为
include fastcgi_param.conf;
vi /var/www/index.php
添加以下代码
:wq! 保存退出
#设置权限
chown nginx.nginx /var/www -R
#重启nginx
service nginx restart
#重启php-fpm
service php-fpm restart
在客户端浏览器IP地址(如: 127.0.0.1),配置信息!说明配置成功!
至此。已完成所有配置!!!!
温馨提示:
若在本地环境,或者在vm虚拟机下,是不会出现信息的
需要进一步配置本地的hosts
vim /etc/hosts
加入你的网站
假设你设置的 /etc/nginx/conf.d/default.conf中
server_name www.aabbccdd.com
本文转自 :https://www.cnblogs.com/lucky-man/p/7093057.html