公司新買了個阿里雲專門給小程序用,已經裝了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)