1.关闭防火墙和SELinux的的
关闭防火墙命令:
[root @ localhost~] #systemctl stop firewalld.service
查询防火墙状态:
[root @ localhost~] #systemctl status firewalld.service
状态为:
[root @ localhost~] #vim / etc / sysconfig / selinux
找到SELINUX =强制执行强制改为禁用
禁用SELinux命令:
[root @ localhost~] #setenforce 0
2.安装nginx
wget下载安装nginx包
[root @ localhost~] #wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
建立nginx的yum仓库
[root @ localhost~] #rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root @ localhost~]
#yum install -y nginx [root @ localhost~] #systemctl start nginx.service
然后在浏览器中输入你服务器的IP如下为nginx的的安装成功:
3.安装MySQL的
下载回购资源
[root @ localhost~] #wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
或者使用另一个地址:wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
安装的MySQL的社区释放,el7-5.noarch.rpm
[root @ localhost~] #rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装mysql&设置用户权限&重启
[root @ localhost~] #yum -y install mysql-community-serve
[root @ localhost~] #sudo chown -R root:root / var / lib / mysql
[root @ localhost~] #systemctl restart mysql.service
登陆MySQL,修改密码(可以先不操作此项,待所有安装完成后自行设置):
[root @ localhost~] #mysql -u root
mysql>使用mysql;
mysql>设置'root'的密码@'localhost'=密码('password');
mysql> flush privilgegs;
检测的MySQL的版本
mysql> status;
mysql> exit;
4.PHP7安装
转安装的PHP相应的荫资源
[root @ localhost~] #rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root @ localhost~] #rpm -Uvh https:// mirror .webtatic.com / grace / EL7 / webtatic-release.rpm
[root @ localhost~] #yum install -y php70w
查看PHP是否安装及版本:
[root @ localhost~] #php -v
安装扩展
[root @ localhost~] #yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64
5.安装php fpm
[root @ localhost~] #yum install -y php70w-fpm
修改配置
**
nginx配置文件修改:可以直接在nginx.conf修改,怕修改坏的,
自己可备份一个nginx的的,的的conf文件命令:
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bk
然后编辑nginx.conf
[root @ localhost~] #vim /etc/nginx/nginx.conf
然后把以下文件粘贴进去,改代码里2个中文的注意点就可以了
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
#gzip on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 32k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6].";
server_names_hash_bucket_size 128;
client_max_body_size 100m;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
server {
listen 80;
server_name www.bzydm.vip(改成自己的域名);
#charset koi8-r;
#access_log logs/host.access.log main;
root "/www/bzydm"(改成自己网站代码的目录);
location / {
index index.html index.htm index.php l.php;
autoindex off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
#include vhosts.conf;
}
然后检查是否该正确
[root @ localhost~] #nginx -t
修改php-fpm配置文件
[root @ localhost~] #vim /etc/php-fpm.d/www.conf
找到修改成这样
user = nginx
group = nginx
测试
在自己设定的root目录下新建一个测试文件(我自己设置的是在/目录下的:/www/bzydm/index.html)
echo'hello“;
启动服务器
[root @ localhost~] #systemctl start nginx.service
查看服务器状态
[root @ localhost~] #systemctl status nginx启动PHP-FPM
[root @ localhost~] #systemctl start php-fpm.service
[root @ localhost~] #systemctl status php-fpm.service在浏览器输入自己的域名就OK了!
成功。