centos7安装nginx、php5.5、mysql5.6

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013091013/article/details/86678601

一、nginx

1、安装

yum install nginx

2、启动

systemctl start nginx

关闭:systemctl stop nginx 重启:systemctl restart nginx 检查状态:systemctl status nginx

3、测试

浏览器直接访问http://ip,应该会看到以下界面:

4、支持php

打开/etc/nginx/nginx.conf

server_name  _;
root         /usr/share/nginx/html;

下面加上

index index.php index.html index.htm;

error_page 500 502 503 504 /50x.html;
     location = /50x.html {
}    

下面加上

location ~ .php$ {
        try_files $uri =404;
        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.conf;
        }

二、PHP5.5

1、选择源

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2、安装php5.5

yum -y install php55w php55w-cli php55w-common php55w-gd php55w-ldap php55w-mbstring php55w-mcrypt php55w-mysql php55w-pdo

3、安装php-fpm

yum -y install php55w-fpm
4、编辑php配置文件
​​​​​​​vim /etc/php.ini

将 ;cgi.fix_pathinfo=1 改为 cgi.fix_pathinfo=0

为啥要改这个?看看大神的解释​​​​​​​

5、编辑PHP-FPM配置文件


 user = nobody
 group = nobody   

 改为
 user = nginx
 group = nginx

上面安装nginx会自动生成nginx用户和组,如果没有可以创建

groupadd -r nginx
useradd -r -g nginx nginx

6、启动php-fpm

systemctl start php-fpm

7、重启nginx

systemctl restart nginx

8、设置开机启动

systemctl enable php-fpm

8、测试是否支持php

在/usr/share/nginx/html/目录下创建

vi phpinfo.php

添加以下内容

<?php phpinfo();?>

浏览器访问http://ip/phpinfo.php

三、mysql5.6

1、下载mysqlrepo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 

如果提示没有wget,可以yum install wget

2、安装mysql-community-release-el7-5.noarch.rpm包 

sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm 

3、安装mysql

sudo yum install mysql-server 

4、启动mysql

systemctl start mysqld

5、加入开机启动

systemctl enable mysqld 

6、修改root密码

mysql_secure_installation 

根据提示设置新密码

7、允许远程连接

mysql -uroot -p

登录数据库执行

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;//password改成你自己的密码
FLUSH PRIVILEGES;

8、重启mysql

systemctl restart mysqld

猜你喜欢

转载自blog.csdn.net/u013091013/article/details/86678601