- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
【centos系列教程之二】Lnmp安装centos6.2
注:本文档所用为centos6.2最小化安装
1.必要的组件
yum -y install gcc gcc-c++ autoconf automake yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
安装Nginx
1,添加一个不能登录且没有主目录的用户:
useradd www -M -s /sbin/nologin wget http://www.landui.com/download/nginx-1.5.0.tar.gz
编译nginx并安装
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module # make && make install ./configure: error: SSL modules require the OpenSSL library.
Centos需要安装openssl-devel
.测试配置文件
/usr/local/nginx/sbin/nginx -t
如果出现以下情况
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.0: or directory
解决方法:
sudo ln -s /usr/local/lib/libpcre.so.0 /usr/lib/libpcre.so.0 /usr/local/nginx/sbin/nginx -t
显示以下信息为正确的
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
5.优化内核参数
vim /etc/sysctl.conf在最后添?
net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.ip_local_port_range = 1024 65535
保存退出后执行
sysctl -p
6.切割Nginx日志脚本
#!/bin/bash PATH_LOGS="/usr/local/nginx/logs" YEAR=`date -d "-1 days" +"%Y"` MONTH=`date -d "-1 days" +"%m"` mkdir -p $PATH_LOGS/$YEAR/$MONTH mv $PATH_LOGS/access.log $PATH_LOGS/$YEAR/$MONTH/access_$(date -d "-1 days" +"%Y%m%d").log kill -USR1 `cat $PATH_LOGS/nginx.pid`
把该脚本加到crontab每天00点执行
注:备机的Nginx和以上安装步骤一样
###################################### PHP #######################################
1,安装必要的组件
yum -y install libjpeg-devel libpng-devel ibmcrypt liwgetbxm l2 libxm l2-devel libcurl-devel freetype freetype-devel
1.1
wget http://www.landui.com/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz tar -zxvf libmcrypt-2.5.8.tar.gz make make install
2.下载PHP
wget http://www.landui.com/get/php-5.5.14.tar.gz/from/a/mirror
3.解压缩
4.编译安装
先执行
export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib
再执行
./configure --prefix=/usr/local/php --with-iconv --with-zlib --enable-xm l --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xm lrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www
3,拷贝和修改php配置文件
# cp php.ini-production /usr/local/php/lib/php.ini 或是/usr/local/lib/php.ini # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf # /usr/local/php/bin/php --ini //测试ini文件是否加载
修改php.ini
[PHP] safe_mode = On register_globals = Off magic_quotes_gpc = Off allow_url_fopen = Off allow_url_include = Off expose_php=Off disable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var [Date] date.timezone = “Asia/Shanghai” 修改php-fpm.conf [global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice emergency_restart_threshold = 0 emergency_restart_interval = 0 [www] pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500
4,添加服务启动脚本
# cp nginx /etc/init.d/nginx # cp php-fpm /etc/init.d/php-fpm # chmod 755 /etc/init.d/nginx # chmod 755 /etc/init.d/php-fpm # chkconfig --add nginx # chkconfig --add php-fpm # chkconfig nginx on # chkconfig php-fpm on
====================================安装MYSQL==========================================
3.1, 创建mysql安装目录
# mkdir -p /usr/local/mysql/
3.2, 创建数据存放目录
# mkdir -p /data/mysql/
3.3, 创建用户和用户组与赋予数据存放目录权限
# useradd mysql -M -s /sbin/nologin # chown mysql.mysql -R /data/mysql/
3.4, 安装必要的组件
# yum -y install cmake # yum -y install ncurses-devel
3.5, 编译安装Mysql
cmake
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
# make && make install
3.6, 初始化数据库
# cd /usr/local/mysql # sc ripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
3.7, 配置环境
# cp support-files/my-medium.cnf /etc/my.cnf # cp support-files/mysql.server /etc/init.d/mysql # chmod 755 /etc/init.d/mysql # chkconfig mysql on # export PATH=/usr/local/mysql/bin:$PATH
3.8, 启动并设置初始密码
# /etc/init.d/mysql start # mysqladmin -uroot password '123123'
进行再修改密码的语句
UPDATE mysql.user SET Password = PASSWord(‘newpwd’) where User = ‘root’;(生新设置密码) flush privileges;(刷新权限)
售前咨询
售后咨询
备案咨询
二维码
TOP