CentOS 7安装 Nginx, MySQL, PHP (LEMP)

官方金沙娱乐赌场网站_赌博娱乐注册送18现金,我和董事会一致认为,陈磊有能力承担完全CEO的责任。,车经过,让他感到很无奈。,让我们在以习近平同志为核心的党中央坚强领导下,锐意改革、砥砺奋进,坚定不移推进全面深化改革,为党和人民事业发展注入强劲动力。

1、安装启动Nginx

sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

2、安装 MySQL (MariaDB)

sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation

设置MySQL密码:

mysql_secure_installation prompts:
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

New password: password
Re-enter new password: password
Password updated successfully!
Reloading privilege tables..
 ... Success!

开始启动MariaDB

sudo systemctl enable mariadb

3、安装php

sudo yum install php php-mysql php-fpm
sudo vi /etc/php.ini
/etc/php.ini excerpt
cgi.fix_pathinfo=0
sudo vi /etc/php-fpm.d/www.conf
/etc/php-php.d/www.conf — 1 of 3
listen = /var/run/php-fpm/php-fpm.sock
/etc/php-php.d/www.conf — 2 of 3
listen.owner = nobody
listen.group = nobody
/etc/php-php.d/www.conf — 3 of 3
user = nginx
group = nginx
sudo systemctl start php-fpm

设置开机启动

sudo systemctl enable php-fpm

4、配置Nginx处理PHP

sudo vi /etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/default.conf — original
server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
/etc/nginx/conf.d/default.conf — updated
server {
    listen       80;
    server_name  server_domain_name_or_IP;

    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

重新启动Nginx

sudo systemctl restart nginx

5、测试

sudo vi /usr/share/nginx/html/info.php
<?php phpinfo(); ?>
http://your_server_IP_address/info.php

发布日期:

所属分类: Apache/Ngnix 标签: