CentOS7 一键安装LNMP环境
来源:互联网 发布:巨人网络 吴萌 编辑:程序博客网 时间:2024/04/28 23:06
说明:此安装属于网络安装,所以首先请保证外网是可以正常访问的。
[root@localhost ~]# ping baidu.comPING baidu.com (123.125.114.144) 56(84) bytes of data.64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=1 ttl=53 time=19.1 ms64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=2 ttl=53 time=18.5 ms64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=3 ttl=53 time=18.6 ms64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=4 ttl=53 time=18.7 ms64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=5 ttl=53 time=18.6 ms64 bytes from 123.125.114.144 (123.125.114.144): icmp_seq=6 ttl=53 time=18.9 ms
- 开始运行如下命令
yum -y install wget screen curl python
yum仓库会更新下,然后下载wget、screen、curl、python
下载完成之后,开始运行
wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
从网络上下载一个压缩包,里面包含一键安装的脚本和安装包,大概275M。
接下来依次解压该文件,进入解压目录,开始执行sh脚本
tar xzf oneinstack-full.tar.gz
cd oneinstack
./install.sh
全部选好了等着安装就好了,是不是so easy~~
大概安装了将近50分钟,看到以下输出信息
####################Congratulations########################Total OneinStack Install Time: -450 minutesNginx install dir: /usr/local/nginxDatabase install dir: /usr/local/mysqlDatabase data dir: /data/mysqlDatabase user: rootDatabase password: 123456PHP install dir: /usr/local/phpPure-FTPd install dir: /usr/local/pureftpdCreate FTP virtual script: ./pureftpd_vhost.shredis install dir: /usr/local/redisindex url: http://192.168.0.222/Please restart the server and see if the services start up fine.Do you want to restart OS ? [y/n]:
最后提示你重启系统,那就重启呗,选择 Y 即可。
重启之后查看相关进程。
[root@localhost ~]# ps -ef|grep phproot 2802 1 0 19:44 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)www 2803 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2804 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2805 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2806 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2807 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2808 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2809 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2810 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2811 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwwww 2812 2802 0 19:44 ? 00:00:00 php-fpm: pool wwwroot 3037 2964 0 19:45 pts/0 00:00:00 grep --color php
[root@localhost ~]# ps -ef|grep mysqlroot 1535 1 0 19:44 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pidmysql 2786 1535 0 19:44 ? 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/data/mysql/mysql.pid --socket=/tmp/mysql.sock --port=3306root 3048 2964 0 19:45 pts/0 00:00:00 grep --color mysql
[root@localhost ~]# ps -ef|grep nginxroot 2957 1 0 19:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confwww 2959 2957 0 19:44 ? 00:00:00 nginx: worker processroot 3060 2964 0 19:46 pts/0 00:00:00 grep --color nginx
进程全部是自动启起来了。那么接下来我们得实践下,这个环境是否能正确运行。
依次运行
[root@localhost ~]# cd /data/wwwroot/[root@localhost wwwroot]# mkdir blog[root@localhost wwwroot]# cd blog/[root@localhost blog]# vi index.php
<?phpecho "hello world!\n";
我们就是在/data/wwwroot下面建了一个blog的目录,然后在blog下面新建了一个index.php的文件,内容输出hello world。
在blog目录运行
php index.php
可以看到输出了 hello world,这就说明php已经安装成功了。
接下来准备配置nginx
cd /usr/local/nginx/confmkdir vhostcd vhosttouch blog.conf
开始编辑 vi blog.conf 内容如下:
server { listen 80; server_name blog.com; root /data/wwwroot/blog; index index.html index.htm index.php; location ~ [^/]\.php(/|$) { #fastcgi_pass remote_php_ip:9000; fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /\.ht { deny all; } }
保存之后 重新加载nginx
[root@localhost vhost]# service nginx reloadReloading nginx configuration (via systemctl): [ OK ]
在nginx里面配置了server_name 为blog.com 所以我们需要配置hosts
echo ‘192.168.0.222 blog.com’ >> /etc/hosts
追加一句进去即可。
然后我们可以通过curl blog.com 就可以访问我们的网站了
[root@localhost ~]# curl blog.comhello world![root@localhost ~]#
成功的输出了 hello world! 说明nginx 和 php 都ok了。
最后就差mysql了,运行 mysql -uroot -p123456
- 注意:-u是用户名 -p是密码 -u后面和-p后面是不加空格的
[root@localhost ~]# mysql -uroot -p123456mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.7.19-log MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)MySQL [(none)]> use mysql;Database changedMySQL [mysql]> show tables;+---------------------------+| Tables_in_mysql |+---------------------------+| columns_priv || db || engine_cost || event || func || general_log || gtid_executed || help_category || help_keyword || help_relation || help_topic || innodb_index_stats || innodb_table_stats || ndb_binlog_index || plugin || proc || procs_priv || proxies_priv || server_cost || servers || slave_master_info || slave_relay_log_info || slave_worker_info || slow_log || tables_priv || time_zone || time_zone_leap_second || time_zone_name || time_zone_transition || time_zone_transition_type || user |+---------------------------+31 rows in set (0.00 sec)MySQL [mysql]>
我们可以看到mysql正常工作的,到这一步我们的LNMP环境就全部搭建完成,并测试成功了。
- CentOS7 一键安装LNMP环境
- CentOS7 LNMP一键安装
- VMware12 Pro 安装centos7.2及一键LNMP环境
- 安装LNMP环境,centos7
- CentOS7安装LNMP环境
- CentOS7安装LNMP环境
- centos7 lnmp 一键安装脚本
- LNMP一键安装环境
- LNMP环境一键安装
- centos7下安装lnmp环境
- CentOS7安装LNMP+Mongodb环境
- ubuntu 一键安装lnmp环境
- Linux环境搭建LNMP一键安装
- centos7下的lnmp环境安装
- Docker CentOS7 LNMP环境yum方式安装
- centOS7手动安装lnmp环境问题总结
- linux centos7 基于LNMP环境安装redis
- centos7安装完成后配置LNMP环境
- Codeforces Round#427(Div.2) C题 二维BIT预处理
- python实现的几种排序算法
- CSDN如何转载别人的文章
- 基于RMQ的LCA
- 1788:Pell数列
- CentOS7 一键安装LNMP环境
- 操作系统库(os)
- Docker 常见命令 --- 简易教程
- 北大方正:从书香到铜臭的退化
- 工作流学习——重要概念扫盲篇一步曲
- 【辨异】—— 可见 vs. 不可见
- Windows GUI自动化测试技术的比较和展望
- Java基础——HSSFworkbook,XSSFworkbook,SXSSFworkbook区别简述
- Ubuntu apt-get upgrade 时候忽略某些安装包