安装配置:
yum install mariadb mariadb-server php php-fpm php-mysql httpd #安装数据库、php、apache yum install gcc gcc-c++ openssl-devel pcre-devel zlib-devel #安装nginx依赖上传源码包到root下:
nginx-1.12.2.tar.gz解压并进入nginx:
# tar zxf nginx-1.12.2.tar.gz # cd nginx-1.12.2编译并安装:
# ./configure && make && make install启动nginx:
# /usr/local/nginx/sbin/nginx查看80端口是否启动成功:
# netstat -lptnu | grep 80启动成功查看网页是否显示nginx: 数据库的操作:
启动mariadb systemctl start mariadb #启动数据库 systemctl enable mariadb #开机自启 创建用户命令 mysql>create user tom@localhost identified by 'tom123'; 直接创建用户并授权的命令 mysql>grant all on *.* to tom@localhost identified by 'tom123'; 授予外网登陆权限 mysql>grant all privileges on *.* to tom@'%' identified by 'tom123'; 授予权限并且可以授权 mysql>grant all privileges on *.* to tom@'hostname' identified by 'tom123' with grant option;编辑nginx配置文件:
# vi /usr/local/nginx/conf/nginx.conf 修改45行:添加index.php location / { root html; index index.php index.html index.htm; } 修改65-71行: location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }添加php文件:
# vi /usr/local/nginx/http/index.php <?php phpinfo(); ?>启动php
# systemctl start php-fpm网页查看: 启动Apache:
# systemctl start httpd.service #启动apache # systemctl enable httpd.service #设置apache开机启动修改nginx配置文件:
# vi /usr/local/nginx/conf.d/default.conf # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # location ~ \.php$ { proxy_pass http://127.0.0.1:8080; } http://localhost #不指定8080端口访问nginx服务器 http://localhost:8080 #指定8080端口访问apache服务器 http://locahost:8080/phpmyadmin #指定8080端口访问apache服务器下的mysql->mariadb