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.www58058.com/16723
對實驗很有幫助,再加上原理就更好了
0803+簡單明了,通俗易懂,操作簡單,不錯,點個贊!?。?/p>
080+簡單明了,通俗易懂,解釋很詳細!對我幫助很大!不錯!不錯。
@sky138170:回復在原始博客下是無效評論哦,要評論在《馬哥教育首屆IT技術博客大賽–復審階段》帖子下才有效哦!
0803+簡單明了,通俗易懂,解釋很詳細!對我幫助很大!不錯!不錯
@sky138170:回復在原始博客下是無效評論哦,要評論在《馬哥教育首屆IT技術博客大賽–復審階段》帖子下才有效哦!