一、准备工作
1、检查selinux是否为关闭状态,不为disable需要改为disable。
SELINUX=disabled
不为disabled 的话,则修改为 SELINUX=disabled。
2、检查环境下有没有安装过低版本的
rpm -qa|grep mysql
mysql-libs-5.1.73-8.el6_8.x86_64
rpm -qa|grep nginx
rpm -qa|grep php
从上可获知Linux下yum过一个 mysql-libs-5.1.73-8.el6_8.x86_64,等下安装MySQL5.6版本的时候,先做卸载就可以。
3、可以查看有没有mysql nginx php等相关的命令 ,有可能是源码安装过的,若有也需要卸载掉。
whereis nginx
whereis php
whereis mysql
4、关闭防火墙
刚刚新安装的系统默认的是关闭iptables的
二、安装nginx
centos 6.9默认的是nginx1.10版本,想安装nginx更高的版本可以下载nginx官网yum源进行安装,这里省略自己查看其它版本安装的参考吧。
1、删除系统自带的软件包
yum remove httpd php
2、安装nginx
yum install -y nginx
3、设置nginx开机启动
chkconfig nginx on
4、启动nginx
service nginx start
输入命令 nginx -t,这是一个判断nginx配置文件格式是否正确的命令,可以用来查找nginx配置文件的路径;
[root@Server-55e30ab1-b924-43b7-94e4-4a7c59208282 html]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
但是这里出现的配置文件是主配置文件,注意配置文件是否有扩展
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36[root@Server-55e30ab1-b924-43b7-94e4-4a7c59208282 html]# cat /etc/nginx/nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf;###这里就出现了扩展,其他参数去扩展配置文件配置!! }
三、安装MySQL5.6
1、检查MySQL是否有相关包
whereis mysql
mysql: /usr/lib64/mysql /usr/share/mysql
rpm -qa|grep mysql
mysql-libs-5.1.73-8.el6_8.x86_64
卸载mysql-libs-5.1.73-8.el6_8.x86_64
yum remove mysql-libs
2、清空dbcache
yum clean dbcache
3、下载MySQL rpm安装包
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4、 安装MySQL安装源
使用rpm -ivh mysql-community-release-el6-5.noarch.rpm安装下载的rpm文件~
rpm -ivh mysql-community-release-el6-5.noarch.rpm
5、安装mysql-community-server
使用yum install mysql-community-server安装MySQL server。
yum install mysql-community-server
6、启动MySQL服务
service mysqld start
7、修改mysql密码
修改密码~
使用update user set password=PASSWORD("YOUR_PASSWORD") where user='root';修改root账号密码~
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=PASSWORD("YOUR_PASSWORD") where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
密码验证
重新登录mysql服务
至此,MySQL安装完毕~
四、安装PHP5.6
检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们, 如:
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64
配置安装包源:,根据具体Linux系统版本安装源。
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 php
rpm -e [上面搜索到的包即可]
执行安装
yum -y install php56w.x86_64
yum -y --enablerepo=webtatic install php56w-devel
yum -y install 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
五、配置
[root@localhost nginx]# cp /etc/nginx/conf.d/default.conf{,.bak}
1、修改配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61[root@Server- ~]# cat /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } #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 /usr/share/nginx/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$ { 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; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} }
2、配置php
vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
3、重启nginx php-fpm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[root@localhost nginx]# service nginx restart Stopping nginx: [ OK ] Starting nginx: [ OK ] [root@localhost nginx]# service php-fpm restart Stopping php-fpm: [ OK ] Starting php-fpm:
4、测试
1
2
3
4
5
6
7
8[root@localhost ~]# cd /usr/share/nginx/html/ [root@localhost html]# vim index.php <?php phpinfo(); ?> [root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R #设置目录所有者
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
安装过程可能会碰到一些问题,记录在另外一篇博客
https://blog.csdn.net/weixin_40283570/article/details/81477390
备注
1
2
3
4
5
6nginx默认站点目录是:/usr/share/nginx/html/ 权限设置:chown nginx.nginx/usr/share/nginx/html/ -R MySQL数据库目录是:/var/lib/mysql 权限设置:chown mysql.mysql -R /var/lib/mysql nginx 配置文件 :/etc/nginx/conf.d/default.conf php-fpm 配置文件 :/etc/php-fpm.d/www.conf
最后
以上就是个性大山最近收集整理的关于Centos6.9下 yum 安装 nginx1.10 + mysql5.6 + php5.6一、准备工作二、安装nginx三、安装MySQL5.6四、安装PHP5.6五、配置的全部内容,更多相关Centos6.9下内容请搜索靠谱客的其他文章。
发表评论 取消回复