LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。
Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统。
Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。
Mysql是一个小型关系型数据库管理系统。
这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
#!/bin/bash a=‘yum install -y‘ b=‘yum groupinstall -y‘ yum_gpk(){ cd /usr/local/src $a wget libmcrypt-devel bzip2-devel gcc pcre-devel openssl-devel php-mcrypt libmcrypt libxml2-devel libjpeg-devel libpng-devel freetype-devel $b "Development Tools" wget http://cn2.php.net/distributions/php-5.5.38.tar.gz wget http://nginx.org/download/nginx-1.12.0.tar.gz } nginx_install(){ cd /usr/local/src useradd nginx tar zxvf nginx-1.12.0.tar.gz cd nginx-1.12.0/ ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre make && make install cd /usr/local/nginx/sbin/ ./nginx netstat -ntlp | grep nginx } nginx_check(){ prog="nginxd" nginx_bin="/usr/local/nginx/sbin/nginx" if [ -x ${nginx_bin} ]; then echo "Nginx is installd" else echo -n "Nginx is not installed" exit 5 fi } php_install(){ cd /usr/local/src tar zxvf php-5.5.38.tar.gz cd php-5.5.38/ ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-mcrypt --with-bz2 --enable-fpm --with-gd make && make install cp /usr/local/src/php-5.5.38/php.ini-production /usr/local/php/etc/php.ini mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf useradd -M -s /sbin/nologin php sed -i -e ‘s\;pid = run/php-fpm.pid\pid = run/php-fpm.pid\g‘ -e ‘s\nobody\php\g‘ -e ‘s\listen = 127.0.0.1:9000\listen = 0.0.0.0:9000\g‘ /usr/local/php/etc/php-fpm.conf sed -i ‘s\;daemonize = yes\daemonize = no\g‘ /usr/local/php/etc/php-fpm.conf /usr/local/php/sbin/php-fpm & } php_check(){ netstat -ntlp | grep php a=`echo $?` if [ $a -eq 0 ];then echo "php is installd" else echo "php isn‘t installd" fi } mysql_install(){ $a mysql mysql-server systemctl start mysqld mysqladmin -uroot -password"123456" mysql -uroot -p123456 -e "create database wordpress" mysql -uroot -p123456 -e "show databases" mysql -uroot -p123456 -e "grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘; FLUSH PRIVILEGES;" } mysql_check(){ netstat -ntlp | grep mysql if [ $? -eq 0 ];then echo "mysqld is installd" else echo "mysqld isn‘t installd" fi } wordpress_install(){ mkdir /web cd /web/ wget https://cn.wordpress.org/wordpress-4.8-zh_CN.tar.gz tar zxvf wordpress-4.8-zh_CN.tar.gz cp –rd wordpress/* /web cp wordpress/wp-admin wordpress/wp-content wordpress/wp-includes -r /web } main(){ yum_gpk nginx_install nginx_check php_install php_check mysql_install mysql_check wordpress_install } main
仅提供参考,后续有待完善代码。。。。
时间: 2024-10-10 23:01:21