• Resolved sebacodroipo

    (@sebacodroipo)


    Hello,

    I have been looking at wp forum threads regarding this issue, there are plenty of info but I still can’t manage to solve my problem. I am working on Linux Mint, installed manually apache, mysql and php, created the database and the user, installed wp and created my site on localhost (/var/www/html). No issue.
    I now need to move the first site in a subdirectory in order to install a new wp site in my localhost. I tried moving the whole folder in the subdirectory and creating the new .htaccess file as mentioned here

    https://www.ads-software.com/support/article/giving-wordpress-its-own-directory/#moving-a-root-install-to-its-own-directory

    but it didn’t work. I suppose this is because I am making mistakes. How do I exactly change the example.com with my localhost path? I tried changing the example.com with localhost or the path /var/www/html, including/excluding the ? at the beginning and the $ at the end but i still get an error page with the header and the footer of my site and the error message

    Oops! That page can’t be found.
    It looks like nothing was found at this location. Maybe try one of the links below or a search?

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteCond %{REQUEST_URI} !^/my_subdir/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /my_subdir/$1
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteRule ^(/)?$ my_subdir/index.php [L]
    </IfModule>

    Or maybe the .htaccess is not suitable for my situation?
    Thank you in advance for any usefull information.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Yui

    (@fierevere)

    永子

    You can create new domain name in /etc/hosts pointing at 127.0.0.1 (localhost)
    and set up VirtualHost in apache config, pointing to other directory, then install WP here.
    https://httpd.apache.org/docs/2.4/vhosts/
    You can use different IP adresses too, any 127.0.0.x points at your local machine

    Or using subfolders is important for you?

    Thread Starter sebacodroipo

    (@sebacodroipo)

    First of all thank you for the super quick response.

    So, I’ll rephrase to see if I got it right. I leave the first website in /var/www/html, create a new domain in the hosts file (let’s say 127.0.0.2) and then, via the VirtualHost in apache, link the new IP to another folder (anywhere on my computer?). After completing this passage then in my browser I could reach this other website accessing 127.0.0.2 instead of localhost, right?

    I wouldn’t say using subfolders it’s imperative, having both sites in two folders in the same main folder would be nicer from an “order” point of view.

    Moderator Yui

    (@fierevere)

    永子

    I’ll rephrase to see if I got it right

    Yes.
    See Apache documentation, you can configure VirtualHost to be name based
    (add IP and hostname to /etc/hosts, then restart all programs that need to know about update – apache, web browser)
    You can use an alias for 127.0.0.1 too, just add new hostname (can be in its own line)
    or you can use IP based VirtualHost, you still can add name for it in /etc/hosts

    so you can have wordpress.local and myothersite.local
    for example.
    You even can override existing domain name in /etc/hosts, to develop a site that will be moved to real host later.

    Thread Starter sebacodroipo

    (@sebacodroipo)

    @flerevere

    again thank you very much for the response.

    So I can assign to different names to the same IP address (127.0.0.1, adding it on the same line of the host file) so that when I load the IP in my browser i get to select the two websites, right?

    You even can override existing domain name in /etc/hosts, to develop a site that will be moved to real host later.

    meaning I can name them whatever I want taking in consideration the name I’d choose for the website when I decide to publish it online.

    thanks again and have a nice day ??

    Moderator Yui

    (@fierevere)

    永子

    So I can assign to different names to the same IP address (127.0.0.1, adding it on the same line of the host file) so that when I load the IP in my browser i get to select the two websites, right?

    You can stick both sites to same IP, but define them with different hostnames (pointing to same IP), you visit your site by typing its hostname (not its IP!) in browser. Browser sends to server “Host:” header, telling the server which of the sites you want to see. Thats how name-based virtualhosting works (for HTTP/1.1 and better)

    meaning I can name them whatever I want taking in consideration the name I’d choose for the website when I decide to publish it online.

    Exactly, thats whats /etc/hosts file is for. Just wont forget to restart software using it after changing this file.

    Hi @sebacodroipo,

    Are you trying to set up your own development environment on localhost, or are you trying to let others get access to it over the internet?

    Thread Starter sebacodroipo

    (@sebacodroipo)

    Hi @pcxt8088 ,

    I was trying to set up my development environment on localhost, when I am done making my experiments I will publish it.

    @sebacodroipo

    when I am done making my experiments I will publish it.

    But how are you going to publish your website?

    Are you trying to give people public access to your local development environment running on your machine at home across the internet?

    @sebacodroipo,

    or are you going to FTP your site code to a remote server when you have made the changes?

    Thread Starter sebacodroipo

    (@sebacodroipo)

    I am not sorry if I look like an ignorant (which I am): I meant I was going to buy a domain and some webhosting and upload it there.

    Hi @sebacodroipo,

    I have set up my develop and live websites on my own machine before, and then made the live branch accessible to the outside world. It’s a lot of hassle to get that all working though. IMHO it’s a lot easier to use a remote hosting company for beta and live websites.

    If you are using your own machine for development purposes only, then you can work out a suitable directory structure to organise where you put all your websites.

    I’m running Linux Mint 18 on my laptop with multiple installations of WordPress and OpenCart plus other websites, and my directory structure is:

    
    aspire-laptop html # pwd
    /var/www/html
    
    aspire-laptop html # tree -dL 1 websites
    websites
    ├── develop
    ├── evaluate
    ├── examples
    ├── originals
    ├── test
    ├── tutorials
    └── wordpress-src
    

    You can put any number of websites under your Apache web server’s DocumentRoot folder, which for Linux Mint defaults to /var/www/html/

    If you create a directory where you want to install WordPress into, then all you need to do is open the index.php file in a browser with the full path like:

    https://127.0.0.1/websites/evaluate/wordpress/5.4/wordpress/index.php

    and install WP there. (Obviously you will need to use a separate database name and username & password for each installation of WordPress you are testing.)

    NB:
    There seems to be an issue now with Firefox 75.0 accessing localhost, but this works with 127.0.0.1 instead. This was working until I updated Firefox to 75.0 (64-bit) yesterday.

    Chrome appears to work OK though using localhost.

    That’s all you need to do for setting up your own personal development environment to test and experiment with WordPress.

    If you are looking for some decent web hosting, I have been using

    https://www.unlimitedwebhosting.co.uk/web-hosting/plesk

    Which runs OpenCart (another PHP-based web application) OK.

    (See their reviews here: https://uk.trustpilot.com/review/www.unlimitedwebhosting.co.uk )

    With remote web hosting all you need is one domain like example.com then you can set up subdomains on that, like test.example.com, beta.example.com, etc.

    Probably the main issue you could have with deploying to remote shared web hosting is database names and usernames will not be the full length as used on localhost, due to using a prefix for each user of the shared hosting database.

    HTH ??

    • This reply was modified 4 years, 11 months ago by pcxt8088.
    Thread Starter sebacodroipo

    (@sebacodroipo)

    Hi @pcxt8088 ,

    thank you for the very interesting message. I was going to reply to that message having solved all of my problems, but of course I incurred in other problems. Maybe you can help me, otherwise I will repost this in a new thread. I am running Mint Cinnamon 19.1. I managed to install the second wp site in another folder, the structure looks like this:

    /var/www/
    ├── html
    └── firstsite
    └── secondsite

    so after installing secondsite, I couldn’t install nor update any plugin because I always got a request to go through FTP. This was happening on both sites. I looked around on various forums and found a solution adding the

    *define(‘FS_METHOD’,’direct’);

    line in the config. file and modifying the Permissions for both html and secondsite folder. After some trial and error yesterday, I found out that I had to set the permission as

    Owner: www-data
    Folder Access: Create and delete files
    File Access: –

    Group: www-data
    Folder Acces: Access files
    File Access:

    Folder Access: Create and delete files
    File Access: –

    This morning I logged in on secondsite. I tried installing a theme but got again the FTP problem, I went back to the config file and permission and set them up again. I don’t know what went wrong, but I now can’t connect to neither secondsite/ nor to secondsite/wp-login.php. I always get error 500. I activated in the config file the debugging options

    define( ‘WP_DEBUG’, true );
    define( ‘WP_DEBUG_LOG’, true );

    but no error log gets created when I try to load the page.
    I had only installed Jetpack yesterday night, I tried deactivate the plugins by renaming the folder (as suggested in numerous forum threads regarding this issue) but to no result.

    As for firstsite/, everything is working perfectly, I can log in and download/update plugins and themes.

    Any suggestion?

    Hi @sebacodroipo,

    Good to see you are making progress.

    Yes I think it might be better if you copy and repost this and give it a new title for your current problem.

    I’ll look out for that post then.

    ??

    Thread Starter sebacodroipo

    (@sebacodroipo)

    original issue solved

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Two WP installation on localhost, LINUX’ is closed to new replies.