新服务器上装java PHP环境有什么一键安装的方便的方法?一般都是怎么安装环境的?
How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04 | DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04
How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6 | DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6
About Lemp
LEMP stack is a group of open source software to get web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. Since the server is already running CentOS, the linux part is taken care of. Here is how to install the rest.
Step One—Install the Required Repositories
We will be installing all of the required software with Yum. However, because nginx is not available straight from CentOS, we'll need to install the epel repository.
sudo yum install epel-release
Step Two—Install MySQL
The next step is to begin installing the server software on the virtual private server, starting with MySQL and dependancies.
sudo yum install mysql-server
Once the download is complete, restart MySQL:
sudo /etc/init.d/mysqld restart
You can do some configuration of MySQL with this command:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password.
Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.
CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the changes.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL
installation should now be secure. Thanks for using MySQL!
Step Three—Install nginx
As with MySQL, we will install nginx on our virtual private server using yum:
sudo yum install nginx
nginx does not start on its own. To get nginx running, type:
sudo /etc/init.d/nginx start
You can confirm that nginx has installed on your virtual private server by directing your browser to your IP address.
You can run the following command to reveal your server’s IP address.
ifconfig eth0 | grep inet | awk '{ print $2 }'
Step Four—Install PHP
The php-fpm package is located within the REMI repository, which, at this point, is disabled. The first thing we need to do is enable the REMI repository and install php and php-fpm:
sudo yum install php-fpm php-mysql
Step Five—Configure php
We need to make one small change in the php configuration. Open up php.ini:
sudo vi /etc/php.ini
Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.
cgi.fix_pathinfo=0
If this number is kept as a 1, the php interpreter will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative. Save and Exit.
Step Six—Configure nginx
Open up the default nginx config file:
sudo vi /etc/nginx/nginx.conf
Raise the number of worker processes to 4 then save and exit that file.
Now we should configure the nginx virtual hosts.
In order to make the default nginx file more concise, the virtual host details are in a different location.
sudo vi /etc/nginx/conf.d/default.conf
The configuration should include the changes below (the details of the changes are under the config information):
#
# The default server
#
server {
listen 80;
server_name example.com; location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
} error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Here are the details of the changes:
- Add index.php within the index line.
- Change the server_name to your domain name or IP address (replace the example.com in the configuration)
- Change the root to /usr/share/nginx/html;
- Uncomment the section beginning with "location ~ \.php$ {",
- Change the root to access the actual document root, /usr/share/nginx/html;
- Change the fastcgi_param line to help the PHP interpreter find the PHP script that we stored in the document root home.
Save and Exit
Open up the php-fpm configuration:
sudo vi /etc/php-fpm.d/www.conf
Replace the apache in the user and group with nginx:
[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[...]
Finish by restarting php-fpm.
sudo service php-fpm restart
Step Seven—RESULTS: Create a php info page
Although LEMP is installed, we can still take a look and see the components online by creating a quick php info page
To set this up, first create a new file:
sudo vi /usr/share/nginx/html/info.php
Add in the following line:
<?php
phpinfo();
?>
Then Save and Exit.
Restart nginx so that all of the changes take effect:
sudo service nginx restart
Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.php
It should look similar to this.
Step Eight—Set Up Autostart
You are almost done. The last step is to set all of the newly installed programs to automatically begin when the VPS boots.
sudo chkconfig --levels 235 mysqld on
sudo chkconfig --levels 235 nginx on
sudo chkconfig --levels 235 php-fpm on
新服务器上装java PHP环境有什么一键安装的方便的方法?一般都是怎么安装环境的?的更多相关文章
- 新服务器搭建-总结: 下载nginx,jdk8,docker-compose编排(安装mysql,redis) 附安装
三明SEO: 前言 如题, 公司新买了一条4核16G的服务器, 不得不重新搭建环境, 只能一一重来, 做个记录 1.nginx : 手动安装 2.jdk8: 手动安装 3. 安装docker 及doc ...
- JAVA开发环境和IntelliJ工具安装
在本地开发机中进行web项目的开发,部署到生产环境进行产品发布时,需要将web应用的文件打包成war包,War包可以放在Tomcat下的webapps或者word目录下,随着tomcat服务器的启动, ...
- Java学习 1.3——Java开发环境的搭建:安装JDK,配置环境变量
了解了基本的Java知识后,就需要开始搭建开发环境了. 一,安装JDK JDK1.8下载地址 接受协议,选择选择自己的系统,我的是Windows64位: 点进去后会让你登录Oracle账号,没有就创建 ...
- java开发环境搭建(jdk安装)和经常出现问题的探讨
面对许多java初学者环境搭建出现的问题 第一步: 1,首先在可以百度jdk进入oracle的官网也可以进入这个网站 https://www.oracle.com/technetwork/java/j ...
- 3. Java开发环境的搭建:安装JDK,配置环境变量
1.安装JDK开发环境 下载网站:http://www.oracle.com/ 开始安装JDK: 修改安装目录如下: 确定之后,单击“下一步”. 注:当提示安装JRE时,可以选择不要安装. 2.配置环 ...
- Java语言环境(JDK的安装教学)
//此文档由徐浩军编写(32/64位系统都适用) 1.下载JDK安装包你 2.点击安装包开始安装 3.首先你要选择安装地址一般情况下,都会选择默认地址. (请记住这个地址,之后配置环境变量的时候需要用 ...
- JAVA EE 环境配置——JAVA8 下载安装和 Eclipse EE的下载安装
说明:我的电脑是win10 64位操作系统 步骤1:下载Java8 浏览器输入www.oracle.com,点击 Downloads,选择 Java ,选择 Java (JDK) for Develo ...
- Java开发环境配置(4)--Maven安装 环境变量配置,本地仓库配置---插件安装
说明在前:本人用过的 luna mars 等,都已经自带maven插件的了,以下有些文章是很老的,讲到maven插件的安装都可以忽略掉. maven安装eclipse在线配置maven搞定所有插件_ ...
- 在CentOS上安装Java开发环境:使用yum安装jdk
请参考百度经验:http://jingyan.baidu.com/article/4853e1e51d0c101909f72607.html 如果您阅读过此文章有所收获,请为我顶一个,如果文章中有错误 ...
随机推荐
- (4.1)mysql备份还原——mysql常见故障
(4.1)mysql备份还原——mysql常见故障 1.常见故障类型 在数据库环境中,常见故障类型: 语句失败,用户进程失败,用户错误 实例失败,介质故障,网络故障 其中最严重的故障主要是用户错误和介 ...
- 前端 html button标签
就是一个按钮标签 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- 别让Open Sans字体拖慢wordpress后台速度
最近打开wordpress后台是不是很慢?国内GG登不上了?这两者有没什么直接的联系?没错,WordPress后台是自动加载的谷歌Open Sans字体,据说gg服务器已经迁移到阿嘛丽可,需要一些小手 ...
- vue中的路由高亮
- abap异常处理 , update module
1:异常 https://www.cnblogs.com/rainysblog/p/6665455.html 2:update module https://www.cnblogs.com/cindy ...
- ASP.Net中的四种状态保持机制
每个人上网可多有过这样的情况,当我们登陆某个网站时,在登陆的旁边会有一个 "记住我" 的复选框,有的网站还会让用户选择记住我.这个记住我是怎么实现的呢? 其实就用利用的是cooki ...
- Java后台+数据库+Java web前端(新手)
实现简单页面上对数据的增删改查:Java后台+数据库表+Jsp前端网页设计 这里做一个简单的学生课程信息管理系统,做之前一定要先有自己的思路,要不然对新手来说,很容易乱的. 另有一完整的代码可供参考, ...
- JAVA代码(GET方式)请求URL(HTTP,HTTPS)
/** * * @param url 这个只支持http地址,不支持https * @param request * @return */ public static String sendMessa ...
- iOS 设计模式-Block实现代理的逻辑
在A页面,点击跳转到B页面,B页面操作完,回到A页面,并刷新A页面的内容.典型的例子,就是在一个列表里,点击新增,跳到新增页面,新增完,把数据传回给列表页,并刷新列表页里的内容. 这个,我平时一般是通 ...
- 27.给input边框和背景颜色设置全透明
给input边框和背景颜色设置全透明,但是里面的字不会消失 1.让背景颜色变透明(二选一) background-color:rgba(0,0,0,0); background:rgba(0,0,0, ...