CentOS5.5一鍵安裝nginx+mysql+php
#***************************************************************************************
#CentOS 5.5一鍵安裝nginx+mysql+php參考http://blog.s135.com/nginx_php_v6/
#系統為定製安裝,只安裝Editors元件,系統核心升級到2.6.35.7,有兩個地方需要注意下:
#1、安裝patch
#yum install -y patch
#2、設定環境變數
#sed -i “s#PATH=$PATH:$HOME/bin#PATH=$PATH:$HOME/bin:/sbin#” /root/.bash_profile
#***************************************************************************************
#!/bin/bash
# BY kerryhu
# MAIL:king_819@163.com
# BLOG:http://kerry.blog.51cto.com
# Please manual operation yum of before Operation…..
echo “============================更新系統時間===========================================”
yum install -y ntp
ntpdate time.nist.gov
echo “00 01 * * * /usr/sbin/ntpdate time.nist.gov” >> /etc/crontab
echo “============================安裝開源元件===========================================”
sudo -s
LANG=C
yum install -y 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
echo “============================下載安裝包=============================================”
cd /opt
wget http://sysoev.ru/nginx/nginx-0.8.46.tar.gz
wget http://www.php.net/get/php-5.2.14.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.3-m3.tar.gz/from/http://mysql.he.net/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget “http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0“
wget “http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0“
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget “http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0“
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
echo “============================編譯安裝php所需的支援庫=================================”
cd /opt
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –prefix=/usr/local
make
make install
cd ../
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
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
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
cd ../
echo “=============================編譯安裝MySQL 5.5.3-m3=========================”
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql -s /sbin/nologin
tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3/
./configure –prefix=/usr/local/mysql/ –enable-assembler –with-extra-charsets=complex –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=partition,innobase,myisammrg
make;make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
cd ../
mkdir -p /data/mysql/data
mkdir -p /data/mysql/binlog
mkdir -p /data/mysql/relaylog
mkdir -p /data/mysql/mysql
chown -R mysql:mysql /data/mysql
/usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –datadir=/data/mysql/data –user=mysql
cp conf/my.cnf /data/mysql/my.cnf
#設定mysql啟動檔案
cp conf/mysqld /etc/rc.d/init.d/mysqld
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#vi /etc/rc.d/init.d/mysqld
#basedir=
#basedir=/usr/local/mysql
#datadir=
#datadir=/data/mysql/data
chmod 700 /etc/rc.d/init.d/mysqld
/etc/rc.d/init.d/mysqld start
/sbin/chkconfig –add mysqld
/sbin/chkconfig –level 2345 mysqld on
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
#設定root密碼(1q2w3e)
/sbin/mysqladmin -u root password 1q2w3e
#配置庫檔案搜尋路徑
echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
/sbin/ldconfig
#新增/usr/local/mysql/bin到環境變數PATH中
export PATH=$PATH:/usr/local/mysql/bin
#新增mysql管理帳戶
#mysql -h localhost -u root -p1q2w3e
#msqyl> use mysql;
#msqyl> grant all on *.* to `kerry`@`172.16.16.150` identified by `kerry1q2w3e`;
#msqyl> flush privileges;
#msqyl> exit;
echo “==========================編譯安裝PHP(FastCGI模式)===============================”
#編譯安裝php-5.2.14
tar -zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap
make ZEND_EXTRA_LIBS=`-liconv`
make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
#編譯安裝PHP5擴充套件模組
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make
make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
echo “===========================修改php.ini檔案==============================”
sed -i `s#extension_dir = “./”#extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
extension = “memcache.so”
extension = “pdo_mysql.so”
extension = “imagick.so”
#` /usr/local/php/etc/php.ini
sed -i `s#output_buffering = Off#output_buffering = On#` /usr/local/php/etc/php.ini
sed -i “s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g” /usr/local/php/etc/php.ini
sed -i “s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g” /usr/local/php/etc/php.ini
#配置eAccelerator加速PHP
mkdir -p /usr/local/eaccelerator_cache
cat >>/usr/local/php/etc/php.ini<<EOF
[eaccelerator]
zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/usr/local/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=””
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″
EOF
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www -s /sbin/nologin
mkdir -p /data/htdocs/blog
chmod +w /data/htdocs/blog
chown -R www:www /data/htdocs/blog
mkdir -p /data/htdocs/www
chmod +w /data/htdocs/www
chown -R www:www /data/htdocs/www
mv /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf.bak
cp conf/php-fpm.conf /usr/local/php/etc/php-fpm.conf
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm start
echo “================================ 安裝Nginx 0.8.46 =============================”
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make;make install
cd ../
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module
make;make install
cd ../
mkdir -p /data/logs
chmod +w /data/logs
chown -R www:www /data/logs
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf
cp conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf
ulimit -SHn 65535
/usr/local/nginx/sbin/nginx
echo “=============================== 新增php測試頁面 ===============================”
cat >/data/htdocs/www/phpinfo.php<<EOF
<?php
phpinfo();
$link=mysql_connect(`localhost`,`root`,`1q2w3e`);
if(!$link) echo “失敗!”;
else echo “成功!”;
mysql_close();
?>
EOF
echo “=============================== 設定啟動項 =====================================”
echo “ulimit -SHn 65535” >> /etc/rc.local
echo “/usr/local/php/sbin/php-fpm start” >> /etc/rc.local
echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local
cat >>/etc/sysctl.conf<<EOF
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 300
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
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_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
EOF
/sbin/sysctl -p
#測試nginx配置
#/usr/local/nginx/sbin/nginx -t
#平滑重啟
#/usr/local/nginx/sbin/nginx -s reload
echo “======================== LNMP安裝完成 ===============================”
echo “The path of some dirs:”
echo “mysql dir: /usr/local/mysql”
echo “php dir: /usr/local/php”
echo “nginx dir: /usr/local/nginx”
echo “web dir /data/htdocs/www”
echo “======================================================================”
本文轉自king_819 51CTO部落格,原文連結:http://blog.51cto.com/kerry/401213,如需轉載請自行聯絡原作者
相關文章
- Centos6 下安裝Nginx+Mysql+PHPCentOSNginxMySqlPHP
- Centos5.5中安裝Mysql5.5過程分享CentOSMySql
- 一鍵安裝yum-utils安裝包
- Ubuntu中使用sanp一鍵安裝安裝Notepad ++Ubuntu
- vimpython一鍵執行、高亮等一鍵安裝Python
- VScode一鍵安裝外掛VSCode
- 一鍵安裝PHP8.0PHP
- shell指令碼一鍵安裝nginx指令碼Nginx
- SourceInsight漢化版一鍵安裝
- 用StabilityMatrix一鍵安裝Stable Diffusion
- Hadoop一鍵下載安裝包Hadoop
- Oracle bbed一鍵安裝工具分享Oracle
- 一鍵安裝PHP7.xPHP
- 一鍵安裝PHP8.0.mdPHP
- Shell指令碼 | 一鍵解除安裝安卓App指令碼安卓APP
- 如何一鍵安裝win10系統|一鍵安裝win10系統教程步驟Win10
- jdk+tomcat+mysql一鍵安裝配置JDKTomcatMySql
- Docker 一鍵安裝Nacos 單機版Docker
- golang一鍵自動安裝指令碼Golang指令碼
- lnmp 一鍵安裝包部署ThinkPHP5LNMPPHP
- shell指令碼一鍵安裝nginx-1.18.0指令碼Nginx
- centos7 mysql 一鍵安裝指令碼CentOSMySql指令碼
- k3s單機版安裝部署 附一鍵安裝指令碼指令碼
- Linux下使用makeself製作一鍵安裝包Linux
- mysql8.0原始碼一鍵安裝指令碼MySql原始碼指令碼
- 3.5安裝ideay、快捷鍵Idea
- App Cleaner & Uninstaller:智慧清理,一鍵解除安裝 mac版APPMac
- DSS+Linkis Ansible 單機一鍵安裝指令碼指令碼
- 在 Rainbond 中一鍵安裝高可用 Nacos 叢集AI
- 一鍵安裝團隊推薦的 vscode 外掛VSCode
- 一鍵化安裝 docker,一鍵化部署 lnmp+Redis 環境,快速部署 Laravel 環境DockerLNMPRedisLaravel
- 使用中科大映象源一鍵給 ubuntu 安裝 dockerUbuntuDocker
- rsync客戶端一鍵安裝rsync指令碼(原始碼)客戶端指令碼原始碼
- 一鍵接入大模型:One-Api本地安裝配置實操大模型API
- 支援一鍵安裝的LIinux/windows伺服器管理皮膚UXWindows伺服器
- 通過 shell 指令碼完成 GitLab11.9.11 的一鍵安裝指令碼Gitlab
- ChatTTS:Win11本地安裝和一鍵執行包!TTS
- DTM釋出1.8.4 支援零配置啟動,brew一鍵安裝
- pd虛擬機器如何一鍵安裝Win懶人版虛擬機