lnmp环境脚本自动配置
生活随笔
收集整理的這篇文章主要介紹了
lnmp环境脚本自动配置
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#!/usr/bin/env bash
echo "=============START====================="
cd /home/
echo '[yum] 安裝epel-release第三方軟件包'
yum install epel-release -y
#安裝php5.6.31
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
echo '[PHP] yum install php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd'
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd
# 設(shè)置PHP 默認(rèn)時(shí)區(qū)
echo '[php]change php.ini date.timezone'
sed -i 's/^;date\.timezone\ =/date\.timezone\ =\ "Asia\/Shanghai"/' /etc/php.ini
sed -i 's/^user\ =\ apache/user\ =\ nginx/' /etc/php-fpm.d/www.conf
sed -i 's/^group\ =\ apache/group\ =\ nginx/' /etc/php-fpm.d/www.conf# 安裝mysql5.7
echo '[msyql]install mysql mysql5.7-server'
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
yum install mysql-community-server -y# 安裝 redis
yum install redis -y# 安裝 ningx
echo '[nginx]install nginx'
yum install nginx -yecho 'mkdir /home/wwwroot/'
mkdir -p /home/wwwroot/logs
mkdir /home/wwwroot/default_site
touch /home/wwwroot/default_site/index.php
echo '<?php phpinfo();' > /home/wwwroot/default_site/index.php
#mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bakecho "[nginx] SET DOMAIN(ignore www,like baidu.com):--------------->"read DOMAIN
confile="/etc/nginx/conf.d/${DOMAIN}.conf"
touch $confilesecho '
server {listen 80;charset utf-8;
' > $confileecho "server_name _ ${DOMAIN} www.${DOMAIN};root /home/wwwroot/${DOMAIN}/;access_log /home/wwwroot/logs/${DOMAIN}_access.log main;error_log /home/wwwroot/logs/${DOMAIN}_error.log;
" >> $confileecho 'location /{index index.php index.html index.htm;if (!-e $request_filename){rewrite ^/(.*)$ /index.php/$1 last;}# Must www# if ($http_host !~ "^www\.domain\.com$") {# rewrite ^(.*) http://www.domain.com$1 permanent;# }}location ~ ^.+\.php{fastcgi_buffer_size 128k;fastcgi_buffers 32 32k;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;include fastcgi_params;}#error_page 404 /404.html;error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}# deny cilocation ^~ /views|controllers|config {deny all;}# deny .htlocation ~ /\.ht {deny all;}# deny .gitlocation ~ /\.git {deny all;}# location ~* ^.+\.(ico|gif|jpg|jpeg|png|html|htm|css|js|txt|xml|swf|wav)$ {# # root /home/http/object/static;# access_log off;# expires 30d;# }
}
' >> $confileecho '[php]start php-fpm'
systemctl start php-fpm.service
systemctl enable php-fpm.serviceecho '[nginx]start nginx'
systemctl start nginx.service
systemctl enable nginx.serviceecho '[mysql]start mysql'
systemctl start mysqld.service
systemctl enable mysqld.serviceecho '[redis]start redis'
systemctl start redis.service
systemctl enable redis.serviceecho '======================END=========================='
echo '[end]open the IP site,read phpinfo '
echo 'web: /home/wwwroot/'
echo 'nginx: /etc/nginx/conf.d/'
echo 'php: /etc/php.init /etc/php-fpm.d/www.conf'
echo 'mysql: /etc/my.ini' # 查看mysql5.7初始密碼 grep 'temporary password' /var/log/mysqld.log? # 登入后第一步修改密碼 alter user root@localhost identified by 'Taozhuzhu!@#123';
轉(zhuǎn)載于:https://www.cnblogs.com/mmmzh/p/10077831.html
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的lnmp环境脚本自动配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 平安银行分期卡啥意思
- 下一篇: 存折和卡的钱是互通吗