公司新买了个阿里云专门给小程序用,已经装了centOS,我再装下环境,记录下。 时间 2018年5月3日php
我获得了ip 用户名和密码 putty登录 看了下 40G+2G centOS6.3 nginx之类的没有装html
wget http://www.atomicorp.com/installers/atomic #下载
sh ./atomic #安装
yum check-update #更新yum源
复制代码
yum -y install wget
复制代码
改下权限node
chmod 777 atomic
复制代码
3和4被吃了 因此直接5mysql
yum remove httpd* php* #删除系统自带的软件包
yum install nginx #安装nginx 根据提示输入y进行安装
chkconfig nginx on #设置nginx开机启动
service nginx start #启动nginx
复制代码
# yum install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic: mirrors.neusoft.edu.cn
* base: mirrors.aliyuncs.com
* epel: mirrors.aliyuncs.com
* extras: mirrors.aliyuncs.com
* updates: mirrors.aliyuncs.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.13.12-4308.el6.art will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
nginx x86_64 1.13.12-4308.el6.art atomic 956 k
Transaction Summary
========================================================================================================
Install 1 Package(s)
Total download size: 956 k
Installed size: 2.6 M
Is this ok [y/N]: yes
Downloading Packages:
nginx-1.13.12-4308.el6.art.x86_64.rpm | 956 kB 00:00
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA256 Signature, key ID 4520afa9: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
Importing GPG key 0x5EBD2744:
Userid : Atomic Rocket Turtle <admin@atomicrocketturtle.com>
Package: atomic-release-1.0-21.el6.art.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
Is this ok [y/N]: yes
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
Importing GPG key 0x4520AFA9:
Userid : Atomicorp (Atomicorp Official Signing Key) <support@atomicorp.com>
Package: atomic-release-1.0-21.el6.art.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : nginx-1.13.12-4308.el6.art.x86_64 1/1
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
Verifying : nginx-1.13.12-4308.el6.art.x86_64 1/1
Installed:
nginx.x86_64 0:1.13.12-4308.el6.art
Complete!
复制代码
若是发现端口占用,通常有两种常见状况 1.是nginx的ipv6 bug, 2.是其余程序端口占用 我此次遇到的是httpd占用 ipv6的状况见下文 8.1nginx
# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1415/httpd
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1422/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1017/sshd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1389/mysqld
tcp 0 0 :::22 :::* LISTEN 1017/sshd
# kill 1415
# service nginx start
Starting nginx: [ OK ]
复制代码
此时浏览器中查看你的网站 应该能看到nginx的欢迎界面sql
yum install mysql mysql-server #输入Y便可自动安装,直到安装完成
/etc/init.d/mysqld start #启动MySQL
chkconfig mysqld on #设为开机启动
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷贝配置文件(注意:若是/etc目录下面默认有一个my.cnf,直接覆盖便可)
为root帐户设置密码
mysql_secure_installation 回车,根据提示输入,输入2次密码,回车,根据提示一路输入Y,最后出现:Thanks for using MySQL!
MySql密码设置完成,从新启动 MySQL:
/etc/init.d/mysqld restart #重启
/etc/init.d/mysqld stop #中止
/etc/init.d/mysqld start #启动
复制代码
而后我遇到了一些问题,由于这个服务器上装过mysql 我删了重装, 启动失败了,查了资料参照这个解决了 Linux下从新安装MySql后出现'MySQL Daemon failed to start‘解决方法shell
yum install php php-fpm #根据提示输入Y直到安装完成
安装PHP组件,使PHP5支持MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #这里选择以上安装包进行安装,根据提示输入Y回车
chkconfig php-fpm on #设置php-fpm开机启动
/etc/init.d/php-fpm start #启动php-fpm
复制代码
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak #备份原有配置文件
vi /etc/nginx/nginx.conf #编辑
user nginx nginx; #修改nginx运行帐号为:nginx组的nginx用户
:wq #保存退出
复制代码
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #备份原有配置文件
vi /etc/nginx/conf.d/default.conf #编辑
index index.php index.html index.htm; #增长index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改成$document_root$fastcgi_script_name,或者使用绝对路径
service nginx restart #重启nginx
复制代码
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) 解决办法:apache
vim /etc/nginx/conf.d/default.conf
复制代码
将小程序
listen 80 default_server;
listen [::]:80 default_server;
复制代码
改成:vim
listen 80;
#listen [::]:80 default_server;
复制代码
从新启动nginx便可
vi /etc/php.ini #编辑
date.timezone = PRC #把前面的分号去掉,改成date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 列出PHP能够禁用的函数,若是某些程序须要用到这个函数,能够删除,取消禁用。
expose_php = Off #禁止显示php版本的信息
short_open_tag = ON #支持php短标签
open_basedir = 网站根目录:/tmp/
#设置表示容许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录;冒号为分隔符。
:wq! #保存退出
复制代码
open_basedir配置选项中有些教程会配置为open_basedir=.:/tmp/,其中’.’表明当前目录。这种方式在nginx+phpfastcgi下好像行不通。
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak #备份原有配置文件
vi /etc/php-fpm.d/www.conf #编辑
user = nginx #修改用户为nginx
group = nginx #修改组为nginx
:wq #保存退出
复制代码
cd /usr/share/nginx/html
vi index.php #添加如下代码
<?php
phpinfo();
?>
:wq! #保存退出
复制代码
chown nginx.nginx /usr/share/nginx/html -R #设置权限
service nginx restart #重启nginx
service php-fpm restart #重启php-fpm
复制代码
在客户端浏览器输入服务器IP地址,能够看到相关的配置信息!说明lnmp配置成功!
至此,CnetOS 安装配置LNMP(Nginx+PHP+MySQL)完成。 ####11.查看版本 查看centos版本
more /etc/issue;
CentOS release 6.8 (Final)
复制代码
查看nginx版本
nginx -v
nginx version: nginx/1.6.2
复制代码
查看mysql版本
mysql -uroot -p
而后输入 password
status;
mysql Ver 14.14 Distrib 5.5.55, for Linux (x86_64) using readline 5.1
复制代码
查看php版本
php -v
PHP 5.4.45 (cli) (built: Aug 23 2016 14:41:13)
复制代码
item | 信息 |
---|---|
VPS | 网站网址 用户名密码 |
VPS上面的实例 | IP地址 centos的root密码 CentOS release 6.3 (Final) |
mysql | mysqlroot密码 |
参考 CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) Getting Started with Linode CentOS下查看apache,php,mysql版本信息 nginx服务器安装及配置文件详解
Linux下从新安装MySql后出现'MySQL Daemon failed to start‘解决方法 LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL)