centerOS7 配置lnmp环境
centerOS7
关闭防火墙
systemctl stop firewalld
实例开机时,禁止启动防火墙服务。
systemctl disable firewalld
安装Nginx
yum -y install nginx
nginx -v
安装MySQL
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
mysql -V
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
安装PHP7.0版本
yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-
gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64
php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb
php -v
配置Nginx
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
vim /etc/nginx/nginx.conf
sever 里面添加
location / {
index index.php index.html index.htm;
}
#添加下列信息,配置Nginx通过fastcgi方式处理您的PHP请求。
location ~ .php$ {
root /usr/share/nginx/html; #将/usr/share/nginx/html替换为您的网站根目录,本
文使用/usr/share/nginx/html作为网站根目录。
fastcgi_pass 127.0.0.1:9000; #Nginx通过本机的9000端口将PHP请求转发给PHP-FPM进
行处理。
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; #Nginx调用fastcgi接口处理PHP请求。
}
systemctl start nginx
systemctl enable nginx
配置MySQL
grep 'temporary password' /var/log/mysqld.log
获取初始密码 localhost后面
2021-11-10T07:01:26.595215Z 1 [Note] A temporary password is generated for root@localhost:
ARQTRy3+n8*W
*4:KDh/srWpN
mysql_secure_installation
设置完毕密码之后,密码有点麻烦,全部填写Y
配置PHP
vim /usr/share/nginx/html/phpinfo.php
systemctl start php-fpm
systemctl enable php-fpm
ALL DONE!!!!!!OVER
lnmp的环境配置,centeros6