lnmp软件版本:nginx1.19+php5.3.8+mysql5.5.19
x64 centos系统分区采用日志:centos6.2系统分区总结中的”服务器版本第2套方案”
一、安装前基本设置规划
#软件安装包存储: /usr/local/src #基本安装目录列表: /usr/local/mysql /usr/local/php /usr/local/nginx 命令:mkdir /usr/local/mysql;mkdir /usr/local/php;mkdir /usr/local/nginx 一次创建所需目录 mkdir /usr/local/{mysql,php,nginx} 为方便查找目录,设置变量 # vi .bashrc alias worksrc='cd /usr/local/src' alias workmysql='cd /usr/local/mysql' alias workphp='cd /usr/local/php' alias worknginx='cd /usr/local/nginx' #nginx启动 alias sernginx='service nginxd' #mysql启动 alias sermysql='service mysqld' #php-fpm启动 alias serfpm='service php-fpmd' 配置生效 # source .bashrc
加入开机启动
# vim /etc/rc.d/rc.local #nginx启动 service nginxd start #mysql启动 service mysqld start #php-fpm启动 service php-fpmd start
二、获取相关开源程序
- a.通过centos光盘安装(以光盘作为yum源)
#1.为DVD创建一个挂载目录(注意:CentOS 大小写与下面的要一致) mkdir /media/CentOS/ #在Linux下挂载CentOSDVD mount /dev/cdrom /media/CentOS/ #2.查看相关配置文件,目录为 # ls -l /etc/yum.repos.d/ total 20 -rw-r--r-- 1 root root 1926 Feb 25 16:20 CentOS-Base.repo -rw-r--r-- 1 root root 631 Feb 25 16:20 CentOS-Debuginfo.repo -rw-r--r-- 1 root root 626 Feb 25 16:20 CentOS-Media.repo -rw-r--r-- 1 root root 6118 Feb 25 16:20 CentOS-Vault.rep #3.禁用yum的网络更新方式,简单地将默认首选的CentOS-Base.repo改名为CentOS-Base.repo.bak即可 # mv CentOS-Base.repo CentOS-Base.repo.bak #4.配置本地yum源 [root@localhost~]# vim /etc/yum.repos.d/CentOS-Media.repo 将 [c5-media] name=5-media baseurl=file:///media/CentOS/ file:///media/cdrom/ file:///media/cdrecorder/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #修改为 [c5-media] name=CentOS-$releasever- Media baseurl=file:///media/CentOS/ gpgcheck=1 enabled=1 #其中baseurl修改为DVD的挂载目录,enabled=1开启本地更新模式 #:wq保存退出 #下面的--enablerepo=5-media 要和上面保持一致 yum -y --disablerepo=* --enablerepo=5-media install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison
- b.通过mirrors.163.com安装(以mirrors.163.com为yum源)
#1.备份原始源,下载163源作为原始源 mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backup wget http://mirrors.163.com/.help/centos5-base-163.repo yum makecache #安装常用软件 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison