L A/N MP 安装
添加epel源
yum install epel*
安装所需环境
yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel mysql-devel net-snmp-devel curl-devel perl-DBI
安装LAMP
yum -y install mysql mysql-server httpd ph pphp-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-bcmath php-mbstring
设置启动服务
chkconfig --level 235 mysqld on /etc/init.d/mysqld start chkconfig --level 235 httpd on /etc/init.d/httpd start
设置密码和配置文件
mysqladmin -u root password 123456 /etc/my.cnf #mysql的配置文件 /etc/httpd/conf/httpd.conf #apache的配置文件 Listen 80 ServerName 127.0.0.1:80 DocumentRoot “/var/www/html” DirectoryIndex index.php index.html index.html.var /var/www/html #apache的web存放目录 vi /etc/php.ini #PHP配置文件 memory_limit=128M post_max_size=8M upload_max_filesize=2M
重启httpd服务激活组件
/etc/init.d/httpd restart
测试php是否安装完成
vim /var/www/html/info.php
一条命令安装LAMP
yum -y install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel mysql-devel net-snmp-devel curl-devel perl-DBI mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-bcmath php-mbstring #安装完需要修改配置文件
PHP/Nginx编译安装
安装所需环境文件
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 openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre-devel zlib-devel gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel cp -frp /usr/lib64/libldap* /usr/lib/
安装库文件
tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local make && make install tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure make && make install /sbin/ldconfig cd libltdl ./configure --enable-ltdl-install make && make install tar zxvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/ ./configure make && make install ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config tar -zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make && make install mkdir -p /usr/local/php5.4 tar zxvf php-5.4.13.tar.gz cd php-5.4.13 export LIBS="-lm -ltermcap -lresolv" export DYLD_LIBRARY_PATH="/usr/local/mysql5.5/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64" export LD_LIBRARY_PATH="/usr/local/mysql5.5/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64" ./configure --prefix=/usr/local/php5.4 \ --with-config-file-path=/etc \ --with-iconv-dir=/usr/local/ --with-freetype-dir \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-jpeg-dir --with-png-dir --with-zlib \ --with-mhash --enable-sockets --enable-ftp \ --with-libxml-dir --enable-xml --disable-rpath \ --enable-bcmath \ --enable-shmop --enable-sysvsem \ --enable-inline-optimization --with-curl \ --with-curlwrappers \ --enable-mbregex \ --enable-mbstring --with-mcrypt --with-gd \ --enable-gd-native-ttf --with-openssl --with-mhash \ --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl \ --enable-fpm \ --with-xmlrpc --enable-zip --enable-soap \ --without-pear make ZEND_EXTRA_LIBS='-liconv' make install cp php.ini-production /etc/php.ini
PHP-FPM
cp php-5.4.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cd /usr/local/php5.4/etc mv php-fpm.conf.default php-fpm.conf chmod 755 /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig --level 345 php-fpm on service php-fpm start
编译Nginx
tar zxvf libunwind-0.99-alpha.tar.gz #安装libnwind cd libunwind-0.99-alpha/ CFLAGS=-fPIC ./configure make CFLAGS=-fPIC make CFLAGS=-fPIC install tar zxvf google-perftools-1.8.tar.gz#安装google-perftools cd google-perftools-1.8/ ./configure make && make install echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf ldconfig tar zxvf pcre-8.32.tar.gz cd pcre-8.32/ ./configure --prefix=/usr/local/pcre#安装pcre make && make install tar zxvf nginx-1.0.15.tar.gz cd nginx-1.0.15/ 找到源码目录下的auto/cc/gcc文件,修改如下几行: # debug CFLAGS=”$CFLAGS -g” 删除以上两行 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-cc-opt='-O3' --with-google_perftools_module make && make install 为google-perftools添加线程目录 mkdir /tmp/tcmalloc chmod 0777 /tmp/tcmalloc 修改Nginx主配置文件 #pidlogs/nginx.pid; google_perftools_profiles /tmp/tcmalloc;
Nginx内核参数优化
net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_syncookies = 1 net.core.somaxconn = 262144 net.core.netdev_max_backlog = 262144 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 30 [root@ localhost home]#/sbin/sysctl -p
配置文件优化
worker_processes X;#X=CPU数*核心数 worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;#为每个进程分配CPU以8个CPU为例 worker_rlimit_nofile 65535;#设置打开连接数 use epoll;#使用epoll模型 worker_connections 65535; keepalive_timeout 60; client_header_buffer_size 4k; open_file_cache max=65535 inactive=60s; open_file_cache_valid 80s; open_file_cache_min_uses 1; tcp_nodelay on; tcp_nopush on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on;
原创文章,作者:双庆 李,如若转载,请注明出处:http://www.178linux.com/16723
评论列表(6条)
对实验很有帮助,再加上原理就更好了
0803+简单明了,通俗易懂,操作简单,不错,点个赞!!!
080+简单明了,通俗易懂,解释很详细!对我帮助很大!不错!不错。
@sky138170:回复在原始博客下是无效评论哦,要评论在《马哥教育首届IT技术博客大赛–复审阶段》帖子下才有效哦!
0803+简单明了,通俗易懂,解释很详细!对我帮助很大!不错!不错
@sky138170:回复在原始博客下是无效评论哦,要评论在《马哥教育首届IT技术博客大赛–复审阶段》帖子下才有效哦!