003-CentOS网站搭建(lnmp编译环境搭建)
防火墙
查看防火墙状态
systemctl status firewalld
关闭防火墙
临时关闭防火墙
systemctl stop firewalld
永久关闭防火墙
systemctl disable firewalld
SELinux
查看SELinux状态并临时关闭
getenforce
setenforce 0
永久关闭SELinux
vim /etc/selinux/config
安装Nginx
yum install epel-release
yum update
yum install nginx
查看nginx版本
nginx -v
安装PHP
添加epel源
yum install \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
添加Webtatic源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php
yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb
安装Mysql
安装Mysql
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
配置Nginx
备份Nginx文件
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
修改配置文件
vim /etc/nginx/nginx.conf
在server大括号内,修改或添加下列信息
location / {
index index.php index.html index.htm;
}
location ~ .php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
启动Nginx
systemctl start nginx
设置开机自启
systemctl enable nginx
配置mysql
mysql_secure_installation
FPM
启动FPM
systemctl start php-fpm
设置FPM开机自启
systemctl enable php-fpm
测试环境
进入根目录 /usr/share/nginx/html/ 中写一个测试页面
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/phpinfo.php
到浏览器访问搭建环境系统计算机的 ip 如果出现下图,说明环境安装好了
网站搭建002-CentOS网站搭建(lamp和lnmp环境下的网站搭建)
将网站源码放到/usr/share/nginx/html/目录下,并给予所有权限,访问网站安装