CentOS在安装配置 Ngnix_tomcat_PHP_Mysql
安裝Nginx
yum install nginx假設(shè)顯示找不到 nginx包,新建一個文件/etc/yum.repos.d/nginx.repo,內(nèi)容: [nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
當(dāng)中:OS替換成centos或者rhel,依據(jù)你安裝的發(fā)行版版本號?OSRELEASE替換成5,6或者7,分別相應(yīng)著5.想,6.x,7.x 如: [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1 ~刪除之前的httpd yum remove httpd
安裝 yum install ngnix
推斷conf /usr/sbin/nginx -t
啟動: service nginx restart
增加自啟動 chkconfig --levels 235 nginx on
安裝PHP
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidyvi /etc/php.ini
在文件末尾加入cgi.fix_pathinfo = 1
service php-fpm startphp-fpm增加啟動項(xiàng):
chkconfig --levels 235 php-fpm on
安裝Tomcat
下載解壓到/usr/local/tomcat port改為8090 啟動就可以安裝mysql:
yum install mysql mysql-server 設(shè)置password: mysql>use mysql; mysql>update user set password=password('你的密碼') where user='root'; mysql>flush privileges;改動password:grant all on *.* to 'root'@'localhost' IDENTIFIED BY '你的password'with grant option ; flush privileges
配置Nginx:
進(jìn)入/etc/nginx 新建一個文件: proxy.conf:proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;
進(jìn)入:/etc/nginx/conf.d 新建tomcat.conf server {listen 8080;server_name localhost;#charset koi8-r;#access_log /var/log/nginx/log/host.access.log main;location / {#root /usr/share/nginx/html;index index.html index.htm;proxy_pass http://127.0.0.1:8090/;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}# proxy the PHP scripts to Apache 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_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#} }
nginx配置完畢
配置default.conf(也能夠新建一個): server {listen 80;server_name localhost;#charset koi8-r;#access_log /var/log/nginx/log/host.access.log main;location / {#root /usr/share/nginx/html;root /var/www/html;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}# proxy the PHP scripts to Apache 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_param SCRIPT_FILENAME ?$document_root$fastcgi_script_name;include fastcgi_params;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#} }
重新啟動就可以 也能夠平滑重新啟動:/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
注:
chkconfig?使用范例:
chkconfig --list??????? #列出全部的系統(tǒng)服務(wù)
chkconfig --add httpd??????? #添加httpd服務(wù)
chkconfig --del httpd??????? #刪除httpd服務(wù)
chkconfig --level httpd 2345 on??????? #設(shè)置httpd在執(zhí)行級別為2、3、4、5的情況下都是on(開啟)的狀態(tài)
chkconfig --list??????? #列出系統(tǒng)全部的服務(wù)啟動情況
chkconfig --list mysqld??????? #列出mysqld服務(wù)設(shè)置情況
chkconfig --level 35 mysqld on??????? #設(shè)定mysqld在等級3和5為開機(jī)執(zhí)行服務(wù),--level 35表示操作僅僅在等級3和5執(zhí)行。on表示啟動,off表示關(guān)閉
chkconfig mysqld on??????? #設(shè)定mysqld在各等級為on,“各等級”包含2、3、4、5等級
怎樣添加一個服務(wù):
1.服務(wù)腳本必須存放在/etc/ini.d/文件夾下。
2.chkconfig --add servicename
??? 在chkconfig工具服務(wù)列表中添加此服務(wù),此時服務(wù)會被在/etc/rc.d/rcN.d中賦予K/S入口了;
3.chkconfig --level 35 mysqld on
??? 改動服務(wù)的默認(rèn)啟動等級。
版權(quán)聲明:本文博客原創(chuàng)文章,博客,未經(jīng)同意,不得轉(zhuǎn)載。
轉(zhuǎn)載于:https://www.cnblogs.com/blfshiye/p/4622882.html
總結(jié)
以上是生活随笔為你收集整理的CentOS在安装配置 Ngnix_tomcat_PHP_Mysql的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javaweb学习总结(三十三)——使用
- 下一篇: 介绍一下Objective-c常用的函数