Posted on

centos7下安装lemp栈

1.nginx

sudo yum install epel-release/更新的社区软件包
sudo yum install nginx
sudo systemctl start nginx/运行nginx
sudo systemctl enable nginx/开机启动
sudo yum update

2.mysql

sudo yum install http://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm/加入软件源
sudo yum repolist all | grep mysql/查看默认安装版本
sudo vim /etc/yum.repos.d/mysql-community.repo/修改默认安装版本
sudo yum install mysql-server
sudo systemctl start mysqld
sudo systemctl enable mysqld
sudo mysql_secure_installation
mysql -u root -p

3.php

sudo yum install php php-mysql php-fpm
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sudo sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sudo sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf
sudo vim /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock/修改的行

4.phpmyadmin

sudo yum install phpmyadmin
sudo ln -s /usr/share/phpMyAdmin /usr/share/nginx/html //把phpmyadmin目录链接到公开的web目录

5.nginx server blocks

sudo vim /etc/nginx/conf.d/default.conf

sudo vim /etc/nginx/nginx.conf

example:

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;
    }
}

6.mysql导入导出

导入:

mysql -u root -p

create database 数据库名;

use 数据库名

source /root/数据库名.sql

导出:
mysqldump -u root -p 数据库名 > 文件名.sql
发表评论

电子邮件地址不会被公开。