CentOS7下搭建Nginx+MariaDB+php5.4笔记(非自编译)

来源:互联网 发布:最小的linux 编辑:程序博客网 时间:2024/06/07 03:57
一、搭建前准备


1、关闭firewall:
#systemctl stop firewalld #停止firewall
#systemctl disable firewalld #禁止firewall开机启动


2、安装iptables防火墙
#yum install iptables-services #安装
#vi /etc/sysconfig/iptables #编辑防火墙配置文件
增加80,3306等端口
#systemctl restart iptables #最后重启防火墙使配置生效
#systemctl enable iptables #设置防火墙开机启动


3、关闭SELINUX
vi /etc/selinux/config
SELINUX=enforcing #注释掉
SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
#setenforce 0 #使配置立即生效


4、安装所需组件及工具
yum install gcc-c++ pcre-devel zlib-devel (openssl-devel perl-Digest-SHA1.x86_64)可选


二、升级安装MariaDB
#yum install mariadb mariadb-server 
#cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷贝配置文件
#systemctl restart mariadb #重启MariaDB
#systemctl enable mariadb #设置开机启动


#mysql_secure_installation #安全配置向导


三、PHP安装
#yum install php php-fpm php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#vi /etc/php.ini #编辑
#date.timezone = PRC(或者Asia/Shanghai)
#short_open_tag = ON #支持php短标签


#systemctl restart php-fpm #重启php-fpm
#systemctl enable php-fpm #设置开机启动


四、安装nginx
1、下载编译安装
#wget http://nginx.org/download/nginx-1.7.6.tar.gz
#tar zxvf nginx-1.7.6.tar.gz
#cd nginx-1.7.6
#./configure

#make && make install



2、安装后的配置
#echo "export PATH=$PATH:/usr/local/nginx/sbin" >>/etc/profile #添加到全局变量
#source /etc/profile #使配置立即生效

#echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local #添加到启动项



#vi /usr/local/nginx/conf/nginx.conf

把php的FastCGI那块取消注释



#nginx #开启nginx

在你的php网站目录建立个php测试文件

#vi /usr/local/nginx/html/index.php  #我的路径

 


<?phpinfo();?>



然后在地址栏输入http://localhost/index.php



0 0
原创粉丝点击