1,准备。
安装 LNMP 之前要安装 EPEL,以便安装源以外的软件,如 Nginx,phpMyAdmin 等
yum install epel-release -y
2,安装 nginx
yum install nginx -y
systemctl start nginx
systemctl enable nginx
3,安装 php
yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel
systemctl start php-fpm
systemctl enable php-fpm
4,安装 mysql
yum -y install mariadb mariadb-server
systemctl enable mariadb
systemctl restart mariadb
初始化数据库:
mysql_secure_installation
Y
123456
123456
Y
Y
Y
Y
EOF
密码是123456
。
然后验证一下:
[root@localhost ~]$mysql -u root -p123456 -e 'show databases'
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
5,添加 nginx 配置
server {
listen 80;
server_name 10.0.40.245;
root /usr/share/nginx/html;
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;
}
location ~ .php$ {
root /usr/share/nginx/html;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重启 nginx 即可
#6,测试 php 是否正常运行
[root@jenkins ~]# cat /usr/share/nginx/html/index.php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
web 访问 index.php
10.0.40.245/index.php
mysql-5.7
php-7.x
#1,安装 nginx。
安装 nginx 最新源
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"
安装 nginx
yum -y install nginx
启动 nginx
yum -y install nginx
设置 nginx 服务器开机自启动
systemctl enable nginx.service
检查开机自动是否设置成功
systemctl list-dependencies | grep nginx
浏览器中输入本机 ip, 检测是否安装成功
http://127.0.0.1
#2,安装 mysql5.7
安装 mysql 源
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
安装 mysql
yum -y install mysql-community-server mysql-community-devel
启动 mysql
service mysqld start
检查 mysql 启动是否正常
service mysqld status 或者 ps -ef | grep mysql
设置 mysqld 服务开机自启动
systemctl enable mysqld.service
检查 mysqld 开机自启动是否设置成功
systemctl list-dependencies | grep mysqld
mysql5.7 以后的争强了安全机制, 所以使用 yum 安装, 启动会系统会自动生成一个随机的密码, 修改 mysql 密码
查看 mysql 的随机密码
grep 'temporary password' /var/log/mysqld.log
版权声明:本文内容来自个人博客:二丫讲梵,遵循CC 4.0 BY-SA版权协议上原文接及本声明。
本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行可。
原文链接:https://wiki.eryajf.net/pages/3133.html
如有涉及到侵权,请联系,将立即予以删除处理。
在此特别鸣谢原作者:二丫讲梵的创作,Powered by 二丫讲梵。
本文已获原作者授权发布。
此篇文章的所有版权归原作者所有,与本公众号无关,商业转载建议请联系原作者,非商业转载请注明出处。