CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7
2019獨角獸企業重金招聘Python工程師標準>>>
CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7
使用 Netkiller OSCM 一鍵安裝PHP環境
Mr.?Neo Chen?(陳景峯),?netkiller, BG7NYT
中國廣東省深圳市龍華新區民治街道溪山美地
518131
+86?13113668890
<netkiller@msn.com>
$Id: setup.xml 608 2013-05-31 11:25:25Z netkiller
版權聲明
轉載請與作者聯系,轉載時請務必標明文章原始出處和作者信息及本聲明。
| |
| | 微信掃描二維碼進入 Netkiller 微信訂閱號 QQ群:128659835 請注明“讀者” |
?
2018-01-12: 2013-05-31 19:25:25 +0800 (Fri, 31 May 2013)
摘要
在工作中,需要經常為新系統安裝軟件,重復而簡單,但又不得不作,我將過去幾年中工作中臨時寫的腳本這里了一下,能夠實現半自動化安裝標本,只需要Ctrl+C, Ctrl+V 快速粘貼復制,即可快速完成安裝
目錄
- 1. CentOS 7 64bit (Minimal ISO) 安裝后 新機初始化常用軟件包安裝
- 2. MySQL-5.7
- 3. php-7.2
- 4. nginx-1.12
- 4.1. host 配置
- 5. redis-4.0.6
- 6. MongoDB
1.?CentOS 7 64bit (Minimal ISO) 安裝后 新機初始化常用軟件包安裝
Minimal ISO
初始化操作系統
curl -s https://raw.githubusercontent.com/oscm/shell/master/os/personalise.sh | bash2.?MySQL-5.7
卸載舊的包,以免出現沖突
rpm -e --nodeps mysql-libs yum localinstall MySQL-*安裝 MySQL
curl -s https://raw.githubusercontent.com/oscm/shell/master/database/mysql/5.7/mysql57-community-release-el7-11.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/database/mysql/5.7/mysql.server.sh | bash安裝完成后會提示臨時密碼
2018-01-08T00:39:52.431840Z 1 [Note] A temporary password is generated for root@localhost: 6)?#raQPKf3s [root@localhost my.cnf.d]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.20Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>使用這個密碼登陸,然后修改密碼
ALTER USER root@localhost identified by 'MQiEge1ikst7S_6tlXzBOmt_4b'; ALTER USER root@localhost PASSWORD EXPIRE NEVER;?
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'chen' WITH GRANT OPTION; FLUSH PRIVILEGES;3.?php-7.2
?
安裝編譯器和一些依賴的devel包。
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/gcc/gcc.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/7.1/devel.sh | bash安裝 PHP 7.2
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/7.2/php-7.2.1.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/php-profile.sh | bash安裝 PHP 擴展
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/pecl/amqp.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/pecl/mongodb.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/pecl/pthreads.sh | bash curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/php/pecl/phalcon.sh | bashRedis 暫不支持 7.2,至少現在沒有穩定版本,我們只能使用最新的Release版本。
https://raw.githubusercontent.com/oscm/shell/master/lang/php/7.2/extension/redis.sh4.?nginx-1.12
為web服務器創建一個用戶,我喜歡使用www,id為80更容易記,同時將一個單獨分區掛在/www上用戶存放web應用程序。
curl -s https://raw.githubusercontent.com/oscm/shell/master/os/user/www.sh | bash安裝 nginx
curl -s https://raw.githubusercontent.com/oscm/shell/master/web/nginx/stable/nginx.sh | bash如果你不懂編譯器優化,建議你使用yum方案。在不優化的情況下編譯出來程序很臃腫。
[root@localhost src]# rpm -qa | grep nginx nginx-release-centos-7-0.el7.ngx.noarch nginx-1.12.2-1.el7_4.ngx.x86_64配置虛擬主機
4.1.?host 配置
mkdir -p /www/www.mydomain.com/htdocscd /etc/nginx/conf.d cp default.conf www.mydomain.com.conf vim www.mydomain.com.conf server {listen 80;server_name www.mydomain.com;charset utf-8;access_log /var/log/nginx/www.mydomain.com.access.log main;location / {root /www/www.mydomain.com/htdocs;index index.html index.php;}#error_page 404 /404.html;# redirect server error pages to thestatic page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}# proxy the PHP scripts toApache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_paramSCRIPT_FILENAME /www/www.mydomain.com/htdocs$fastcgi_script_name;include fastcgi_params;}# deny access to .htaccess files, ifApache's document root# concurs with nginx's one#location ~ /\.ht {deny all;} }創建測試頁面
cat >> /www/www.mydomain.com/htdocs/index.php <<PHP <?php phpinfo(); PHP啟動服務器
service php-fpm startservice nginx start檢查index.php輸出
# curl -H HOST:www.mydomain.com http://127.0.0.1/index.php5.?redis-4.0.6
安裝 Redis 因為YUM安裝的Redis版本比較低,所以我們選擇了源碼安裝
curl -s https://raw.githubusercontent.com/oscm/shell/master/database/redis/source/redis-4.0.6.sh | bash安裝redis
[root@localhost redis-4.0.6]# redis-cli 127.0.0.1:6379> set nickname netkiller 10 (error) ERR syntax error 127.0.0.1:6379> get nickname (nil) 127.0.0.1:6379> set nickname netkiller OK 127.0.0.1:6379> get nickname "netkiller" 127.0.0.1:6379> expire nickname 5 (integer) 1 127.0.0.1:6379> get nickname (nil) 127.0.0.1:6379>6.?MongoDB
curl -s https://raw.githubusercontent.com/oscm/shell/master/database/mongodb/mongodb.org/mongodb-3.6.sh | bash轉載于:https://my.oschina.net/neochen/blog/1606365
總結
以上是生活随笔為你收集整理的CentOS 7 + nginx-1.12 + php-7.2 + MySQL-5.7的全部內容,希望文章能夠幫你解決所遇到的問題。