摘要:部署架設環境網卡綁定多個內網和外網下其實這部不用操作默認就是原來的內網配置原配置中的地址原配置的內網地址原配置原配置原配置添加規則內網
uclund 部署架設環境
cp /etc/resolv.conf /etc/resolv.conf.bak
yum update -y
yum -y install gcc gcc-c++ autoconf cmake libjpeg libg libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-deves-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-idn-devel openssl openssl-devel openldap openldap-devel nss_ldclients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN ncurses-devel bison bison-devel bzip2-devel libxslt-devel zip unzip
reboot
//網卡綁定多個內網和外網 ucloud.cn下
cd /etc/sysconfig/network-scripts cp ifcfg-eth0 ifcfg-eth0:1 vim ifcfg-eth0DEVICE=eth0 IPADDR=$Publick_IP NETMASK=255.255.255.255 BOOTPROTO=none PEERDNS=yes USERCTL=no NM_CONTROLLED=no ONBOOT=yesvim ifcfg-eth0:1 其實這部不用操作 默認就是原來的內網配置
DEVICE=eth0:1 HWADDR=原配置中的mac地址 IPADDR=原配置的內網ip地址 NETMASK=255.255.0.0 BOOTPROTO=none PEERDNS=yes USERCTL=no NM_CONTROLLED=no ONBOOT=yes DNS1=原配置 DNS2=原配置 DNS3=原配置vim route-eth0
10.0.0.0/8 via 10.9.0.1
default via 10.9.0.1 src $Public_IP
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
添加iptables規則:
iptables -t nat -A PREROUTING ! -s 10.0.0.0/8 -d 內網ip/32 -j DNAT --to-destination $Publick_IP iptables -t nat -A POSTROUTING -s 外網ip/32 -j SNAT --to-source 內網ipumount /dev/vdb
fdisk -l
fdisk /dev/vdb
n
p
1
[enter]
[enter]
w
vim /etc/fstab
mkdir /web
mkfs.ext3 /dev/vdb1
vim /etc/fstab
/dev/vdb1 /web ext3 defaults 0 0
mount -a
安裝mysql-5.6.26
創建mysql用戶和組
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
mkdir -p /web/mysql/data
mkdir -p /web/mysql/logs
mkdir -p /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /web/mysql
編譯安裝mysql
tar zxvf mysql-5.6.26.tar.gz
cd mysql-5.6.26
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/web/mysql/data
-DSYSCONFDIR=/etc
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_TCP_PORT=3306
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_READLINE=1-DWITH_SSL=system
-DWITH_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_DEBUG=0
make && make install
============可能遇到的編譯錯誤===========
出現函數gets錯誤的
解決辦法:
rm -f CMakeCache.txt
修改配置文件
cp?./support-files/my-medium.cnf?/etc/my.cnf
vi?/etc/my.cnf
[mysqld]
datadir=/web/mysql/data
socket=/tmp/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/web/mysql/logs/mysqld.log
pid-file=/web/mysql/mysqld.pid
user=mysql
tmpdir=/tmp
or
cp /web/lanmp/my.cnf /etc/my.cnf
初始化數據庫
/usr/local/mysql/scripts/mysql_install_db
--user=mysql
--basedir=/usr/local/mysql
--datadir=/web/mysql/data
配置開機自啟動
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
添加MySQL的軟鏈接以適應init腳本
ln -sv /usr/local/mysql/bin/mysql /usr/sbin/mysql
ln -sv /usr/local/mysql/bin/mysqladmin /usr/sbin/mysqladmin
ln -sv /usr/local/mysql/bin/mysqldump /usr/sbin/mysqldump
啟動mysql
service mysqld start??#?或?/etc/init.d/mysqld?start
修改root密碼:
mysqladmin -uroot password "新密碼"
mysql -uroot -p
輸入新密碼
create user "duigou"@"%" identified by "密碼"
create user "duigou"@"localhost" identified by "密碼"
create database duigou default character set utf8mb4 collate utf8mb4_general_ci;
grant all privileges on duigou.* to "duigou"@"%" identified by "密碼";
grant all privileges on duigou.* to "duigou"@"localhost" identified by "密碼";
======================================================================================
或者重新配置一個超級管理員并刪除root
GRANT?ALL?PRIVILEGES?ON?.?TO?"admin"@"localhost"?IDENTIFIED?BY?"12345678";
GRANT?ALL?PRIVILEGES?ON?.?TO?"admin"@"127.0.0.1"?IDENTIFIED?BY?"12345678";
第三步:安裝nginx-1.8.0
添加www用戶和組、創建網站虛擬目錄
groupadd www
useradd -g www -s /usr/sbin/nologin www
mkdir -p /web/htdocs/www
chmod +w /web/htdocs/www
chown -R www:www /web/htdocs/www
mkdir -p /web/htdocs/logs
chmod +w /web/htdocs/logs
chown -R www:www /web/htdocs/logs
安裝Nginx所需的pcre庫
tar zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make && make install
ln -s /usr/local/lib/libpcre.so.1 /usr/lib64/libpcre.so.1
cd ..
安裝nginx-1.8.0
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure
--user=www
--group=www
--prefix=/usr/local/nginx
--with-http_stub_status_module
--with-http_ssl_module
--with-http_realip_module
--with-http_image_filter_module
make && make install
創建Nginx配置文件和創建fcgi.conf文件
cp -f /web/lanmp/nginx.conf.uclound /usr/local/nginx/conf/nginx.conf
cp -f /web/lanmp/fastcgi.conf /usr/local/nginx/conf/fastcgi.conf
啟動nginx
ulimit -SHn 65535
/usr/local/nginx/sbin/nginx 直接啟動
配置開機自啟動
cp /web/lanmp/initd/nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig nginx on
service nginx start|stop|restart|reload
第四步:安裝php5.5.13
cd ..
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
=====================================================================
編譯libiconv解決./stdio.h:1010:1: 錯誤: ‘gets’未聲明(不在函數內)
cd srclib/
sed -i -e "/gets is a security/d" ./stdio.in.h
cd ../
make
cd ..
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
cd ..
cd ..
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/lib64/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
cd ..
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
=====================================================================
遇到問題:configure: error: * libmcrypt was not found
繼續查找,還是變量的問題
解決方法如下:運行
安裝php:
cd ..
tar zxvf php-5.6.11.tar.gz
cd php-5.6.11
./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
--enable-fpm
--enable-calendar
--enable-dba
--enable-wddx
--enable-opcache
--with-fpm-user=php-fpm
--with-fpm-group=php-fpm
--with-mysql=mysqlnd
--with-mysql-sock=/tmp/mysql.sock
--with-libxml-dir=/usr
--with-xsl
--with-gd
--with-bz2
--with-kerberos
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-freetype-dir
--with-iconv-dir
--with-zlib-dir
--with-mcrypt
--enable-soap
--enable-gd-native-ttf
--enable-ftp
--enable-sockets
--enable-zip
--enable-posix
--enable-pcntl
--enable-mbstring
--enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf
--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap
--enable-mbregex
--enable-sysvsem
--enable-sockets
--enable-shmop
--enable-bcmath
--enable-xml
--enable-exif
--disable-ipv6
--with-pear
--with-curl
--with-openssl
--with-pdo-mysql
--enable-magic-quotes
--disable-fileinfo
======================================================
configure: error: Please reinstall the BZip2 distribution
yum install bzip2-devel.x86_64 -y
error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install libxslt-devel -y make ZEND_EXTRA_LIBS="-liconv"make
如果直接make出錯make: * [sapi/cli/php] Error 1
make install
php.ini設置cp /web/lanmp/php.ini /usr/local/php/etc/php.ini
cp /web/lanmp/php-fpm.conf /usr/local/php/etc/php-fpm.conf
fpm加入自啟動
cp /web/lanmp/initd/php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
service php-fpm start|stop|restart|reload
vi /etc/rc.local
輸入ulimit -SHn 65535
以上簡單部署 下面是增加部分的擴展和優化編譯PHP擴展模塊memcache、pdo_mysql、imagick
tar zxvf memcache-3.0.8.tgz
cd memcache-3.0.8
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
出錯出現configure: error: mysql_query missing!? 解決方法 ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make出錯
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
ln -s /usr/local/mysql/include/* /usr/local/include/
make
make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../
tar zxvf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1
/usr/local/php/bin/phpize
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
修改php.ini配置文件
vi /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"
并加入extension=memcache.so
extension=pdo_mysql.so
extension=imagick.so
執行下面的命令使配置文件立即生效:
kill -USR2 cat /usr/local/php/var/run/php-fpm.pid
其他(可選):
優化linux內核參數
vi /etc/sysctl.conf
在末尾增加以下內容:
Addnet.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 = 1net.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
使配置立即生效:
/sbin/sysctl -p
安裝opcache(因為PHP 5.5已經集成Zend Opcache,可以替代eaccelerator)
tar zxvf zendopcache-7.0.3.tgz
cd zendopcache-7.0.3
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
在php.ini中加入下面配置:
[opcache]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
?
1
2 # 使php.ini配置文件立即生效
kill -USR2 cat /usr/local/php/var/run/php-fpm.pid
常用命令:
修改完php.ini后執行:kill -USR2 cat /usr/local/php/var/run/php-fpm.pid
修改完nginx.conf后執行/usr/local/nginx/sbin/nginx -s reload
重啟mysql服務執行:service mysqld (start|stop|restart)
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/39610.html
摘要:寫在前面的話本文章緊接上一篇下編譯安裝。來完成常用的開發集成環境的基本搭建,本篇來記錄的安裝,還是那些步驟。 寫在前面的話 本文章緊接上一篇CentOS7.0下編譯安裝Nginx 1.10.0。來完成常用的web開發集成環境lnmp的基本搭建,本篇來記錄php的安裝,還是那些步驟。 安裝編譯工具、依賴包及下載源碼包 解壓編譯 安裝 啟動 編譯安裝 下載源碼 由于在上篇文章中編譯工具...
摘要:寫在前面的話本文章緊接上一篇下編譯安裝。來完成常用的開發集成環境的基本搭建,本篇來記錄的安裝,還是那些步驟。 寫在前面的話 本文章緊接上一篇CentOS7.0下編譯安裝Nginx 1.10.0。來完成常用的web開發集成環境lnmp的基本搭建,本篇來記錄php的安裝,還是那些步驟。 安裝編譯工具、依賴包及下載源碼包 解壓編譯 安裝 啟動 編譯安裝 下載源碼 由于在上篇文章中編譯工具...
摘要:下源碼安裝一前言之前,我的開發環境是。重新加載權限表將確保所有到目前為止所做的更改將立即生效。然后,和注意,如果是使用二進制包安裝了及相應的開發庫,不需要指定路徑。五參考資料入門教程編譯安裝編譯安裝 Debian9下源碼安裝LNMP 一、前言 之前,我的開發環境是Windows-10+PHP-7.1+Nginx-1.10+MariaDB-10.1。 后面開發需要使用到memcached...
閱讀 1507·2021-11-25 09:43
閱讀 4057·2021-11-15 11:37
閱讀 3192·2021-08-17 10:13
閱讀 3503·2019-08-30 14:16
閱讀 3535·2019-08-26 18:37
閱讀 2489·2019-08-26 11:56
閱讀 1128·2019-08-26 10:42
閱讀 609·2019-08-26 10:39